class RED::RenderShader
Programmable graphics hardware shader class. More...
#include <REDRenderShader.h>
Inherits: Shader.
Inherited by: RayCutoffShader, RayGIDiffuseShader, RayGIReflectionColorShader, RayGIRefractionColorShader, RayReflectionShader, RayRefractionShader, ReflectionShader, RenderShaderAAFilter, RenderShaderAmbient, RenderShaderAnisotropic, RenderShaderEdges, RenderShaderEnvironmental, RenderShaderLambert, RenderShaderLogo, RenderShaderPhong, RenderShaderRefractionEffect, RenderShaderSectionCut, RenderShaderSolid, RenderShaderText, RenderShaderVertexColor and RenderShaderViewport.
Public functions:
Public static functions:
static int | CompositeTextureSelection ( int iNbInputs, const RED::Object * iTexture[16] ) |
static RED_RC | FakeColorWithImage ( RED::Object *& oImage, const RED::Color & iColor, RED::Object * iResourceManager ) |
static RED::CID | GetClassID ( ) |
static RED::MESH_CHANNEL | SelectSingleUV ( int iNbInputs, RED::MESH_CHANNEL iUV[16], const RED::Object * iTexture[16] ) |
static int | VertexProgramSelection ( int iNbInputs, RED::MESH_CHANNEL iUV[7], const RED::Object * iTexture[7], const RED::Matrix * iTransform[7] ) |
Protected functions:
const RED::RenderShaderData * | FindPlatformData ( int iShaderTarget, RED::HARDWARE_PLATFORM iPlatformId ) const |
RED_RC | GetPlatformData ( RED::RenderShaderData *& oData, int iShaderTarget, RED::HARDWARE_PLATFORM iPlatformId ) |
RED::Vector< RED::RenderShaderData > * | PlatformLookup ( RED::HARDWARE_PLATFORM iPlatformID, bool iExactMatch ) const |
Protected variables:
RED::Vector< RED::Vector< RED::RenderShaderData > > | _pdata |
Detailed description:
Programmable graphics hardware shader class.
This class defines the way geometries are rendered by REDsdk. There are two different types of rendering shaders in REDsdk: those that are built-in (example: The RED::RenderShaderLambert) and those that are defined by the application.
Built-in shaders are RED::RenderShader children classes and are using a list of input parameters which is set at their construction time. A built-in shader can then be accessed by retrieving an input parameter value thanks to one of the RED::RenderShader::GetInputParameter method. Modification of a built-in rendering shader occurs using two calls: 1. Calling one of the RED::RenderShader::SetInputParameter methods to do the changes for the specified parameter of the shader. 2. Calling RED::RenderShader::EvaluateFromInputParameters if the 'iEvaluate' flag of the set methods were turned off.
The call to the re-evaluation method of the shader is mandatory for any change to be taken into consideration. Please note that legacy REDsdk 3.x shaders are not built-in. They don't have any input parameter declared and must be considered as user made rendering shaders, using the define parameters names defined in REDsdk 3.x releases. REDsdk 4.0 and above built-in shaders do declare input parameters and can be used using the method described above.
Rendering shaders that are defined by the application must be configured following the steps below to be usable: 1. Declare geometrical inputs to the vertex shader stage. This is called the RED::RenderCode. This operation is done using RED::RenderShader::SetRenderCode. 2. Declare the flow of the data inside the shader. This is the step where shader programs are declared and configured. At least a vertex program and a pixel program must be setup. See the RED::RenderShader::SetVertexProgramId and RED::RenderShader::SetPixelProgramId calls for that. Optional shaders, such as geometry shaders can be declared as well. All programs are loaded by the resource manager using RED::IResourceManager::LoadShaderFromString. 3. Declare parameters inputs that will be used for each shader. 4. Register the created shader in a material using RED::IMaterial::RegisterShader. 5. Assign the created shader into a rendering pass. 6. Assign the material to a shape.
Every parameter set in a RED::RenderShader can target a specific rendering configuration. All parameters API call support a "shader target" flag value that can be used to indicate the scope of the parameter. Values for this target flag can be a bitwise OR of the following terms:
Target name | Shortcut | Description |
---|---|---|
RED_SHAD_TARGET_LIGHT_NO_LIGHT | RED_L0 | A parameter using this target is read only in pre-lighting or post-lighting rendering passes. |
RED_SHAD_TARGET_LIGHT_DIRECTIONAL | RED_LD | The shader parameter is used for all directional lights in lighting passes. |
RED_SHAD_TARGET_LIGHT_BEAM | RED_LB | The shader parameter is used for all beam lights in lighting passes. |
RED_SHAD_TARGET_LIGHT_POINT | RED_LP | The shader parameter is used for all point light sources in lighting passes. |
RED_SHAD_TARGET_LIGHT_AREA | RED_LA | The shader parameter is used for all area light sources in lighting passes. |
RED_SHAD_TARGET_LIGHT_POINT_SPOT | RED_LS | The shader parameter is used for all point light sources that are casting a umbra spot in lighting passes. |
RED_SHAD_TARGET_LIGHT_AREA_SPOT | RED_LE | The shader parameter is used for all area light sources that are casting a umbra spot in lighting passes. |
RED_SHAD_TARGET_LIGHT_SKY_LIGHT | RED_LK | The shader parameter is used for the skylight source in lighting passes. |
RED_SHAD_TARGET_REFLECTION_VECTOR | N/A | The shader parameter is used for the configuration of direct ray-traced reflections in the ray-tracing pass. |
RED_SHAD_TARGET_INDIRECT_REFLECTION_VECTOR | N/A | The shader parameter is used for the configuration of indirect ray-traced reflections in the ray-tracing pass. |
RED_SHAD_TARGET_REFRACTION_VECTOR | N/A | The shader parameter is used for the configuration of direct ray-traced refractions in the ray-tracing pass. |
RED_SHAD_TARGET_INDIRECT_REFRACTION_VECTOR | N/A | The shader parameter is used for the configuration of indirect ray-traced refractions in the ray-tracing pass. |
RED_SHAD_TARGET_REFLECTION_CUTOFF | N/A | The shader parameter is used for the configuration of direct ray-traced reflection rays cutoff values in the ray-tracing pass. |
RED_SHAD_TARGET_INDIRECT_REFLECTION_CUTOFF | N/A | The shader parameter is used for the configuration of indirect ray-traced reflection rays cutoff values in the ray-tracing pass. |
RED_SHAD_TARGET_REFRACTION_CUTOFF | N/A | The shader parameter is used for the configuration of direct ray-traced refraction rays cutoff values in the ray-tracing pass. |
RED_SHAD_TARGET_INDIRECT_REFRACTION_CUTOFF | N/A | The shader parameter is used for the configuration of indirect ray-traced refraction rays cutoff values in the ray-tracing pass. |
RED_SHAD_TARGET_GI_DIFFUSE_COLOR | N/A | The shader parameter is used for the configuration of the global illumination diffuse color in the ray-tracing pass. |
RED_SHAD_TARGET_GI_NORMAL | N/A | The shader parameter is used for the configuration of the global illumination geometry normal in the ray-tracing pass. |
RED_SHAD_TARGET_GI_REFLECTION_COLOR | N/A | The shader parameter is used for the configuration of the global illumination reflection color in the ray-tracing pass. |
RED_SHAD_TARGET_GI_TRANSMISSION_COLOR | N/A | The shader parameter is used for the configuration of the global illumination transmission color in the ray-tracing pass. |
Note:
Please note that shader targets are ignored while configuring a render shader for the RED::HW_SOFT_TRACER hardware platform. Shader targets are only used for the setup of hardware rendering using a GPU.
Physical lights have no associated shader target type. Physical lights are rendered on the CPU and equivalent lights are rendered on the GPU for each kind of physical light in REDsdk. Refer to the Light shapes chapter for all details on lights and how they are being rendered.
The rendering pipeline will consider all parameters whose target scope is matching the type of the configuration we are currently rendering. This way, it's possible to use a given shader for directional lights, another one for spots, or whatever combination is appropriate. Usually, different shaders are used for each kind of light, as they require different parameters to be loaded, but it's possible to share or to dedicate programs to a given rendering need.
In a similar manner, the render shader contents are set to support different versions of the same shader programs for different graphics hardware. This with the objective to be able to support, with a single scene description, various graphical hardware that don't have the same rendering capabilities. As a result, the same file can be loaded on different computers, and render differently, according to the choices made for each hardware platform.
All RenderShader setup methods are using a 'iPlatformId' identifier. This identifier must be set to a valid runtime platform amongst those that are defined by the RED::HARDWARE_PLATFORM enumeration.
Functions documentation
public RED::RenderShader::RenderShader | ( | ) |
RenderShader construction method.
public virtual RED::RenderShader::~RenderShader | ( | ) |
RenderShader destruction method.
public static int RED::RenderShader::CompositeTextureSelection | ( | int | iNbInputs, |
const RED::Object * | iTexture[16] | ||
) |
Chooses the texture access command.
This method returns a composite flag for the RED::ShaderProgramID, based on the types of the textures specified in 'iTexture'.
Parameters:
iNbInputs: | Number of inputs, in [ 1, 16 ]. |
iTexture: | Texture list for each texturing input. |
Returns:
public static RED_RC RED::RenderShader::FakeColorWithImage | ( | RED::Object *& | oImage, |
const RED::Color & | iColor, | ||
RED::Object * | iResourceManager | ||
) |
Generates a tiny texture for pixel shaders.
Generates a 1x1 pixel image, set to repeat wrapping mode. Its life cycle is maintained by the resource manager, and is used by all REDsdk built-in shaders to reduce the number of different programs in a shader that are needed to cover all combinations of parameters that may or may not use a texture.
A texture created through this method should neither be modified nor destroyed. Two creation requests using the same color will return the same texture.
Note that every texture created through this method has the same ID: "REDFakeImage".
Parameters:
oImage: | Resulting image. |
iColor: | Color to put in the texture. |
iResourceManager: | The resource manager. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if a memory allocation has failed,
RED_FAIL otherwise.
public static RED::CID RED::RenderShader::GetClassID | ( | ) |
Reimplements: RED::Shader::GetClassID.
Reimplemented by: RED::RayCutoffShader::GetClassID, RED::RayGIDiffuseShader::GetClassID, RED::RayGIReflectionColorShader::GetClassID, RED::RayGIRefractionColorShader::GetClassID, RED::RayReflectionShader::GetClassID, RED::RayRefractionShader::GetClassID, RED::ReflectionShader::GetClassID, RED::RenderShaderAAFilter::GetClassID, RED::RenderShaderAmbient::GetClassID, RED::RenderShaderAnisotropic::GetClassID, RED::RenderShaderEdges::GetClassID, RED::RenderShaderEnvironmental::GetClassID, RED::RenderShaderLambert::GetClassID, RED::RenderShaderLogo::GetClassID, RED::RenderShaderPhong::GetClassID, RED::RenderShaderRefractionEffect::GetClassID, RED::RenderShaderSectionCut::GetClassID, RED::RenderShaderSolid::GetClassID, RED::RenderShaderText::GetClassID, RED::RenderShaderVertexColor::GetClassID and RED::RenderShaderViewport::GetClassID.
public static RED::MESH_CHANNEL RED::RenderShader::SelectSingleUV | ( | int | iNbInputs, |
RED::MESH_CHANNEL | iUV[16], | ||
const RED::Object * | iTexture[16] | ||
) |
Gets the right UV when we have only one valid texture.
Parameters:
iNbInputs: | Number of inputs. |
iUV: | UV Channel for the each texturing input. |
iTexture: | Texture map connected on each texturing input. |
Returns:
public static int RED::RenderShader::VertexProgramSelection | ( | int | iNbInputs, |
RED::MESH_CHANNEL | iUV[7], | ||
const RED::Object * | iTexture[7], | ||
const RED::Matrix * | iTransform[7] | ||
) |
Selects the vertex program matching some inputs.
Selects the vertex program to use based on UV, texturing and matrix transformations inputs.
Parameters:
iNbInputs: | Number of inputs, in [ 1, 7 ]. |
iUV: | UV Channel for the each texturing input. |
iTexture: | Texture map connected on each texturing input. |
iTransform: | Texture transformation matrix on each tex input. |
Returns:
public virtual RED_RC RED::RenderShader::AddParameter | ( | const RED::RenderShaderParameter & | iParam, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Setups a program parameter for the rendering.
Adds the provided parameter for the program kind and value it specifies for the rendering, for the iShaderTarget configuration.
Note that a parameter may be added twice for different bitwise combinations of shader targets. There's no restriction here. If the two shader targets for which the parameter is added have no common bit, the operation is correct. However, if the two shader targets have a target bit in common, there may be a mistake during the rendering, as the two versions of the parameter will be bound for the common rendering target. If their value differs, this may lead to incorrect shader bindings.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
iParam: | Parameter value. |
iShaderTarget: | Bitwise combination of the shader targets used. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public virtual const void * RED::RenderShader::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Shader::As.
Reimplemented by: RED::RayCutoffShader::As, RED::RayGIDiffuseShader::As, RED::RayGIReflectionColorShader::As, RED::RayGIRefractionColorShader::As, RED::RayReflectionShader::As, RED::RayRefractionShader::As, RED::ReflectionShader::As, RED::RenderShaderAAFilter::As, RED::RenderShaderAmbient::As, RED::RenderShaderAnisotropic::As, RED::RenderShaderEdges::As, RED::RenderShaderEnvironmental::As, RED::RenderShaderLambert::As, RED::RenderShaderLogo::As, RED::RenderShaderPhong::As, RED::RenderShaderRefractionEffect::As, RED::RenderShaderSectionCut::As, RED::RenderShaderSolid::As, RED::RenderShaderText::As, RED::RenderShaderVertexColor::As and RED::RenderShaderViewport::As.
template< class T_As > public const T_As * RED::RenderShader::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Shader::As.
Reimplemented by: RED::RayCutoffShader::As, RED::RayGIDiffuseShader::As, RED::RayGIReflectionColorShader::As, RED::RayGIRefractionColorShader::As, RED::RayReflectionShader::As, RED::RayRefractionShader::As, RED::ReflectionShader::As, RED::RenderShaderAAFilter::As, RED::RenderShaderAmbient::As, RED::RenderShaderAnisotropic::As, RED::RenderShaderEdges::As, RED::RenderShaderEnvironmental::As, RED::RenderShaderLambert::As, RED::RenderShaderLogo::As, RED::RenderShaderPhong::As, RED::RenderShaderRefractionEffect::As, RED::RenderShaderSectionCut::As, RED::RenderShaderSolid::As, RED::RenderShaderText::As, RED::RenderShaderVertexColor::As and RED::RenderShaderViewport::As.
public virtual void * RED::RenderShader::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Shader::As.
Reimplemented by: RED::RayCutoffShader::As, RED::RayGIDiffuseShader::As, RED::RayGIReflectionColorShader::As, RED::RayGIRefractionColorShader::As, RED::RayReflectionShader::As, RED::RayRefractionShader::As, RED::ReflectionShader::As, RED::RenderShaderAAFilter::As, RED::RenderShaderAmbient::As, RED::RenderShaderAnisotropic::As, RED::RenderShaderEdges::As, RED::RenderShaderEnvironmental::As, RED::RenderShaderLambert::As, RED::RenderShaderLogo::As, RED::RenderShaderPhong::As, RED::RenderShaderRefractionEffect::As, RED::RenderShaderSectionCut::As, RED::RenderShaderSolid::As, RED::RenderShaderText::As, RED::RenderShaderVertexColor::As and RED::RenderShaderViewport::As.
template< class T_As > public T_As * RED::RenderShader::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Shader::As.
Reimplemented by: RED::RayCutoffShader::As, RED::RayGIDiffuseShader::As, RED::RayGIReflectionColorShader::As, RED::RayGIRefractionColorShader::As, RED::RayReflectionShader::As, RED::RayRefractionShader::As, RED::ReflectionShader::As, RED::RenderShaderAAFilter::As, RED::RenderShaderAmbient::As, RED::RenderShaderAnisotropic::As, RED::RenderShaderEdges::As, RED::RenderShaderEnvironmental::As, RED::RenderShaderLambert::As, RED::RenderShaderLogo::As, RED::RenderShaderPhong::As, RED::RenderShaderRefractionEffect::As, RED::RenderShaderSectionCut::As, RED::RenderShaderSolid::As, RED::RenderShaderText::As, RED::RenderShaderVertexColor::As and RED::RenderShaderViewport::As.
public RED_RC RED::RenderShader::BindLight | ( | int | iChannel, |
bool | iSpecular, | ||
bool | iBump, | ||
bool | iDirect, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Generates the light binding used by all RED internal shaders.
All these bindings have precise positions detailed in REDBuiltInShaders.h
Parameters:
iChannel: | Current pixel shader texture channel position. |
iSpecular: | Do we need the specular color ? |
iBump: | Do we bind bump parameter set ? |
iDirect: | Are we in a direct lighting configuration ? |
iPlatformId: | Currently bound platform. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::BindRayVsTriangle | ( | int | iTarget, |
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Generates the binding for a ray vs triangle intersection.
This call binds all textures and shader parameters used to properly compute a ray vs triangle intersection during an indirect lighting pass. Designed for internal REDsdk usage.
Parameters:
iTarget: | Shader target for the binding. |
iPlatformId: | Currently bound platform. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public virtual RED::Shader * RED::RenderShader::Clone | ( | ) const |
public RED_RC RED::RenderShader::EvaluateFromInputParameters | ( | RED::Object * | iResMgr | ) |
Re evaluates the shader contents.
The shader is entirely cleared and re-created on calling this method. The contents of the shader are redefined from the list of input parameters that are stored in the class. This method only works for REDsdk built-in shaders. It'll return RED_WORKFLOW_ERRORS for user shaders.
Parameters:
iResMgr: | The cluster's resource manager. |
Returns:
RED_BAD_PARAM if a bad parameter was found during the re-evaluation,
RED_ALLOC_FAILURE if a memory allocation has failed,
Other RED_RCs from shader evaluation methods can be returned too.
public RED_RC RED::RenderShader::GetGeometryProgramId | ( | RED::ShaderProgramID & | oProgram, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Returns the identifier of a shader's vertex program.
This method searches the shader contents for a geometry program whose shader target exactly matches iShaderTarget.
Parameters:
oProgram: | The identifier of the geometry program, -1 if none could be found exactly matching iShaderTarget. |
iShaderTarget: | The exact shading target for the search. |
iPlatformId: | Platform identifier. |
Returns:
public RED_RC RED::RenderShader::GetGeometryProgramId | ( | RED::Vector< RED::ShaderProgramID > & | oProgramList, |
RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList, | ||
RED::Vector< int > & | oTargetList | ||
) | const |
Geometry shader lookup method.
This method returns all geometry shader programs that can be found in the shader, for all the shading targets they were declared for and for all shader's hardware platforms.
Parameters:
oProgramList: | List of program identifiers. |
oPlatformList: | List of platforms for each value in oProgramList. |
oTargetList: | List of targets for each value in 'oProgramList'. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::MESH_CHANNEL & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::MATERIAL_PASS & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::Color & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::Vector4 & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::Object *& | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | RED::Matrix & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | double & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::GetInputParameter | ( | bool & | oParameter, |
const RED::String & | iName | ||
) | const |
Retrieve an input parameter value by its name from the list.
Parameters:
oParameter: | The retrieved parameter value. |
iName: | The name of the accessed parameter. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public int RED::RenderShader::GetInputParametersCount | ( | ) const |
Get the number of input parameters.
Returns:
public virtual RED_RC RED::RenderShader::GetOperationStream | ( | const RED::Object * | iCaller, |
RED::Vector< int > & | ioStream, | ||
RED::HARDWARE_PLATFORM | iPlatformId | ||
) | const |
Accesses the operation stream of a shader.
Internal RED usage method. Writes down the shader stream.
Parameters:
iCaller: | Pointer to the method caller. |
ioStream: | Stream to write to. |
iPlatformId: | Target hardware platform identifier. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
Reimplements: RED::Shader::GetOperationStream.
public virtual RED_RC RED::RenderShader::GetParameter | ( | RED::RenderShaderParameter *& | oParam, |
const RED::String & | iName, | ||
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Accesses a shader parameter.
This method looks for the parameter in the shader whose name is iName, exactly matching the iShaderTarget shading target, for the iPlatformId platform. When valid, the returned parameter can be modified.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
oParam: | The parameter address if we could find it, NULL otherwise. |
iName: | String name of the parameter to look for. |
iShaderTarget: | Bitwise combination of the shader targets used. |
iPlatformId: | Identifier of the targeted platform. |
Returns:
public RED_RC RED::RenderShader::GetParameter | ( | RED::Vector< RED::RenderShaderParameter * > & | oParamList, |
RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList, | ||
RED::Vector< int > & | oTargetList, | ||
const RED::String & | iName | ||
) | const |
Get a single parameter by its name.
The method searches all parameters named iName, for all shading targets and for all hardware platforms defined in the shader.
The method fills oParamList, oPlatformList and oTargetList with the found parametric data. Returned parameters can be modified.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
oParamList: | List of parameters using iName. |
oPlatformList: | List of platforms for each value in oParamList. |
oTargetList: | List of targets for each value in oParamList. |
iName: | String name of the parameter to look for. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetParameter | ( | RED::Vector< RED::RenderShaderParameter * > & | oParamList, |
const RED::String & | iName | ||
) | const |
Gets a single parameter by its name.
This method returns all instance of parameters named iName. This method is similar to RED::RenderShader::GetParameter using lists of platforms and targets, except that we don't return these extra information lists. Returned parameters can be modified.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
oParamList: | List of parameters using iName. |
iName: | String name of the parameter to look for. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetParameters | ( | RED::Vector< RED::RenderShaderParameter * > & | ioParamList, |
RED::RenderShaderParameter::TYPE | iType, | ||
int | iShaderTargets = RED_SHAD_TARGET_ALL, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Builds a list of parameters of a given type.
This helper parses the specified shader targets that is bitwise matching iShaderTargets, for the specified iPlatformId, for all parameters of a given type, and return a vector filled with the result.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
ioParamList: | Returned list of parameters. |
iType: | The type of parameter being searched for. |
iShaderTargets: | Bitwise combination of the searched targets. |
iPlatformId: | Platform identifier. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetParameters | ( | RED::Vector< RED::RenderShaderParameter * > & | ioParamList, |
int | iShaderTargets = RED_SHAD_TARGET_ALL, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Builds a list of parameters.
This helper parses the specified shader targets for all parameters and return a vector filled with the result. Any parameter found in a shader target that is bitwise matching iShaderTargets will be returned for the specified iPlatformId.
Shader parameter documentation can be found here: Shader parameters.
Parameters:
ioParamList: | Returned list of parameters. |
iShaderTargets: | Bitwise combination of the searched targets. |
iPlatformId: | Platform identifier. |
Returns:
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetPixelProgramId | ( | RED::ShaderProgramID & | oProgram, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Returns the identifier of a shader's pixel program.
This method searches the shader contents for a pixel program whose shader target matches iShaderTarget.
Parameters:
oProgram: | The identifier of the vertex program, -1 if none could be found exactly matching iShaderTarget. |
iShaderTarget: | The shading target for the search. |
iPlatformId: | Platform identifier. |
Returns:
public RED_RC RED::RenderShader::GetPixelProgramId | ( | RED::Vector< RED::ShaderProgramID > & | oProgramList, |
RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList, | ||
RED::Vector< int > & | oTargetList | ||
) | const |
Pixel shader lookup method.
This method returns all pixel shader programs that can be found in the shader, for all the shading targets they were declared for and for all shader's hardware platforms.
Parameters:
oProgramList: | List of program identifiers. |
oPlatformList: | List of platforms for each value in oProgramList. |
oTargetList: | List of targets for each value in oProgramList. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetPlatformList | ( | RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList | ) const |
Gets the list of hardware and software platforms used by the shader.
This method fills a RED::Vector with the list of hardware and software platforms that are used by the shader.
Please find shader platform book here: Defining shader programs by hardware platform
Parameters:
oPlatformList: | The list of platforms. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetPlatformsCount | ( | int & | oCount | ) const |
public RED_RC RED::RenderShader::GetRenderCode | ( | RED::RenderCode ** | oRenderCode, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Returns a rendercode of the shader.
This method returns the RED::RenderCode used by the shader for the exact iShaderTarget configuration. The returned render code can be modified. Note that the returned address may become invalid if the shader is edited while the address is used.
Parameters:
oRenderCode: | The address of the rendercode in case of success, NULL if no rendercode could be found exactly matching iShaderTarget. |
iShaderTarget: | The shading target for the search. |
iPlatformId: | Platform identifier. |
Returns:
public RED_RC RED::RenderShader::GetRenderCode | ( | RED::Vector< RED::RenderCode * > & | oCodeList, |
RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList, | ||
RED::Vector< int > & | oTargetList | ||
) | const |
RED::RenderCode lookup method.
This method returns all RED::RenderCode (s) that can be found in the shader, for all the shading targets they were declared for and for all shader's hardware platforms. All returned render codes can be modified. Note that the returned addresses may become invalid if the shader is edited while any of the addresses is used.
Parameters:
oCodeList: | List of render codes. |
oPlatformList: | List of platforms for each value in oCodeList. |
oTargetList: | List of targets for each value in oCodeList. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetShaderTargets | ( | RED::Vector< int > & | oTargets, |
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Gets the list of shader targets composing the shader.
This method return a list of shader targets used for the definition of the shader. For example, a shader used for point lights and spot lights could use up to 3 different shader targets: one for parameters specific for point lights, the other for parameters specific for spot lights and the third being a bitwise combination of the two unitary targets for the storage of all parameters common to both.
Parameters:
oTargets: | The list of all shader targets composing the shader. |
iPlatformId: | Platform identifier. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::GetVertexProgramId | ( | RED::ShaderProgramID & | oProgram, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) | const |
Returns the identifier of a shader's vertex program.
This method searches the shader contents for a vertex program whose shader target exactly matches iShaderTarget.
Parameters:
oProgram: | The identifier of the vertex program, -1 if none could be found exactly matching iShaderTarget. |
iShaderTarget: | The exact shading target for the search. |
iPlatformId: | Platform identifier. |
Returns:
public RED_RC RED::RenderShader::GetVertexProgramId | ( | RED::Vector< RED::ShaderProgramID > & | oProgramList, |
RED::Vector< RED::HARDWARE_PLATFORM > & | oPlatformList, | ||
RED::Vector< int > & | oTargetList | ||
) | const |
Vertex shader lookup method.
This method returns all vertex shader programs that can be found in the shader, for all the shading targets they were declared for and for all shader's hardware platforms.
Parameters:
oProgramList: | List of program identifiers. |
oPlatformList: | List of platforms for each value in oProgramList. |
oTargetList: | List of targets for each value in oProgramList. |
Returns:
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
public bool RED::RenderShader::IsInputParameter | ( | const RED::String & | iName | ) const |
Do we have an input parameter whose name is 'iName'?
Parameters:
iName: | Name of the input parameter. |
Returns:
public RED_RC RED::RenderShader::operator= | ( | const RenderShader & | iSrc | ) |
Assignment operator.
Parameters:
iSrc: | Right hand equality member. |
Returns:
public virtual RED_RC RED::RenderShader::RemoveParameter | ( | const RED::String & | iName | ) |
Removes a parameter from all platforms and targets.
This method removes all instances of the parameter identified by iName from all targets for all hardware platforms declared in the shader.
Parameters:
iName: | Parameter name to unreference. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public virtual RED_RC RED::RenderShader::RemoveParameterFromPlatform | ( | const RED::String & | iName, |
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Removes a parameter for a given hardware platform.
The parameter identified by iName is removed for all targets for the specified iPlatformId.
Parameters:
iName: | Parameter name to unreference. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public void RED::RenderShader::Reset | ( | ) |
Cleanup of a RenderShader.
Clears all shader parameters and programs, for all platforms and all targets.
public void RED::RenderShader::ResetPlatform | ( | RED::HARDWARE_PLATFORM | iPlatformId | ) |
Cleanup of a RenderShader for a given hardware platform.
Clears all shader parameters and programs, for the specified 'iPlatformId'.
public virtual RED_RC RED::RenderShader::Save | ( | RED::IStream * | iStream, |
StreamingPolicy & | iPolicy, | ||
int | iState = -1 | ||
) | const |
Saves the object content as one or more chunks in the given stream.
Parameters:
iStream: | Pointer to the stream where the data must be saved. |
iPolicy: | Reference to the streaming policy to be used. |
iState: | Optional state number parameter at which the data to be saved must be retrieved. Default is set to 0 (for current state). |
Returns:
RED_FILE_WRITE_ERROR on a file write error (if iStream is a file stream),
RED_ALLOC_FAILURE on a memory allocation error,
RED_FAIL otherwise.
Implements: RED::IChunkSaver::Save.
public virtual RED_RC RED::RenderShader::SetGeometryProgramId | ( | const RED::ShaderProgramID & | iGshProgramID, |
int | iShaderTarget, | ||
RED::Object * | iResourceManager, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Sets the shader geometry program to use.
Geometry programs are optional in a rendering pipeline. Some graphics hardware have no support for geometry programs. Geometry programs are ignored in software ray-tracing.
Shader programs are shared resources. The resource manager is in charge of loading custom programs from byte streams thanks to RED::IResourceManager::LoadShaderFromString. That method returns an ID that can be supplied to iGshProgramID.
The program will be ignored for all lights whose target don't intersect with the iShaderTarget value.
This method is used in the tutorial Writing a custom rendering shader using geometry program.
Parameters:
iGshProgramID: | Geometry shader program identifier. |
iShaderTarget: | Bitwise combination of the shader targets used. |
iResourceManager: | The cluster's resource manager. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::SetInputParameter | ( | const RED::Color & | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | const RED::Object * | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | RED::MESH_CHANNEL | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | double | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | const RED::Vector4 & | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | bool | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | const RED::Matrix & | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public RED_RC RED::RenderShader::SetInputParameter | ( | RED::MATERIAL_PASS | iParameter, |
const RED::String & | iName, | ||
RED::Object * | iResMgr, | ||
bool | iEvaluate = true | ||
) |
Set an input parameter value by its name.
Parameters:
iParameter: | The parameter value. |
iName: | The name of the input parameter. |
iResMgr: | The cluster's resource manager. |
iEvaluate: | If true, the shader is re-evaluated to take the change into consideration. |
Returns:
RED_BAD_PARAM if no parameter with 'iName' is found in our list,
RED_FAIL if the parameter 'iName' is not of the type specified by the method.
public virtual RED_RC RED::RenderShader::SetPixelProgramId | ( | const RED::ShaderProgramID & | iPshProgramId, |
int | iShaderTarget, | ||
RED::Object * | iResourceManager, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Sets the shader pixel program to use.
Shader programs are shared resources. The resource manager is in charge of loading custom programs from byte streams thanks to RED::IResourceManager::LoadShaderFromString. That method returns an ID that can be supplied to iPshProgramID.
The program will be ignored for all lights whose form don't match the iShaderTarget value.
Please see the Writing a custom rendering shader in GLSL tutorial to have an example of use.
Parameters:
iPshProgramId: | Pixel shader program identifier. |
iShaderTarget: | Bitwise combination of the shader targets used. |
iResourceManager: | The cluster's resource manager. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public virtual RED_RC RED::RenderShader::SetRenderCode | ( | const RED::RenderCode & | iRenderCode, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Defines the vertex shader geometrical inputs.
The RED::RenderCode defines the vertex shader input information that are bridged by the engine for it to properly work.
This information contains geometrical channels bindings, as well as input matrices that can be made available to the vertex shader.
The rendercode is set for the iShaderTarget value.
More information about render code is available here: From geometry data to rendering programs
Parameters:
iRenderCode: | RED::RenderCode defining the vertex shader input. |
iShaderTarget: | Shader target for which the code is used. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public virtual RED_RC RED::RenderShader::SetVertexProgramId | ( | const RED::ShaderProgramID & | iVshProgramID, |
int | iShaderTarget, | ||
RED::Object * | iResourceManager, | ||
RED::HARDWARE_PLATFORM | iPlatformId = RED::HW_GENERIC | ||
) |
Sets the shader vertex program to use.
Shader programs are shared resources. The resource manager is in charge of loading custom programs from byte streams thanks to RED::IResourceManager::LoadShaderFromString. That method returns an ID that can be supplied to iVshProgramID.
The program will be ignored for all lights whose target don't intersect with the iShaderTarget value.
This method is highly used in the shader relative tutorials like Writing a custom rendering shader in GLSL.
Parameters:
iVshProgramID: | Vertex shader program identifier. |
iShaderTarget: | Bitwise combination of the shader targets used. |
iResourceManager: | The cluster's resource manager. |
iPlatformId: | Platform identifier. |
Returns:
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
public RED_RC RED::RenderShader::Solve | ( | RED::IReferenceManager * | iReferenceManager, |
const RED::State & | iState | ||
) |
Shader texture and program ID reference solving.
Parameters:
iReferenceManager: | Reference repository. |
iState: | Current transaction parameter. |
public virtual RED_RC RED::RenderShader::UpdateFrom | ( | const RED::Object & | iShader, |
const RED::State & | iState, | ||
int | iSrcStateNumber | ||
) |
Updates the instance with the content of the given one.
Parameters:
iShader: | Pointer to the source shader. |
iState: | Transaction parameter. |
iSrcStateNumber: | Transaction at which the source shader must be evaluated. |
Returns:
Implements: RED::Shader::UpdateFrom.
protected const RED::RenderShaderData * RED::RenderShader::FindPlatformData | ( | int | iShaderTarget, |
RED::HARDWARE_PLATFORM | iPlatformId | ||
) | const |
Returns an existing data object for a given shader configuration.
This call returns for iTarget and iPlatformId the RenderShaderData that defines the shader contents. The shader data is returned if found, using the hardware platform hierarchy, or NULL is returned.
Parameters:
iShaderTarget: | Targeted shader configuration. |
iPlatformId: | Identifier of the hardware platform. |
Returns:
protected RED_RC RED::RenderShader::GetPlatformData | ( | RED::RenderShaderData *& | oData, |
int | iShaderTarget, | ||
RED::HARDWARE_PLATFORM | iPlatformId | ||
) |
Returns a data object to use for a given shader configuration.
This call returns for iTarget and iPlatformId the RenderShaderData that defines the shader contents. The data object matching iPlatformID and iShaderTarget is created upon need.
Parameters:
oData: | The found or created shader data. |
iShaderTarget: | Targeted shader configuration. |
iPlatformId: | Identifier of the hardware platform. |
Returns:
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
protected RED::Vector< RED::RenderShaderData > * RED::RenderShader::PlatformLookup | ( | RED::HARDWARE_PLATFORM | iPlatformID, |
bool | iExactMatch | ||
) | const |
Looks for a given hardware platform, return the list of lighting targets available for it.
Parameters:
iPlatformID: | Identifier of the hardware platform for the research. |
iExactMatch: | If true, the exact value of 'iPlatformId' is searched for, if false, the runtime platform hierarchy is used to look for a hardware compatible platform instead. |
Returns:
Variables documentation
Per platform per lighting target shader data.