RenderShaderLambert

Functions

CID

GetClassID

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

void *

As

const void *

As

class T_As

As

class T_As

As

RenderShaderLambert

~RenderShaderLambert

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:

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

virtual void *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.

virtual const void *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.

template<class T_As>
inline T_As *As()
template<class T_As>
inline const T_As *As() const
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 inline RED::CID GetClassID()
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
  • ioShaderShader 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.