RenderShaderLambert
Functions
Detailed Description
-
class RenderShaderLambert : public RED::RenderShader
Shader class for the lambertian lighting equation.
@related Using Built-in Render Shaders, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode
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.
Public Functions
-
SET_CID(CID_class_REDRenderShaderLambert)
-
IMPLEMENT_AS()
-
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.
-
virtual ~RenderShaderLambert()
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.