ReflectionShader
Functions
Detailed Description
-
class ReflectionShader : public RED::RenderShader
Built-in reflection display shader.
@related Using Built-in Render Shaders, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode
This shader can be used to display a reflection image. It uses two color / texture pairs of values that can modulate the reflection image that is blended in the post-lighting pass of the scene rendering: The intensity of the reflection is successively multiplied by the specular color at the lit pixel and then by the reflective color at the lit pixel.
I = reflect_color * specular_color * reflection
I.w = alpha_mask.w or 1.0
In hardware rendering, the shader produces an alpha value equal to 1.0 or to the alpha of the specified ‘iAlphaMask’ parameter of the constructor. In software rendering, the shader produces an alpha value equal to 1.0.
This shader is using a pass at its construction time. This pass indicates whether the setup is to be done for a direct post-lighting pass or for an indirect post-lighting pass.
An object using a material with this shader will show up:
Reflections when the direct post-lighting shader exists.
Reflections within reflections or refractions when the indirect post-lighting shader exists.
This shader creates two direct lighting configurations:
And three indirect lighting configurations:
See the REDReflectionShader.h file documentation for the list of all #define statements used to name all parameters of this shader.
Public Functions
-
SET_CID(CID_class_REDReflectionShader)
-
IMPLEMENT_AS()
-
ReflectionShader(RED::MATERIAL_PASS iPass, const RED::Color &iSpecularColor, const RED::Object *iSpecularTexture, const RED::Matrix &iSpecularMatrix, RED::MESH_CHANNEL iSpecularUV, const RED::Color &iReflectiveColor, const RED::Object *iReflectiveTexture, const RED::Matrix &iReflectiveMatrix, RED::MESH_CHANNEL iReflectiveUV, bool iUseReflImage, const RED::Object *iFresnel, const RED::StateShader &iAlphaMask, RED::Object *iResMgr, RED_RC &oErrorCode)
ReflectionShader construction method.
Applies the ray-traced reflection image on rendered objects. The reflection image color is multiplied by the specular color and by the reflective color at the lit pixel.
If iUseReflImage is set to false, then the reflection image is ignored. This case may be useful when the reflection image is already used through a composite image set in one of the two textures used for the reflection amount calculation.
iAlphaMask contains a possible alpha mask that we need to consider when it exists to generate reflection colors only on the correct alpha passed pixels.
iFresnel can be used to generate Fresnel based reflections for refractive objects. The Fresnel value modulates the amount of reflection and refraction emitted by the object.
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
iPass – Target pass, RED::MTL_POSTLIT or RED::MTL_INDIRECT_POSTLIT.
iSpecularColor – Specular color.
iSpecularTexture – Object specular texture. Overrides the color when set.
iSpecularMatrix – Texture matrix applied to the iSpecularTexture.
iSpecularUV – Mesh UV channel to use to the specular texture.
iReflectiveColor – Reflective color.
iReflectiveTexture – Reflective texture. Overrides the reflective color when set.
iReflectiveMatrix – Texture matrix applied to the iReflectiveTexture.
iReflectiveUV – Mesh UV channel to use for the reflective texture.
iUseReflImage – Set to true to use the reflection image in the shader color calculation. If set to false, the reflection image is not directly used, but it may be used throughout a composite image for instance.
iFresnel – Must be NULL or a valid composite image. The ‘.w’ value of the image is used as fresnel term that modulates the intensity of the reflection image being returned by this shader. RED::IImageComposite::Fresnel is a possible valid composite image for this shader.
iAlphaMask – State shader with possible alpha masking parameters.
iResMgr – The cluster’s resource manager.
oErrorCode – Indicates a construction failure when not returned set to RED_OK.
-
~ReflectionShader()
ReflectionShader destruction method.
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.