RenderShaderAnisotropic

Functions

CID

GetClassID

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

void *

As

const void *

As

class T_As

As

class T_As

As

RenderShaderAnisotropic

~RenderShaderAnisotropic

Detailed Description

class RenderShaderAnisotropic : public RED::RenderShader

Anisotropic lighting shader. Implements a Ward based anisotropic lighting equation.

@related Using Built-in Render Shaders, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode

This shader produces an anisotropic lighting. Anisotropy is defined by two sets of data: an orientation parameter and an anisotropy parameter that’ll define the look of the specular highlights produced by this shader.

The shader is set to be used with the RED::MTL_LIT or with the RED::MTL_INDIRECT_LIT pass of the material.

Parameters used by the shader are:

  • A diffuse color / texture.

  • A specular color / texture.

  • A specular exponent/texture (this texture has value in [0.0f,1.0f] that are mapped onto the [0,iSpecExpRange] range of exponents),

  • A normal map.

  • An orientation value / texture (defines the orientation of the anisotropy). as for the exponent, the texture’s values are in [0.0f,1.0f] and mapped onto the [0,RED_PI] interval.

  • An anisotropy value / texture (defines the stretching of the specular highlight by specular_width = anisotropy * specular_height).

  • A transparency color / texture.

Each texture is associated to its own texture matrix and uv channel. Matrices are duplicated internally, whereas images are simply pointed to.

UVs must be specified if a texture is to be used by the shader. This shader supports RED::TGT_TEX_2D textures, that must be sampled with normalized UVs, composite textures, that are sampled at the shaded fragment position, or RED::TGT_TEX_RECT textures that are sampled using denormalized UVs.

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_<any>: Tangent space vectors of the meshes. Tangent space information is mandatory for correct lighting calculations within an anisotropic shader.

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

This shader creates two platform configurations in direct lighting:

It also creates two platform configurations in indirect lighting:

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
RenderShaderAnisotropic(RED::MATERIAL_PASS iTargetPass, const RED::Color &iDiffuseColor, const RED::Object *iDiffuseTexture, const RED::Matrix &iDiffuseMatrix, RED::MESH_CHANNEL iDiffuseUV, const RED::Color &iSpecularColor, const RED::Object *iSpecularTexture, const RED::Matrix &iSpecularMatrix, RED::MESH_CHANNEL iSpecularUV, float iSpecExp, const RED::Object *iSpecExpTexture, const RED::Matrix &iSpecExpMatrix, RED::MESH_CHANNEL iSpecExpUV, float iSpecExpRange, const RED::Object *iNormalMap, const RED::Matrix &iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, float iOrientation, const RED::Object *iOrientationTexture, const RED::Matrix &iOrientationMatrix, RED::MESH_CHANNEL iOrientationUV, float iAnisotropy, const RED::Object *iAnisotropyTexture, const RED::Matrix &iAnisotropyMatrix, RED::MESH_CHANNEL iAnisotropyUV, const RED::Color &iTransparColor, const RED::Object *iTransparTexture, const RED::Matrix &iTransparMatrix, RED::MESH_CHANNEL iTransparUV, RED::Object *iResourceManager, RED_RC &oRC)

Constructor.

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.

All specified UV channels must be in the RED::MCL_TEX0 - RED::MCL_TEX7 range, otherwise the method will return RED_BAD_PARAM.

Parameters
  • iTargetPass – RED::MTL_LIT for a direct lighting shader, or RED::MTL_INDIRECT_LIT for an indirect lighting shader.

  • iDiffuseColor – The shader’s diffuse color.

  • iDiffuseTexture – The shader’s diffuse texture. Overrides the diffuse color when set.

  • iDiffuseMatrix – Texture matrix applied to the diffuse texture if a valid texture image is provided.

  • iDiffuseUV – Diffuse texture UV mesh channel.

  • iSpecularColor – The shader’s specular color.

  • iSpecularTexture – The shader’s specular texture. Overrides the specular color when set.

  • iSpecularMatrix – Texture matrix applied to the specular texture.

  • iSpecularUV – Specular texture UV mesh channel.

  • iSpecExp – Specular exponent value (this value ignores the ‘iSpecExpRange’ parameter used to rescale the specular exponent of a texture).

  • iSpecExpTexture – Specular exponent texture. Overrides the ‘iSpecExp’ when set. Only the red component of the texture is being used.

  • iSpecExpMatrix – Specular exponent texture transformation matrix.

  • iSpecExpUV – Specular exponent UV mesh channel.

  • iSpecExpRange – Specular exponent maximal range value.

  • iNormalMap – Normal map image.

  • iNormalMatrix – Texture matrix applied to the normal map if a normal map is provided.

  • iNormalUV – Normal map UV mesh channel.

  • iTangentChannel – Mesh channel containing vertex tangents.

  • iOrientation – Orientation used to compute the anisotropy local basis.

  • iOrientationTexture – Orientation texture image overrides the orientation value when set. Only the red component of the texture is being used.

  • iOrientationMatrix – Transformation matrix for the orientation texture image.

  • iOrientationUV – Orientation texture UV mesh channel.

  • iAnisotropy – Anisotropy value in [0.0f,1.0f]. Defines the stretching ratio applied to the specular’s width.

  • iAnisotropyTexture – Anisotropy texture image overrides the anisotropy value when set. Only the red component of the texture is being used.

  • iAnisotropyMatrix – Transformation matrix for the anisotropy image.

  • iAnisotropyUV – Anisotropy UV mesh channel.

  • iTransparColor – The shader’s transparency color.

  • iTransparTextureShader transparency texture. Overrides the color when set.

  • iTransparMatrix – Transparency texture matrix.

  • iTransparUV – Transparency UV channel.

  • iResourceManager – The cluster’s resource manager.

  • oRC – Indicates a construction failure when not returned set to RED_OK.

virtual ~RenderShaderAnisotropic()

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.