class RED::RenderShaderLambert
Shader class for the lambertian lighting equation. More...
#include <REDRenderShaderLambert.h>
Inherits: RenderShader.
Public functions:
RenderShaderLambert ( RED::MATERIAL_PASS iRenderPass, const RED::Color & iDiffuseColor, const RED::Object * iDiffuseTexture, const RED::Matrix & iDiffuseMatrix, RED::MESH_CHANNEL iDiffuseUV, const RED::Color & iTransparColor, const RED::Object * iTransparTexture, const RED::Matrix & iTransparMatrix, RED::MESH_CHANNEL iTransparUV, const RED::Object * iNormalMap, const RED::Matrix & iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, RED::Object * iResMgr, RED_RC & oErrorCode ) | |
virtual | ~RenderShaderLambert ( ) |
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_RC | EvaluateFromInputParameters ( RED::RenderShader * ioShader, RED::Object * iResMgr ) |
static RED::CID | GetClassID ( ) |
static RED_RC | LoadProgram ( RED::String & oString, const RED::ShaderProgramID & iID ) |
Detailed description:
Shader class for the lambertian lighting equation.
This shader reproduces the "Lambert" lighting equation. It calculates the amount of diffuse lighting received by the object.
The result is bound to the RED::MTL_LIT or to the RED::MTL_INDIRECT_LIT pass of the material.
Parameters that are considered in the calculation are:
- A diffuse object color / texture,
- A transparency color / texture,
- A normal map,
- The current light parameters.
This shader uses the following geometrical channels:
- RED::MCL_VERTEX: vertex array of the rendered meshes.
- RED::MCL_NORMAL: normal array of the rendered meshes.
- RED::MCL_TEX0 - n: (optional) texture coordinates of the rendered meshes.
- RED::MCL_USER0 - n: (optional) tangent space vectors of the rendered meshes.
UVs must be specified if a texture image is used, and tangent space vectors must be supplied if the shader is using a normal map.
This shader creates two platform configurations in direct lighting:
It also creates three platform configurations in indirect lighting:
See the REDRenderShaderLambert.h file documentation for the list of all define statements used to name all parameters of this shader.
Functions documentation
public RED::RenderShaderLambert::RenderShaderLambert | ( | RED::MATERIAL_PASS | iRenderPass, |
const RED::Color & | iDiffuseColor, | ||
const RED::Object * | iDiffuseTexture, | ||
const RED::Matrix & | iDiffuseMatrix, | ||
RED::MESH_CHANNEL | iDiffuseUV, | ||
const RED::Color & | iTransparColor, | ||
const RED::Object * | iTransparTexture, | ||
const RED::Matrix & | iTransparMatrix, | ||
RED::MESH_CHANNEL | iTransparUV, | ||
const RED::Object * | iNormalMap, | ||
const RED::Matrix & | iNormalMatrix, | ||
RED::MESH_CHANNEL | iNormalUV, | ||
RED::MESH_CHANNEL | iTangentChannel, | ||
RED::Object * | iResMgr, | ||
RED_RC & | oErrorCode | ||
) |
Constructor.
The Lambertian lighting equation is using a regular diffuse color / texture term that is modulated by a transparency color / texture term. A bump mapping may be applied to the surface normal.
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:
iRenderPass: | RED::MTL_LIT or RED::MTL_INDIRECT_LIT. |
iDiffuseColor: | Diffuse object color. |
iDiffuseTexture: | Diffuse object texture. Overrides the diffuse color when set. |
iDiffuseMatrix: | Diffuse object texture transformation matrix. |
iDiffuseUV: | Diffuse texture UV mesh channel. |
iTransparColor: | Transparency color. |
iTransparTexture: | Transparency texture. Overrides the transparency color when set. |
iTransparMatrix: | Transparency texture transformation matrix. |
iTransparUV: | Transparency texture UV mesh channel. |
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. |
iResMgr: | The cluster's resource manager. |
oErrorCode: | Indicates a construction failure when not returned set to RED_OK. |
public virtual RED::RenderShaderLambert::~RenderShaderLambert | ( | ) |
Destructor.
public static RED_RC RED::RenderShaderLambert::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_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.
public static RED::CID RED::RenderShaderLambert::GetClassID | ( | ) |
Reimplements: RED::RenderShader::GetClassID.
public static RED_RC RED::RenderShaderLambert::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_ALLOC_FAILURE if an allocation has failed,
RED_FAIL otherwise.
public virtual void * RED::RenderShaderLambert::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::RenderShader::As.
public virtual const void * RED::RenderShaderLambert::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::RenderShader::As.
template< class T_As > public const T_As * RED::RenderShaderLambert::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::RenderShader::As.
template< class T_As > public T_As * RED::RenderShaderLambert::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::RenderShader::As.