StateShader
Types
CULLING_MODE |
|
FUNCTION |
|
DEPTH_MODE |
|
STENCIL_MODE |
|
STENCIL_OPERATION |
|
BLENDING_MODE |
|
BLENDING_EQUATION |
|
BLENDING_FUNCTION |
|
TRANSPARENCY_MODE |
Fields
BACK |
|
FRONT |
|
NONE |
|
NEVER |
|
LESS |
|
LEQUAL |
|
GREATER |
|
GEQUAL |
|
EQUAL |
|
NOTEQUAL |
|
ALWAYS |
|
DEPTH_SKIP |
|
ON |
|
OFF |
|
STENCIL_ON |
|
STENCIL_OFF |
|
STENCIL_OP_KEEP |
|
STENCIL_OP_ZERO |
|
STENCIL_OP_REPLACE |
|
STENCIL_OP_INCR |
|
STENCIL_OP_DECR |
|
STENCIL_OP_INVERT |
|
SKIP |
|
NO_BLENDING |
|
ADDITIVE |
|
SUBTRACTIVE |
|
MULTIPLICATIVE |
|
CUSTOM |
|
ADD |
|
SUBTRACT |
|
REVERSE_SUBTRACT |
|
MIN |
|
MAX |
|
EQ_ENUM_SIZE |
|
ZERO |
|
ONE |
|
SRC_COLOR |
|
ONE_MINUS_SRC_COLOR |
|
DST_COLOR |
|
ONE_MINUS_DST_COLOR |
|
SRC_ALPHA |
|
ONE_MINUS_SRC_ALPHA |
|
DST_ALPHA |
|
ONE_MINUS_DST_ALPHA |
|
SRC_ALPHA_SATURATE |
|
CONSTANT_COLOR |
|
ONE_MINUS_CONSTANT_COLOR |
|
CONSTANT_ALPHA |
|
ONE_MINUS_CONSTANT_ALPHA |
|
FUNC_ENUM_SIZE |
|
NO_TRANSPARENCY |
|
MASKED_TRANSPARENCY |
|
SORTED_TRANSPARENCY |
|
SORTED_AND_MASKED_TRANSPARENCY |
Functions
Detailed Description
-
class
StateShader
: public RED::Shader Rendering pipeline configuration shader class.
@related Writing a Custom Material, Configuring a Render Shader Using a State Shader, class RED::IMaterial, class RED::RenderShader, class RED::RenderCode
The RED::StateShader is used to configure the rendering pipeline for all shaders that are rendered after it in a list of shaders in a material. Hardware and software state parameters are managed using this shader. State parameters include all the parameters typically involved in the setup of a rendering pass, such as depth equation, blending mode, stencil, lines or point shapes, etc…
Transparency should be consistent across all state shaders within a material. Ray-traced transparency information will be based on an analysis of the state shaders of the material.
Default state shader parameters are set to:
- BACK face culling.
- SKIP blending mode.
- SKIP depth testing mode.
- SKIP depth writing mode.
- NO_TRANSPARENCY transparency.
- 1 pixel line width.
- Disabled line stipple,
- No polygon offset,
- Color writes enabled,
- Line and point smoothing off,
- Line thickness and point sizes set to 1,
- No displacement map,
- OFF stencil mode.
- Stencil ref = 0.0, stencil mask = 0xffffffff, stencil writemask = 0xffffffff,
- Stencil operations: all STENCIL_OP_KEEP.
The RED::StateShader supports multiple hardware platforms, as the RED::RenderShader do. On setting up a given platform for the first time, the state shader clones any more generic platform that was setup before. For example if the shader uses a give polygon offset setup for RED::HW_GENERIC platform, on setting up a parameter for the RED::HW_NVIDIA_G400 platform, all values from the RED::HW_GENERIC platform will be copied. However, once the two platform exist, there’s no more copy of any setting: modifying the RED::HW_GENERIC platform will not change the RED::HW_NVIDIA_G400 platform parameters.
Public Types
-
enum
CULLING_MODE
Select the side of a triangle that is to be visible during the rendering: BACK or FRONT. To render both faces of a polygon, use NONE.
Values:
-
enumerator
BACK
Culls back faces of the rendered geometry.
-
enumerator
FRONT
Culls front faces of the rendered geometry.
-
enumerator
NONE
Culls neither front nor back faces of the rendered geometry.
-
enumerator
-
enum
FUNCTION
Enumeration of a depth or stencil test function.
Values:
-
enumerator
NEVER
Never pass the depth or stencil test for any fragment.
-
enumerator
LESS
Pass the depth or stencil test if the incoming fragment’s depth is less than the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
LEQUAL
Pass the depth or stencil test if the incoming fragment’s depth is less than or equal to the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
GREATER
Pass the depth or stencil test if the incoming fragment’s depth is greater than the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
GEQUAL
Pass the depth or stencil test if the incoming fragment’s depth is greater than or equal to the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
EQUAL
Pass the depth or stencil test if the incoming fragment’s depth is equal to the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
NOTEQUAL
Pass the depth or stencil test if the incoming fragment’s depth is not equal to the current buffer depth or stencil at the fragment’s coordinates.
-
enumerator
ALWAYS
Always pass the depth or stencil test for any fragment (default).
-
enumerator
-
enum
DEPTH_MODE
Enable or disable z testing or writing.
Values:
-
enumerator
DEPTH_SKIP
Let the current depth testing or writing mode unchanged (default).
-
enumerator
ON
Enable depth testing using the specified depth comparison function or enable depth writing.
-
enumerator
OFF
Disable depth testing or writing.
-
enumerator
-
enum
STENCIL_MODE
Enable or disable stencil testing.
Values:
-
enumerator
STENCIL_ON
Enable stencil testing.
-
enumerator
STENCIL_OFF
Disable stencil testing.
-
enumerator
-
enum
STENCIL_OPERATION
Lists all possible stencil operations.
Values:
-
enumerator
STENCIL_OP_KEEP
Stencil operation. Keep existing stencil value unchanged.
-
enumerator
STENCIL_OP_ZERO
Stencil operation. Set stencil value to zero.
-
enumerator
STENCIL_OP_REPLACE
Stencil operation. Replace stencil value by incoming stencil value.
-
enumerator
STENCIL_OP_INCR
Stencil operation. Increment stencil buffer by 1.
-
enumerator
STENCIL_OP_DECR
Stencil operation. Decrement stencil buffer by 1.
-
enumerator
STENCIL_OP_INVERT
Stencil operation. Invert bits in stencil buffer values.
-
enumerator
-
enum
BLENDING_MODE
Select the blending mode for all incoming geometries.
Values:
-
enumerator
SKIP
Means that we do not affect the current blending statement.
-
enumerator
NO_BLENDING
-
enumerator
ADDITIVE
color = (src_color * src_alpha) + (dest_color * (1 - src_alpha)).
-
enumerator
SUBTRACTIVE
color = (src_color * src_alpha) - (dest_color * (1 - src_alpha)).
-
enumerator
MULTIPLICATIVE
color = src_color * dest_color.
-
enumerator
CUSTOM
color = function1( src_color ) operand function2( dest_color ).
-
enumerator
-
enum
BLENDING_EQUATION
Lists all possible blending operations mixing the incoming fragment color and the destination fragment color.
Values:
-
enumerator
ADD
color = src_color + dest_color.
-
enumerator
SUBTRACT
color = src_color - dest_color.
-
enumerator
REVERSE_SUBTRACT
color = dest_color - src_color.
-
enumerator
MIN
color = min( src_color, dest_color ).
-
enumerator
MAX
color = max( src_color, dest_color ).
-
enumerator
EQ_ENUM_SIZE
Size of this enumeration.
-
enumerator
-
enum
BLENDING_FUNCTION
Lists all functions that can apply to the source or destination colors in the blending equation. The blending formula is always ‘func1(src_color) operation func2(dest_color)’.
Values:
-
enumerator
ZERO
-
enumerator
ONE
-
enumerator
SRC_COLOR
-
enumerator
ONE_MINUS_SRC_COLOR
-
enumerator
DST_COLOR
-
enumerator
ONE_MINUS_DST_COLOR
-
enumerator
SRC_ALPHA
-
enumerator
ONE_MINUS_SRC_ALPHA
-
enumerator
DST_ALPHA
-
enumerator
ONE_MINUS_DST_ALPHA
-
enumerator
SRC_ALPHA_SATURATE
-
enumerator
CONSTANT_COLOR
-
enumerator
ONE_MINUS_CONSTANT_COLOR
-
enumerator
CONSTANT_ALPHA
-
enumerator
ONE_MINUS_CONSTANT_ALPHA
-
enumerator
FUNC_ENUM_SIZE
-
enumerator
-
enum
TRANSPARENCY_MODE
Select the kind of transparency we should use for the shader.
Values:
-
enumerator
NO_TRANSPARENCY
The name says it.
-
enumerator
MASKED_TRANSPARENCY
This is a fake transparency. The texture specified in RED::StateShader::SetMaskedTransparency is used as a filter for the fragments to render. There’s no blending at all as the transparency result is a binary 0 / 1 value. Ray-traced shadows are defined by the masking texture’s alpha intensity.
-
enumerator
SORTED_TRANSPARENCY
Blended transparency. The color or transparency texture is specified by RED::StateShader::SetSortedTransparency. Ray-traced shadows are defined by the color of the transparency, or by the texture’s color modulated by the texture’s alpha.
-
enumerator
SORTED_AND_MASKED_TRANSPARENCY
The texture’s alpha value is used to mask the pixel regions where the fragments are rendered. This combines both transparency modes, using the single texture specified with RED::StateShader::SetSortedAndMaskedTransparency. Ray-traced shadows are computed as for the RED::StateShader::SORTED_TRANSPARENCY mode.
-
enumerator
Public Functions
-
SET_CID
(CID_class_REDStateShader)
-
IMPLEMENT_AS
()
-
SET_CHUNK_SIGNATURE (0x00000707)
-
IMPLEMENT_CHUNKINTERPRETER
()
-
StateShader
() Construction method.
The StateShader is using a RED::HARDWARE_PLATFORM identifier for all data setup & access, in all ways similarly to the RED::RenderShader, so that the same state shader instance can behave differently on different hardware.
A state shader uses the default RED::Object ID set at its creation time.
-
virtual
~StateShader
() Destruction method.
-
RED_RC
SetNoTransparency
(RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Indicates that we are not transparent at all.
This is the default of a state shader.
Parameters: iPlatformID – Platform identifier. Returns: RED_OK when the operation succeeded, RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetMaskedTransparency
(const RED::Object *iAlphaImage, RED::MESH_CHANNEL iAlphaChannel, const RED::Matrix &iAlphaMatrix, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines a mask based transparency.
See \ref bk_bm_custom_state_alphamask for details.
Parameters: - iAlphaImage – Specify the address of the alpha masking texture.
- iAlphaChannel – Mesh channel source of the UV for the alpha mapping transparency texture sampling.
- iAlphaMatrix – Texture matrix for iAlphaImage.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetSortedTransparency
(const RED::Color &iOpacityColor, const RED::Object *iOpacityTexture, RED::MESH_CHANNEL iOpacityUV, const RED::Matrix &iOpacityMatrix, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines a per pixel depth sorted transparency.
We may use an opacity color or an opacity texture in this configuration. We are not alpha masked by the texture’s alpha values.
See also \ref bk_improving_cad_graphics.
Parameters: - iOpacityColor – Opacity color.
- iOpacityTexture – Opacity texture. Overrides iOpacityColor when set.
- iOpacityUV – UV channel to use if we have a, opacity texture.
- iOpacityMatrix – Opacity texture matrix.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetSortedTransparency
(const RED::Color &iOpacityColor, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines a per pixel depth sorted transparency.
We may use an opacity color here. This call is equivalent to setting a sorted transparency without texture using:
RED::StateShader::SetSortedTransparency( iOpacityColor, NULL, RED::MCL_TEX0, RED::Matrix::IDENTITY, iPlatformID );
Parameters: - iOpacityColor – Opacity color.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetSortedAndMaskedTransparency
(const RED::Object *iOpacityTexture, RED::MESH_CHANNEL iOpacityUV, const RED::Matrix &iOpacityMatrix, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines a depth sorted transparency with an alpha mask.
We use an opacity texture in this configuration. The texture’s color is used as the opacity color, and the texture’s alpha is used as alpha mask for the rendering.
Parameters: - iOpacityTexture – Opacity texture.
- iOpacityUV – UV channel to use to sample the opacity texture.
- iOpacityMatrix – Opacity texture matrix.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetAlphaThreshold
(float iAlphaThreshold, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the alpha masking threshold.
This value is used to define the alpha masking ratio for alpha masked transparency.
See \ref bk_bm_custom_state_alphamask for details.
Parameters: - iAlphaThreshold – New value [0.0f,1.0f].
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetFaceCulling
(CULLING_MODE iCullingMode, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Sets the face culling mode.
Sets the culling mode for all incoming geometries.
Parameters: - iCullingMode – Face culling mode.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetBlendingMode
(BLENDING_MODE iBlendingMode, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the color blending mode.
Sets the blending mode for all incoming geometry. The RED::StateShader::SKIP blending mode indicates that the state shader will not interfere with the current blending parameters.
See \ref bk_bm_custom_state_transpar and \ref bk_bm_custom_state_blend for details on blending and transparency.
Parameters: - iBlendingMode – The blending mode to use.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetBlendingMode
(BLENDING_MODE iBlendingMode, BLENDING_FUNCTION iFunction1, BLENDING_EQUATION iOperation, BLENDING_FUNCTION iFunction2, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the color blending mode.
Sets the blending mode for all incoming geometry. All parameters of the blending equation are set by this call.
See \ref bk_bm_custom_state_transpar and \ref bk_bm_custom_state_blend for details on blending and transparency.
Parameters: - iBlendingMode – The blending mode to use.
- iFunction1 – Function applied to the incoming fragment color.
- iOperation – Operation combining the two colors.
- iFunction2 – Function applied to the buffer fragment color.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetBlendingConstant
(const RED::Color &iConstant, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Sets the constant colors/alpha usable in the blending.
Sets the constant color that can be used in a blending equation, for functions using one of the following BLENDING_FUNCTIONs:
- CONSTANT_COLOR,
- ONE_MINUS_CONSTANT_COLOR,
- CONSTANT_ALPHA,
- ONE_MINUS_CONSTANT_ALPHA.
See \ref bk_bm_custom_state_transpar and \ref bk_bm_custom_state_blend for details on blending and transparency.
Parameters: - iConstant – Source and destination color constant.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetBlendingMode
(int iNumBuffer, BLENDING_FUNCTION iFunction1, BLENDING_EQUATION iOperation, BLENDING_FUNCTION iFunction2, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the color blending mode for a single drawing buffer of a multiple render target VRL.
Requires blending to be activated using RED::StateShader::SetBlendingMode and the rendering to occur in a multiple render target VRL, created using RED::IWindow::CreateMultiRenderTargetVRL.
A first call to RED::StateShader::SetBlendingMode will turn on blending for all drawing buffers available in the VRL. Then, per buffer blending operations can be configured using this call.
See \ref bk_bm_custom_state_transpar and \ref bk_bm_custom_state_blend for details on blending and transparency.
Note that your hardware must support the ARB_draw_buffers_blend OpenGL extension, otherwise, the operation is ignored.
Parameters: - iNumBuffer – The number of the buffer being targeted.
- iFunction1 – Function applied to the incoming fragment color.
- iOperation – Operation combining the two colors.
- iFunction2 – Function applied to the buffer fragment color.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetDoubleSided
(bool iDoubleSided, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Renders the geometry once or twice.
Renders the geometry once if iDoubleSided is false, and renders the geometry twice if iDoubleSided is true. The polygon facing reference RED::RenderShaderParameter::REF_POLYGON_FACING can be used to identify which object side is currently being rendered.
Parameters: - iDoubleSided – Are we double sided ?
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetDepthFunction
(FUNCTION iFunc, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Specifies the depth function to use.
Depth testing must be enabled for this function to be effectively set.
Parameters: - iFunc – The new depth test function.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetDepthTest
(DEPTH_MODE iTest, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Specifies the depth testing mode.
SKIP lets the previous state shader or pass startup mode unmodified.
Note that in standard OpenGL if the depth test is disabled, then there won’t be any depth write that will occur, even if the depth mask is enabled.
Parameters: - iTest – The new depth test mode.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetDepthMask
(DEPTH_MODE iMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Specifies the depth masking (write) mode.
SKIP lets the previous state shader or pass startup mode unmodified.
Parameters: - iMask – The new depth write mode.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetLineWidth
(float iWidth, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Specifies the pixel width of rendered lines.
Define the pixel width of rendered lines. Note that enabling engine anti-aliasing reduces the size of rendered lines because of the super sampling method used. When engine AA is enabled, it may be necessary to increase the specified line width.
The rendering of thick lines is supported by the GPU rendering but is not supported by the software ray-tracer. However, 1 pixel wide lines can be rendered by the software ray-tracer.
Parameters: - iWidth – Pixel width of lines.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetLineStipple
(bool iOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables or disables line stipple.
See \ref wf_hidden_lines_removal_a_real_time_example for a practical example of line stipple.
Parameters: - iOnOff – Enable or disable line stipple.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetLineStipplePattern
(int iFactor, short iPattern, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the line stipple parameters.
See \ref wf_hidden_lines_removal_a_real_time_example for a practical example of line stipple.
Parameters: - iFactor – Line stipple factor. This is the scaling applied to the line stipple pattern. Input value is clamped to [1,256]. For example, using a factor of 3 repeats three times each bit equal to 1 defined in the pattern.
- iPattern – Line stipple pattern. This is a mask of 16 bits that define the line pattern used to draw lines.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetLineSmoothing
(bool iOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables or disables line smoothing.
Uses OpenGL line smoothing capabilities, improving the quality of thick lines being rendered with a line stipple pattern.
Parameters: - iOnOff – Enable or disable line smoothing.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetPointSmoothing
(bool iOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables or disables point smoothing.
Uses OpenGL point smoothing capabilities, improving the quality of points being rendered with a point size greater than 1. If activated, points are rendered round instead of square.
Parameters: - iOnOff – Enable or disable point smoothing.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetPointSize
(float iSize, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the point size.
Define the OpenGL point size. This is the diameter of the point size.
Parameters: - iSize – Diameter of rendered points.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetPolygonOffset
(bool iOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables or disables polygon offset.
Only triangle based data may be depth offseted using the polygon offset. Other primitives may not be offseted.
The polygon offset is useful to avoid geometry stitching artifacts and is widely used to prevent edges of a mesh to be z-fighting with the geometry they represent.
Parameters: - iOnOff – Enable or disable polygon offset.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetPolygonOffsetValue
(float iFactor, float iUnits, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the polygon offset parameters.
The polygon offset is useful to avoid geometry stitching artifacts and is widely used to prevent edges of a mesh to be z-fighting with the geometry they represent.
Usually, ‘iFactor’ starts at 1.0 and is below 10.0; ‘iUnits’ starts at 1.0 and may be up to 100.0+ depending on the viewing conditions.
Parameters: - iFactor – Angular factor used in the polygon offset equation.
- iUnits – Number of biasing units in the polygon offset equation.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetColorMask
(bool iWriteR, bool iWriteG, bool iWriteB, bool iWriteA, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the color write mode.
Parameters: - iWriteR – Authorized to write red color component?
- iWriteG – Authorized to write green color component?
- iWriteB – Authorized to write blue color component?
- iWriteA – Authorized to write alpha color component?
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetMatte
(bool iMatte, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the matte mode.
When a material has the matte mode set to true, it is considered as not being lit directly. Instead, it receives shadows cast by the other objects in the scene as well as their global illumination contribution.
Matte objects are useful when rendering synthetic objects into real-world photographs for example.
Parameters: - iMatte – Enable (true) or disable (false) matte mode.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetDisplacement
(float iDispHeight, const RED::Object *iDispTexture, const RED::Matrix &iDispMatrix, RED::MESH_CHANNEL iDispUV, float iDispOffset, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines a displacement map for the rendering of the object.
Defines a displacement map for the object. A displacement map is used to define a surface elevation at each texel on the rendered geometry. Texel triangles are created in a transient manner during the rendering to increase the detail of rendered geometries.
The height of the displacement map is the .x coordinate read from the texture map. The displacement map must be a RED::TGT_TEX_2D texture. The RED::FMT_L8 is best to use for the texture storage.
Displacement mapping can be removed by calling SetDisplacement with NULL as displacement texture.
Displacement mapping can be enabled or disabled for the ray-tracer by setting the wished RED::OPTIONS_RAY_DISPLACEMENT value.
Displacement mapping is ignored in hardware rendering.
See \ref wf_displacement for a displacement mapping example.
Parameters: - iDispHeight – Maximal height of the displacement in model units. This value must be positive. To have a displacement “below” the displaced surface, please use a negative ‘iDispOffset’ value and a positive ‘iDispHeight’.
- iDispTexture – Displacement texture. Must be a valid 2D image or NULL to disable displacement.
- iDispMatrix – Displacement texture matrix.
- iDispUV – UV channel to use to sample the displacement texture. Must be in the [ RED::MCL_TEX0, RED::MCL_TEX7 ] range.
- iDispOffset – Displacement offset. This is a global translation of the displacement region. Setting a negative offset value for example equal to ‘iDispHeight’ generates a displacement surface that appears below the actual original surface level.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetStencilTest
(STENCIL_MODE iTest, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables or disables stencil testing.
RED::StateShader::STENCIL_OFF is the default. See \ref bk_ba_no_stencil_buffer_on_auxiliary_vrls for details on using stencil buffer on various hardware.
Parameters: - iTest – Specify the stencil test mode.
- iPlatformID – Platform identifier.
Returns: RED_OK is the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetStencilFunction
(FUNCTION iFunc, int iRef, int iMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines the stencil function.
Defines the standard OpenGL stencil test: ( iRef & iMask ) iFunc ( stencil_buffer & iMask ) See \ref bk_ba_no_stencil_buffer_on_auxiliary_vrls for details on using stencil buffer on various hardware.
Parameters: - iFunc – The new stencil test function.
- iRef – Reference value for the stencil test.
- iMask – Bitwise AND mask for stencil test.
- iPlatformID – Platform identifier.
Returns: RED_OK is the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetStencilOperation
(STENCIL_OPERATION iFailOp, STENCIL_OPERATION iZFailOp, STENCIL_OPERATION iZPassOp, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Defines all stencil operations.
See \ref bk_ba_no_stencil_buffer_on_auxiliary_vrls for details on using stencil buffer on various hardware.
Parameters: - iFailOp – Stencil operation that occurs when the stencil test fails.
- iZFailOp – Stencil operation that occurs when the stencil test passes and the depth test fails.
- iZPassOp – Stencil operation that occurs when the stencil test and the depth test passes.
- iPlatformID – Platform identifier.
Returns: RED_OK is the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed.
-
RED_RC
SetStencilMask
(int iMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Specifies the stencil writemask value.
See \ref bk_ba_no_stencil_buffer_on_auxiliary_vrls for details on using stencil buffer on various hardware.
Parameters: - iMask – The new stencil mask value.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetReflectiveCaustics
(bool iReflectiveCaustics, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables/disables reflective caustics.
True to enable the generation of reflective caustics.
Parameters: - iReflectiveCaustics – Are reflective caustics enabled?
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
SetRefractiveCaustics
(bool iRefractiveCaustics, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) Enables/disables refractive caustics.
True to enable the generation of refractive caustics.
Parameters: - iRefractiveCaustics – Are refractive caustics enabled?
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
GetPlatformsCount
(int &oCount) const Gets the number of platforms used by this shader.
This method returns the number of hardware platforms that have been configured for this shader.
Parameters: oCount – Number of hardware platforms used by the shader. Returns: RED_OK when the method has succeeded, RED_FAIL otherwise.
-
RED_RC
GetPlatformList
(RED::Vector<RED::HARDWARE_PLATFORM> &oPlatformList) const Gets the list of hardware platforms used by the shader.
This method fills a RED::Vector with the list of hardware platforms that are used by the shader.
Parameters: oPlatformList – The list of hardware platforms. Returns: RED_OK if the operation has succeeded, RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetTransparencyMode
(TRANSPARENCY_MODE &oTransparency, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the kind of transparency we manage.
Parameters: - oTransparency – The transparency mode for all shaders after this one in its rendering pass.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetTransparencyImage
(RED::Object **oImage, RED::MESH_CHANNEL &oUVChannel, RED::Matrix &oMatrix, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Retrieves transparency texture parameters.
Parameters: - oImage – Address of the transparency / alpha texture if it exists.
- oUVChannel – Mesh channel used to sample ‘oImage’.
- oMatrix – Texture matrix for ‘oImage’.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetTransparencyColor
(RED::Color &oTransparColor, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the color of the transparency.
Parameters: - oTransparColor – Transparency color.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetAlphaThreshold
(float &oAlpha, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the alpha masking threshold.
Parameters: - oAlpha – The alpha threshold value for all shaders after this one.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetBlendingMode
(BLENDING_MODE &oBlend, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the state shader blending mode.
Parameters: - oBlend – The blending mode for the shader.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetBlendingMode
(BLENDING_MODE &oBlend, BLENDING_FUNCTION &oFunction1, BLENDING_EQUATION &oEquation, BLENDING_FUNCTION &oFunction2, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the detailed state shader blending mode.
Parameters: - oBlend – The blending mode for the shader.
- oFunction1 – Function applied to the incoming fragment color.
- oEquation – Operation combining the two colors.
- oFunction2 – Function applied to the buffer fragment color.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetBlendingMode
(BLENDING_FUNCTION &oFunction1, BLENDING_EQUATION &oEquation, BLENDING_FUNCTION &oFunction2, int iNumBuffer, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the detailed state shader blending mode for a specified iNumBuffer.
Parameters: - oFunction1 – Function applied to the incoming fragment color.
- oEquation – Operation combining the two colors.
- oFunction2 – Function applied to the buffer fragment color.
- iNumBuffer – The number of the buffer being targeted in the VRL.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetFaceCulling
(CULLING_MODE &oCullMode, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the face culling mode.
Parameters: - oCullMode – Face culling mode.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetDoubleSided
(bool &oDoubleSided, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Should the rendering be double sided?
Parameters: - oDoubleSided – true if we are double sided.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetDepthFunction
(FUNCTION &oFunc, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the depth function.
Parameters: - oFunc – The depth function for the shader.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetDepthTest
(DEPTH_MODE &oDepth, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the depth testing mode.
Parameters: - oDepth – The depth testing mode for the shader.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetDepthMask
(DEPTH_MODE &oMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the depth masking mode.
Parameters: - oMask – The depth masking mode for the shader.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetLineWidth
(float &oWidth, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the pixel width of rendered lines.
Parameters: - oWidth – Pixel width of lines.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetLineStipple
(bool &oOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets line stipple activation status.
Parameters: - oOnOff – Is line stipple enabled ?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetLineStipplePattern
(int &oFactor, short &oPattern, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the line stipple parameters.
Parameters: - oFactor – Line stipple factor. This is the scaling applied to the line stipple pattern.
- oPattern – Line stipple pattern. This is a mask of 16 bits that define the line pattern used to draw lines.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetLineSmoothing
(bool &oOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the line smoothing activation status.
Parameters: - oOnOff – Is line smoothing enabled ?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetPointSmoothing
(bool &oOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the point smoothing activation status.
Parameters: - oOnOff – Is point smoothing enabled ?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetPointSize
(float &oPointSize, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the point size.
Parameters: - oPointSize – Return the point size diameter.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetPolygonOffset
(bool &oOnOff, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the polygon offset activation status.
Parameters: - oOnOff – Is polygon offset enabled ?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetPolygonOffsetValue
(float &oFactor, float &oUnits, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the polygon offset parameters.
Parameters: - oFactor – Angular factor used in the polygon offset equation.
- oUnits – Number of biasing units in the polygon offset equation.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetColorMask
(bool &oWriteR, bool &oWriteG, bool &oWriteB, bool &oWriteA, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the color masking mode.
Parameters: - oWriteR – Authorized to write red color component?
- oWriteG – Authorized to write green color component?
- oWriteB – Authorized to write blue color component?
- oWriteA – Authorized to write alpha color component?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetMatte
(bool &oMatte, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Gets the matte mode (see SetMatte for details).
Parameters: - oMatte – matte mode enabled?
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetDisplacement
(float &oDispHeight, RED::Object *&oDispTexture, RED::Matrix &oDispMatrix, RED::MESH_CHANNEL &oDispUV, float &oDispOffset, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Retrieves the displacement mapping parameters.
Parameters: - oDispHeight – Maximal displacement height in model units.
- oDispMatrix – Displacement texture matrix.
- oDispTexture – Displacement texture.
- oDispUV – Displacement UV channel.
- oDispOffset – Displacement offset translation.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetStencilTest
(STENCIL_MODE &oStencil, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the stencil testing mode.
Parameters: - oStencil – The stencil testing mode for the shader.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetStencilFunction
(FUNCTION &oFunc, int &oRef, int &oMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the stencil function.
Parameters: - oFunc – The stencil function set in this shader.
- oRef – Reference value for the stencil test.
- oMask – Bitwise AND mask for stencil test.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetStencilOperation
(STENCIL_OPERATION &oFailOp, STENCIL_OPERATION &oZFailOp, STENCIL_OPERATION &oZPassOp, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the stencil operations.
Parameters: - oFailOp – Stencil operation that occurs when the stencil test fails.
- oZFailOp – Stencil operation that occurs when the stencil test passes and the depth test fails.
- oZPassOp – Stencil operation that occurs when the stencil test and the depth test passes.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetStencilMask
(int &oMask, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the stencil writemask.
Parameters: - oMask – The stencil writemask.
- iPlatformID – Platform identifier.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter.
-
RED_RC
GetReflectiveCaustics
(bool &oReflectiveCaustics, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the reflective caustics enabled status.
Parameters: - oReflectiveCaustics – Reflective caustics enabled status.
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
RED_RC
GetRefractiveCaustics
(bool &oRefractiveCaustics, RED::HARDWARE_PLATFORM iPlatformID = RED::HW_GENERIC) const Returns the refractive enabled caustics status.
Parameters: - oRefractiveCaustics – Are refractive caustics enabled?
- iPlatformID – Platform identifier.
Returns: RED_OK when the operation succeeded,
RED_BAD_PARAM if the method received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation did fail.
-
virtual RED_RC
UpdateFrom
(const RED::Object &iShader, const RED::State &iState, int iSrcStateNumber) Internal update event method.
Parameters: - iShader – Source shader.
- iState – Current transaction parameter.
- iSrcStateNumber – Source state number.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.
-
virtual RED_RC
GetOperationStream
(const RED::Object *iCaller, RED::Vector<int> &ioStream, RED::HARDWARE_PLATFORM iPlatformID) const Internal access to 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_OK when the shader could have its operation stream written down,
RED_ALLOC_FAILURE if an internal allocation did fail,
RED_FAIL otherwise.
-
RED_RC
Solve
(RED::IReferenceManager *iReferenceManager, const RED::State &iState) Shader texture reference solving.
Parameters: - iReferenceManager – Reference repository.
- iState – Current transaction parameter.
-
virtual RED_RC
Save
(RED::IStream *iStream, StreamingPolicy &iPolicy, int iState = -1) const Internal class streaming.
Parameters: - iStream – The target stream.
- iPolicy – The streaming policy.
- iState – The written transaction number.
Returns: RED_OK if the operation has succeeded,
RED_BAD_PARAM if the method has received an invalid parameter,
RED_ALLOC_FAILURE if an internal allocation has failed,
RED_FAIL otherwise.