class RED::RenderShaderEnvironmental

Environmental mapping shader. More...

#include <REDRenderShaderEnvironmental.h>

Inherits: RenderShader.

Public functions:

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, bool iFresnel, float iFresnelIOR, const RED::Object * iNormalMap, const RED::Matrix & iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, RED::Object * iResMgr, RED_RC & oErrorCode )
virtual ~RenderShaderEnvironmental ( )
virtual void *As ( const RED::CID & iCID )
virtual const void *As ( const RED::CID & iCID ) const
template< class T_As > const T_As *As ( ) const
template< class T_As > T_As *As ( )

Public static functions:

static RED_RCEvaluateFromInputParameters ( RED::RenderShader * ioShader, RED::Object * iResMgr )
static RED::CIDGetClassID ( )
static RED_RCLoadProgram ( RED::String & oString, const RED::ShaderProgramID & iID )

Detailed description:

Environmental mapping shader.

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:

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.

Functions documentation

public RED::RenderShaderEnvironmental::RenderShaderEnvironmental(RED::MATERIAL_PASSiRenderingPass,
const RED::Color &iSpecularColor,
const RED::Object *iSpecularTexture,
const RED::Matrix &iSpecularMatrix,
RED::MESH_CHANNELiSpecularUV,
const RED::Color &iReflectColor,
const RED::Object *iReflectTexture,
const RED::Matrix &iReflectMatrix,
RED::MESH_CHANNELiReflectUV,
const RED::Object *iCubeMap,
const RED::Matrix &iCubeMatrix,
booliAutoEnvironment,
booliVRLEnvironment,
booliFresnel,
floatiFresnelIOR,
const RED::Object *iNormalMap,
const RED::Matrix &iNormalMatrix,
RED::MESH_CHANNELiNormalUV,
RED::MESH_CHANNELiTangentChannel,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Constructor.

This shader can be created only for the following render passes:

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.
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.
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.

Destructor.

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.

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.
public virtual void * RED::RenderShaderEnvironmental::As(const RED::CID &iCID)

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::RenderShader::As.

public virtual const void * RED::RenderShaderEnvironmental::As(const RED::CID &iCID) const

Converts the object to an instance of the given type.

Parameters:

iCID:Requested class.

Returns:

An object pointer of the given class on success, NULL otherwise.

Reimplements: RED::RenderShader::As.

template< class T_As > public const T_As * RED::RenderShaderEnvironmental::As() const

Template version of the as const method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to a const instance of class T on success, NULL otherwise.

Reimplements: RED::RenderShader::As.

template< class T_As > public T_As * RED::RenderShaderEnvironmental::As()

Template version of the as method.

Simply set T to be the class you want to retrieve an interface to.

Returns:

A pointer to an instance of class T on success, NULL otherwise.

Reimplements: RED::RenderShader::As.