RenderShaderRefractionEffect

Functions

SET_CID

RenderShaderRefractionEffect

~RenderShaderRefractionEffect

RED_RC

LoadProgram

RED_RC

EvaluateFromInputParameters

Detailed Description

class RenderShaderRefractionEffect : public RED::RenderShader

Refraction effect shader. Implements approximated refractions.

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

This shader produces a ray-traced like refraction effect without using the REDsdk’s ray-tracer. Therefore, it’s perfectly suitable for real-time rendering purposes. The generated rendering is only an approximation of what ray-traced refraction would produce in far more time.

The shader should be used in pre-lighting within a regular transparency setup, except that blending must be disarmed.

Each texture can be associated to its own texture matrix and uv channel.

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_TEXn: (optional) texture coordinates of the rendered meshes.

  • RED::MCL_USERn: (optional) tangent space vectors of the meshes.

UVs must be specified if a 2D texture image is used and tangent space vectors must be supplied if the shader is using a normal map

This shader creates one platform configuration in real-time lighting:

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

Public Functions

SET_CID (CID_class_REDRenderShaderRefractionEffect) IMPLEMENT_AS()
RenderShaderRefractionEffect(RED::MATERIAL_PASS iRenderPass, float iRefractIndex, const RED::Object *iRefractTexture, const RED::Matrix &iRefractTextureMatrix, RED::MESH_CHANNEL iRefractUV, float iRefractRange, bool iFresnel, 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.

All textures used by this method may either be 2D images using the RED::TGT_TEX_2D target or composite images.

This shader implements several optimized programs. The best program is chosen according to the specified set of parameters. This has an effect on the shader declared parameters. You’ll find all parameters names and their description / targets in RenderShaderRefractionEffect.h

Parameters
  • iRenderPass – RED::MTL_PRELIT.

  • iRefractIndex – Refraction index. This value is ignored whenever iRefractTexture is not NULL.

  • iRefractTexture – Refraction texture or NULL to use the index instead. Must be a RED::TGT_TEX_2D RED::IImage2D texture or a RED::IImageComposite image.

  • iRefractTextureMatrix – Refraction texture transformation matrix.

  • iRefractUV – UV mesh channel number to use for the refraction texture mapping.

  • iRefractRange – Float value used to rescale the information contained in iRefractTexture. As iRefractTexture is a 2D target texture (or a composite whose sources are in [0,1]), its value are in the [0,1] range, and are multiplied by ‘iRefractRange’ after sampling.

  • iFresnel – Modulate the amount of refraction by a Fresnel term.

  • 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 ~RenderShaderRefractionEffect()

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