RayReflectionShader

Functions

SET_CID

IMPLEMENT_AS

RayReflectionShader

~RayReflectionShader

RayReflectionShader

RayReflectionShader

RayReflectionShader

RayReflectionShader

RED_RC

Setup

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

Detailed Description

class RayReflectionShader : public RED::RenderShader

Reflection calculation shader for the ray-tracer.

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

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

That shader calculates the world coordinate per pixel reflection vector to use for all reflection calculations. It can also be used for the calculations of glossy reflections using the appropriate constructors.

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

This shader has 4 runtime platform configurations:

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

Public Functions

SET_CID(CID_class_REDRayReflectionShader)
IMPLEMENT_AS()
RayReflectionShader()

RayReflectionShader construction method.

~RayReflectionShader()

RayReflectionShader destruction method:

RayReflectionShader(const RED::RenderShaderPhong &iPhong, const RED::StateShader &iAlphaMask, float iBumpEffect, RED::Object *iResMgr, RED_RC &oErrorCode)

Construction method for a phong reflection.

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

Parameters
  • iPhong – Source phong shader.

  • iAlphaMaskState shader with possible alpha masking parameters.

  • iBumpEffect – Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].

  • iResMgr – The cluster’s resource manager.

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

RayReflectionShader(const RED::RenderShaderAnisotropic &iAniso, const RED::StateShader &iAlphaMask, float iBumpEffect, RED::Object *iResMgr, RED_RC &oErrorCode)

Construction method for an anisotropic reflection.

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

Parameters
  • iAniso – Source anisotropic shader.

  • iAlphaMaskState shader with possible alpha masking parameters.

  • iBumpEffect – Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,1.0f].

  • iResMgr – The cluster’s resource manager.

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

RayReflectionShader(const RED::RenderShaderPhong &iPhong, const RED::StateShader &iAlphaMask, float iBumpEffect, float iGlossyAngle, int iGlossySamples, RED::Object *iResMgr, RED_RC &oErrorCode)

Construction method for a glossy phong reflection.

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

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

Parameters
  • iPhong – Source phong shader.

  • iAlphaMaskState shader with possible alpha masking parameters.

  • iBumpEffect – Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,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.

RayReflectionShader(const RED::RenderShaderAnisotropic &iAniso, const RED::StateShader &iAlphaMask, float iBumpEffect, float iGlossyAngle, int iGlossySamples, RED::Object *iResMgr, RED_RC &oErrorCode)

Construction method for a glossy anisotropic reflection.

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

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

Parameters
  • iAniso – Source anisotropic shader.

  • iAlphaMaskState shader with possible alpha masking parameters.

  • iBumpEffect – Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,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.

RED_RC Setup(const RED::Object *iNormalMap, const RED::Matrix &iNormalMatrix, RED::MESH_CHANNEL iNormalUV, RED::MESH_CHANNEL iTangentChannel, const RED::StateShader &iState, float iBumpEffect, bool iGlossy, float iGlossyAngle, int iGlossySamples, RED::Object *iResMgr)

Builds a ray reflection deviation shader.

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.

  • iStateState shader with a possible alpha mask.

  • iBumpEffect – Intensity of the bump map that may be considered in the reflection vectors calculation. Values in [0.0f,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.

Returns

RED_OK if the setup operation has succeeded,

RED_BAD_PARAM if the method has received an invalid parameter,

RED_ALLOC_FAILURE if an internal allocation has failed,

RED_FAIL otherwise.

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
  • 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.