RenderShaderEnvironmental
Functions
Detailed Description
-
class RenderShaderEnvironmental : public RED::RenderShader
Environmental mapping shader.
@related Using Built-in Render Shaders, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode, workflow wf_environmental_mapping
This shader can be used to produce an environmental mapping effect. The color calculated by this shader is equal to:
color = specular_color * reflection_color * fresnel * environment_map_color.
The ‘specular_color’ and ‘reflection_color’ are similar. This lets the caller a way to modulate a reflectance map by an attenuation term for example. The ‘fresnel’ term is optional.
The ‘environment_map_color’ can be sourced from three different sources and supports bump mapping:
The caller’s specified cube map.
An automatic environment map calculated by the engine.
The background image of the VRL hosting the geometries drawn with this shader.
Please note that in software rendering, the automatic environment flag that lets the engine calculate a cube map is ignored: in this case, true ray-traced reflections should be setup instead and the environmental shader should be repladed by a RED::ReflectionShader that produce a much higher quality of reflections.
The RenderShaderEnvironmental can be used in a direct or indirect lighting configuration. This is selected at the shader’s creation time. A direct shader goes to the pre-lighting or to the post-lighting pass of the material, whereas an indirect shader goes to its indirect pre-lighting or indirect post-lighting pass.
Note that all parameters used by the shader use the RED_SHAD_TARGET_LIGHT_NO_LIGHT target (commonly used in its shortcut RED_L0 form).
This shader creates the following platform configurations in a direct lighting pass:
It creates the following platform configurations in an indirect lighting pass:
See the REDRenderShaderEnvironmental.h file documentation for the list of all #define statements used to name all parameters of this shader.
Public Functions
-
SET_CID(CID_class_REDRenderShaderEnvironmental)
-
IMPLEMENT_AS()
-
RenderShaderEnvironmental(RED::MATERIAL_PASS iRenderingPass, const RED::Color &iSpecularColor, const RED::Object *iSpecularTexture, const RED::Matrix &iSpecularMatrix, RED::MESH_CHANNEL iSpecularUV, const RED::Color &iReflectColor, const RED::Object *iReflectTexture, const RED::Matrix &iReflectMatrix, RED::MESH_CHANNEL iReflectUV, const RED::Object *iCubeMap, const RED::Matrix &iCubeMatrix, bool iAutoEnvironment, bool iVRLEnvironment, float iMipmap, bool iFresnel, float iFresnelIOR, const RED::Object *iFresnelIORTexture, const RED::Matrix &iFresnelIORMatrix, RED::MESH_CHANNEL iFresnelIORUV, const RED::Object *iNormalMap, const RED::Matrix &iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, RED::Object *iResMgr, RED_RC &oErrorCode)
Constructor.
This shader can be created only for the following render passes:
RED::MTL_PRELIT,
RED::MTL_POSTLIT,
RED::MTL_INDIRECT_PRELIT,
RED::MTL_INDIRECT_POSTLIT.
All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images or rectangular images using the RED::TGT_TEX_RECT target. Sampling UVs that are needed to sample 2D textures must be normalized. Sampling UVs that are needed to sample rectangular textures are denormalized with values directly sampling texels coordinates.
- Parameters
iRenderingPass – The target rendering pass.
iSpecularColor – Specular color that modulates the environmental map color.
iSpecularTexture – Object specular texture. Overrides the color when set.
iSpecularMatrix – Texture matrix applied to the iSpecularTexture.
iSpecularUV – Mesh UV channel to use to the specular texture.
iReflectColor – A reflection color that modulates the environment map color.
iReflectTexture – Reflection texture image to use instead of the reflection color.
iReflectMatrix – Transformation matrix applied to the reflection UV.
iReflectUV – UV channel source of the reflect texture mapping coordinates.
iCubeMap – The environment image.
iCubeMatrix – Transform matrix applied to the cube image sampling direction. This matrix is ignored if the iVRLEnvironment flag is activated and the value of RED::RenderShaderParameter::REF_VRL_BACKGROUND_CUBE_IMAGE_MATRIX is used instead.
iAutoEnvironment – If true, the value of iCubeMap is ignored, and the engine automatically calculates an environment map to use instead for the shader.
iVRLEnvironment – If true, the value of iCubeMap is ignored, the value of iAutoEnvironment is ignored and the engine will use the VRL background cube image as environment map for the shader.
iMipmap – Tells the shader about the number of the mipmap to be used if an environment cube map is to be used. Setting this value to 0.0 let the shader behave as it did for all REDsdk versions before REDsdk 5.3. Setting this value to a mipmap number greater than zero will render a blurry version of the environment cube map being used. This parameter is only for GPU rendering.
iFresnel – If true, the iCubeMap effect is modulated by a Fresnel term.
iFresnelIOR – IOR value that changes the Fresnel intensity. A value of 1 means no Fresnel term at all. Larger values produce a stronger Fresnel effect that strengthen the reflectance effect.
iFresnelIORTexture – IOR texture image to use instead of the reflection color.
iFresnelIORMatrix – Transformation matrix applied to the IOR UV.
iFresnelIORUV – UV channel source of the IOR texture mapping coordinates.
iNormalMap – Normal map that affect the environment mapping.
iNormalMatrix – Transformation matrix applicable to the normal map.
iNormalUV – UV channel source of the normals.
iTangentChannel – Tangent space channel for the normal mapping.
iResMgr – Cluster’s resource manager.
oErrorCode – Returned error code.
-
virtual ~RenderShaderEnvironmental()
Destructor.
Public Static Functions
-
static RED_RC LoadProgram(RED::String &oString, const RED::ShaderProgramID &iID)
Loads a shader program.
Generates a shader program that corresponds to the specified iID.
- Parameters
oString – The created program string.
iID – The shader program unique ID.
- Returns
RED_OK if the shader could be loaded,
RED_ALLOC_FAILURE if an allocation has failed,
RED_FAIL otherwise.
-
static RED_RC EvaluateFromInputParameters(RED::RenderShader *ioShader, RED::Object *iResMgr)
Evaluate a shader from its input parameters.
- Parameters
ioShader – Shader to redefine using its own input parameters.
iResMgr – The cluster’s resource manager.
- Returns
RED_OK if the operation has succeeded,
RED_BAD_PARAM if iShader was not valid,
RED_BAD_PARAM if an invalid parameter was found during the evaluation,
RED_ALLOC_FAILURE if a memory allocation has failed,
Other RED_RC related to shader creation can be returned.