class RED::RayReflectionShader

Reflection calculation shader for the ray-tracer. More...

#include <REDRayReflectionShader.h>

Inherits: RenderShader.

Public functions:

RayReflectionShader ( const RED::RenderShaderAnisotropic & iAniso, const RED::StateShader & iAlphaMask, float iBumpEffect, float iGlossyAngle, int iGlossySamples, RED::Object * iResMgr, RED_RC & oErrorCode )
RayReflectionShader ( const RED::RenderShaderPhong & iPhong, const RED::StateShader & iAlphaMask, float iBumpEffect, RED::Object * iResMgr, RED_RC & oErrorCode )
RayReflectionShader ( const RED::RenderShaderAnisotropic & iAniso, const RED::StateShader & iAlphaMask, float iBumpEffect, RED::Object * iResMgr, RED_RC & oErrorCode )
RayReflectionShader ( )
RayReflectionShader ( const RED::RenderShaderPhong & iPhong, const RED::StateShader & iAlphaMask, float iBumpEffect, float iGlossyAngle, int iGlossySamples, RED::Object * iResMgr, RED_RC & oErrorCode )
~RayReflectionShader ( )
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 ( )
RED_RCSetup ( const RED::Object * iNormalMap, const RED::Matrix & iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, const RED::StateShader & iState, float iBumpEffect, bool iGlossy, float iGlossyAngle, int iGlossySamples, RED::Object * iResMgr )

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:

Reflection calculation shader for the ray-tracer.

The RED engine ray-tracer is able to calculate true reflections based on the material definition of shapes. As the ray-tracer combines both CPU and GPU based calculations, it needs one specific shader to be defined to specify the reflection properties of the geometries rendered with the material, through this shader.

That shader calculates the world coordinate per pixel reflection vector to use for all reflection calculations. It can also be used for the calculations of glossy reflections using the appropriate constructors.

The RED::RayReflectionShader outputs its shaders in the RED::MTL_RAYTRACE of the material. Parameters for direct reflection vectors and for indirect reflection vectors are calculated.

This shader has 4 runtime platform configurations:

See the REDRayReflectionShader.h file documentation for the list of all define statements used to name all parameters of this shader.

Functions documentation

public RED::RayReflectionShader::RayReflectionShader(const RED::RenderShaderAnisotropic &iAniso,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for a glossy anisotropic reflection.

Build the reflection vector shader for a standard anisotropic lighting model. iAlphaMask contains a possible alpha mask that we need to consider when it exists to generate reflection vectors only on the correct alpha passed pixels.
This method setups glossy reflections. A glossiness spread angle has to be defined for glossy reflections to be enabled. A 0.0f angle will result in non glossy perfect reflections.

Parameters:

iAniso:Source anisotropic shader.
iAlphaMask:State shader with possible alpha masking parameters.
iBumpEffect:Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].
iGlossyAngle:Angle of glossiness in [0.0f,RED_PI / 2.0f].
iGlossySamples:Number of samples. Must be in the range [1,256].
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.
public RED::RayReflectionShader::RayReflectionShader(const RED::RenderShaderPhong &iPhong,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for a phong reflection.

Build the reflection vector shader for a standard phong lighting model. iAlphaMask contains a possible alpha mask that we need to consider when it exists to generate reflection vectors only on the correct alpha passed pixels.

Parameters:

iPhong:Source phong shader.
iAlphaMask:State shader with possible alpha masking parameters.
iBumpEffect:Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.
public RED::RayReflectionShader::RayReflectionShader(const RED::RenderShaderAnisotropic &iAniso,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for an anisotropic reflection.

Build the reflection vector shader for a standard anisotropic lighting model. iAlphaMask contains a possible alpha mask that we need to consider when it exists to generate reflection vectors only on the correct alpha passed pixels.

Parameters:

iAniso:Source anisotropic shader.
iAlphaMask:State shader with possible alpha masking parameters.
iBumpEffect:Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.

RayReflectionShader construction method.

public RED::RayReflectionShader::RayReflectionShader(const RED::RenderShaderPhong &iPhong,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for a glossy phong reflection.

Build the reflection vector shader for a standard phong lighting model. iAlphaMask contains a possible alpha mask that we need to consider when it exists to generate reflection vectors only on the correct alpha passed pixels.
This method setups glossy reflections. A glossiness spread angle has to be defined for glossy reflections to be enabled. A 0.0f angle will result in non glossy perfect reflections.

Parameters:

iPhong:Source phong shader.
iAlphaMask:State shader with possible alpha masking parameters.
iBumpEffect:Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].
iGlossyAngle:Angle of glossiness in [0.0f,RED_PI / 2.0f].
iGlossySamples:Number of samples. Must be in the range [1,256].
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.

RayReflectionShader destruction method:

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

public RED_RC RED::RayReflectionShader::Setup(const RED::Object *iNormalMap,
const RED::Matrix &iNormalMatrix,
RED::MESH_CHANNELiNormalUV,
RED::MESH_CHANNELiTangentChannel,
const RED::StateShader &iState,
floatiBumpEffect,
booliGlossy,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr
)

Builds a ray reflection deviation shader.

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:

iNormalMap:Surface normal perturbation map. NULL for no normal map.
iNormalMatrix:Normal map texture transformation matrix.
iNormalUV:Normal map texture UV mesh channel.
iTangentChannel:Mesh channel containing the vertex tangents.
iState:State shader with a possible alpha mask.
iBumpEffect:Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].
iGlossy:true to enable glossiness, false otherwise.
iGlossyAngle:Angle of glossiness in [0.0f,RED_PI/2.0f].
iGlossySamples:Number of rays fired for the glossiness calculation.
iResMgr:The cluster's resource manager.

Returns:

RED_OK if the setup operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.