class RED::RayRefractionShader

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

#include <REDRayRefractionShader.h>

Inherits: RenderShader.

Public functions:

RayRefractionShader ( const RED::RenderShaderAnisotropic & iAniso, const RED::StateShader & iAlphaMask, float iBumpEffect, float iRefractIndex, const RED::Object * iRefractTexture, const RED::Matrix & iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, float iGlossyAngle, int iGlossySamples, RED::Object * iResMgr, RED_RC & oErrorCode )
RayRefractionShader ( const RED::RenderShaderPhong & iPhong, const RED::StateShader & iAlphaMask, float iBumpEffect, float iRefractIndex, const RED::Object * iRefractTexture, const RED::Matrix & iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, RED::Object * iResMgr, RED_RC & oErrorCode )
RayRefractionShader ( const RED::RenderShaderAnisotropic & iAniso, const RED::StateShader & iAlphaMask, float iBumpEffect, float iRefractIndex, const RED::Object * iRefractTexture, const RED::Matrix & iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, RED::Object * iResMgr, RED_RC & oErrorCode )
RayRefractionShader ( )
RayRefractionShader ( const RED::RenderShaderPhong & iPhong, const RED::StateShader & iAlphaMask, float iBumpEffect, float iRefractIndex, const RED::Object * iRefractTexture, const RED::Matrix & iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, float iGlossyAngle, int iGlossySamples, RED::Object * iResMgr, RED_RC & oErrorCode )
~RayRefractionShader ( )
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, float iRefractIndex, const RED::Object * iRefractTexture, const RED::Matrix & iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, 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:

Refraction calculation shader for the ray-tracer.

The RED engine ray-tracer is able to calculate true refractions 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 refraction properties of the geometries rendered with the material, through this shader.

That shader calculates the world coordinate per pixel refraction vector to use for all refraction calculations.

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

Direct refractions parameters (when rays are issued from the camera) are added to the RED_SHAD_TARGET_REFRACTION_VECTOR shader target and indirect refraction parameters (ray bounces after the first one) are added to the RED_SHAD_TARGET_INDIRECT_REFRACTION_VECTOR shader target.

Therefore, a parameter provided to the shader construction method exists in two versions in the created shader: for direct and indirect refractions. Then, modifying a parameter's value may request the modification of the direct and indirect values of the parameter.

This shader has two runtime platform configurations: one is RED::HW_NVIDIA_GENERIC and the other is RED::HW_ATI_GENERIC. This shader has no generic configuration.

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

Functions documentation

public RED::RayRefractionShader::RayRefractionShader(const RED::RenderShaderAnisotropic &iAniso,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiRefractIndex,
const RED::Object *iRefractTexture,
const RED::Matrix &iRefractTextureMatrix,
RED::MESH_CHANNELiRefractUV,
floatiRefractRange,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for an anisotropic refraction.

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

All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images.

This method setups glossy refractions. A glossiness spread angle has to be defined for glossy refractions to be enabled. A 0.0f angle will result in non glossy perfect refractions.

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 Refraction vectors calculation. Values in [0.0f,1.0f].
iRefractIndex:Refraction index. This value is ignored whenever iRefractTexture is not NULL.
iRefractTexture:Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2DRED::IImage2D texture or a RED::IImageComposite image.
iRefractTextureMatrix:Refraction texture transformation matrix.
iRefractUV:UV mesh channel number to use for the refraction texture mapping.
iRefractRange:Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by iRefractRange after sampling. iRefractRange should be set so that the scaled IOR values are greater than 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::RayRefractionShader::RayRefractionShader(const RED::RenderShaderPhong &iPhong,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiRefractIndex,
const RED::Object *iRefractTexture,
const RED::Matrix &iRefractTextureMatrix,
RED::MESH_CHANNELiRefractUV,
floatiRefractRange,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for a phong refraction.

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

All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images.

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 Refraction vectors calculation. Values in [0.0f,1.0f].
iRefractIndex:Refraction index. This value is ignored whenever iRefractTexture is not NULL.
iRefractTexture:Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2DRED::IImage2D texture or a RED::IImageComposite image.
iRefractTextureMatrix:Refraction texture transformation matrix.
iRefractUV:UV mesh channel number to use for the refraction texture mapping.
iRefractRange:Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by iRefractRange after sampling. iRefractRange should be set so that the scaled IOR values are greater than 1.0f.
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.
public RED::RayRefractionShader::RayRefractionShader(const RED::RenderShaderAnisotropic &iAniso,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiRefractIndex,
const RED::Object *iRefractTexture,
const RED::Matrix &iRefractTextureMatrix,
RED::MESH_CHANNELiRefractUV,
floatiRefractRange,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for an anisotropic refraction.

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

All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images.

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 Refraction vectors calculation. Values in [0.0f,1.0f].
iRefractIndex:Refraction index. This value is ignored whenever iRefractTexture is not NULL.
iRefractTexture:Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2DRED::IImage2D texture or a RED::IImageComposite image.
iRefractTextureMatrix:Refraction texture transformation matrix.
iRefractUV:UV mesh channel number to use for the refraction texture mapping.
iRefractRange:Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by iRefractRange after sampling. iRefractRange should be set so that the scaled IOR values are greater than 1.0f.
iResMgr:The cluster's resource manager.
oErrorCode:Indicates a construction failure when not returned set to RED_OK.

RayRefractionShader construction method.

public RED::RayRefractionShader::RayRefractionShader(const RED::RenderShaderPhong &iPhong,
const RED::StateShader &iAlphaMask,
floatiBumpEffect,
floatiRefractIndex,
const RED::Object *iRefractTexture,
const RED::Matrix &iRefractTextureMatrix,
RED::MESH_CHANNELiRefractUV,
floatiRefractRange,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr,
RED_RC &oErrorCode
)

Construction method for a phong refraction.

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

All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images.

This method setups glossy refractions. A glossiness spread angle has to be defined for glossy refractions to be enabled. A 0.0f angle will result in non glossy perfect refractions.

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 Refraction vectors calculation. Values in [0.0f,1.0f].
iRefractIndex:Refraction index. This value is ignored whenever iRefractTexture is not NULL.
iRefractTexture:Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2DRED::IImage2D texture or a RED::IImageComposite image.
iRefractTextureMatrix:Refraction texture transformation matrix.
iRefractUV:UV mesh channel number to use for the refraction texture mapping.
iRefractRange:Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by iRefractRange after sampling. iRefractRange should be set so that the scaled IOR values are greater than 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.

RayRefractionShader 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::RayRefractionShader::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::RayRefractionShader::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::RayRefractionShader::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::RayRefractionShader::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::RayRefractionShader::Setup(const RED::Object *iNormalMap,
const RED::Matrix &iNormalMatrix,
RED::MESH_CHANNELiNormalUV,
RED::MESH_CHANNELiTangentChannel,
const RED::StateShader &iState,
floatiBumpEffect,
floatiRefractIndex,
const RED::Object *iRefractTexture,
const RED::Matrix &iRefractTextureMatrix,
RED::MESH_CHANNELiRefractUV,
floatiRefractRange,
booliGlossy,
floatiGlossyAngle,
intiGlossySamples,
RED::Object *iResMgr
)

Builds a ray refraction deviation shader.

Uses one normal map and one alpha mask: only these two textures have an influence on the refraction vector.

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 the possible alpha mask.
iBumpEffect:Intensity of the bump map that may be considered in the Refraction vectors calculation. Values in [0.0f,1.0f].
iRefractIndex:Refraction index. This value is ignored whenever iRefractTexture is not NULL.
iRefractTexture:Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2DRED::IImage2D texture or a RED::IImageComposite image.
iRefractTextureMatrix:Refraction texture transformation matrix.
iRefractUV:UV mesh channel number to use for the refraction texture mapping.
iRefractRange:Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by iRefractRange after sampling. iRefractRange should be set so that the scaled IOR values are greater than 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 (must implement the RED::IResourceManager interface).

Returns:

RED_OK when the setup succeeded,
Other internal codes on purpose.