class RED::Shader
Master shader class. Defines the way elements are rendered. More...
#include <REDShader.h>
Inherits: IChunkSaver and Object.
Inherited by: RenderShader and StateShader.
Public functions:
Shader ( ) | |
virtual | ~Shader ( ) |
virtual void * | As ( const RED::CID & iCID ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
template< class T_As > T_As * | As ( ) |
virtual Shader * | Clone ( ) const = 0 |
virtual RED_RC | GetOperationStream ( const RED::Object * iCaller, RED::Vector< int > & ioStream, RED::HARDWARE_PLATFORM iPlatformId ) const |
virtual RED_RC | UpdateFrom ( const RED::Object & iShader, const RED::State & iState, int iSrcStateNumber ) = 0 |
Public static functions:
static RED::CID | GetClassID ( ) |
Detailed description:
Master shader class. Defines the way elements are rendered.
Shaders are objects involved during the construction of a material for the rendering of shapes in a scene. A shape owns one single material that defines the way it'll be rendered and react to lighting.
There are two kind of shaders beyond the Shader class, which is a generic object:
- The RED::RenderShader: this shader defines the rendering operations to perform. This shader uses vertex and pixel programs and define the way they are configured.
- The RED::StateShader: this shader defines a render state to apply to the processing of the forthcoming shaders. For example, change in the blending equation, disarm of z-buffer testing or any other state management operation are managed through it.
Shaders are assembled in lists defining the rendering sequences of a material. As explained in the Building REDsdk materials book, there are three basic rendering sequences: pre-lighting, lighting and post-lighting, so a given material may have three separate shader lists (plus other special lists for dedicated shading purposes).
Shaders can't be shared amongst materials, but can be shared amongst passes in the same material. Materials can be shared by many shapes.
RED::RenderShader and RED::StateShader shaders classes instances support platform selection, which enables the same shader to behave in a way that is specific to a given graphical hardware.
Functions documentation
public RED::Shader::Shader | ( | ) |
Constructor.
public virtual RED::Shader::~Shader | ( | ) |
Destructor.
public static RED::CID RED::Shader::GetClassID | ( | ) |
Reimplements: RED::IChunkSaver::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::RenderShader::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, RED::RenderShaderViewport::GetClassID and RED::StateShader::GetClassID.
public virtual void * RED::Shader::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::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::RenderShader::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, RED::RenderShaderViewport::As and RED::StateShader::As.
public virtual const void * RED::Shader::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::Object::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::RenderShader::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, RED::RenderShaderViewport::As and RED::StateShader::As.
template< class T_As > public const T_As * RED::Shader::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::Object::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::RenderShader::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, RED::RenderShaderViewport::As and RED::StateShader::As.
template< class T_As > public T_As * RED::Shader::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::Object::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::RenderShader::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, RED::RenderShaderViewport::As and RED::StateShader::As.
public virtual Shader * RED::Shader::Clone | ( | ) const = 0 |
Object duplication.
This method must return a full copy of this.
Returns:
Implemented by: RED::RenderShader::Clone and RED::StateShader::Clone.
public virtual RED_RC RED::Shader::GetOperationStream | ( | const RED::Object * | iCaller, |
RED::Vector< int > & | ioStream, | ||
RED::HARDWARE_PLATFORM | iPlatformId | ||
) | const |
Gets 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.
Reimplemented by: RED::RenderShader::GetOperationStream and RED::StateShader::GetOperationStream.
public virtual RED_RC RED::Shader::UpdateFrom | ( | const RED::Object & | iShader, |
const RED::State & | iState, | ||
int | iSrcStateNumber | ||
) | = 0 |
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:
Implemented by: RED::RenderShader::UpdateFrom and RED::StateShader::UpdateFrom.