RenderShaderLogo
Functions
Detailed Description
-
class RenderShaderLogo : public RED::RenderShader
Decal display shader.
@related Using Built-in Render Shaders, Applying a Logo Over a Material’s Geometry, class RED::IMaterial, class RED::RenderShader, class RED::StateShader, class RED::RenderCode
This simple shader displays a list of decal textures on a geometry. Each texture’s RGB color value is modulated by the texture’s own alpha mask value, interpolated with the result of blending all previous logos. Consequently, the shader’s lighting equation is:
// Example for 1 logo: output.rgb = logo0.rgb * logo0.a; output.a = logo0.a; // Example for 2 logos: output.rgb = ( logo0.rgb * logo0.a ) * ( 1 - logo1.a ) + logo1.rgb * logo1.a; output.a = saturate( logo0.a + logo1.a ); // Example for 3 logos: output.rgb = ( ( logo0.rgb * logo0.a ) * ( 1 - logo1.a ) + logo1.rgb * logo1.a ) * ( 1 - logo2.a ) + logo2.rgb * logo2.a...; output.a = saturate( logo0.a + logo1.a + logo2.a ); // Example for N logos: output.rgb = outputN-1.rgb * ( 1 - logoN.a ) + logoN.rgb * logoN.a; output.a = saturate( outputN-1.a + logoN.a );
Color and alpha saturation may apply based on the output rendering buffer’s format.
This shader uses the following geometrical channels:
RED::MCL_VERTEX: Vertex array of the rendered meshes.
RED::MCL_TEX0-7: Texture coordinates of the rendered meshes.
The RenderShaderLogo can be used in a direct or indirect lighting configuration. This is selected at the shader’s creation time. A direct shader goes to the RED::MTL_PRELIT pass of the material, whereas an indirect shader goes to its RED::MTL_INDIRECT_PRELIT pass.
This shader creates two platform configurations in direct lighting:
It also creates two platform configurations in indirect lighting:
See the REDRenderShaderLogo.h file documentation for the list of all #define statements used to name all parameters of this shader.
Public Functions
-
SET_CID(CID_class_REDRenderShaderLogo)
-
IMPLEMENT_AS()
-
RenderShaderLogo(RED::MATERIAL_PASS iRenderPass, const RED::Vector<RED::Object*> &iLogoImage, const RED::Vector<RED::Matrix> &iLogoUVMatrix, const RED::Vector<RED::MESH_CHANNEL> &iLogoUV, RED::Object *iResMgr, RED_RC &oErrorCode)
Constructor.
All textures used by this method can either be 2D images using the RED::TGT_TEX_2D target or composite images. The iLogoUVMatrix and iLogoUV parameters are ignored for a composite image.
The maximal number of logos images that can be managed by the shader is 7.
- Parameters
iRenderPass – RED::MTL_PRELIT or RED::MTL_INDIRECT_PRELIT.
iLogoImage – List of logo images.
iLogoUVMatrix – List of logo UV transformation matrices.
iLogoUV – List of UV channels to use for each logo.
iResMgr – The cluster’s resource manager.
oErrorCode – Indicates a construction failure when not returned set to RED_OK.
-
virtual ~RenderShaderLogo()
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
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.