Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Shader Nodes

figure_ac5efeb7-d0e4-437f-983e-eef7d7004630%* SoBase

+ **SoFieldContainer**



    - **SoNode**



        * **SoShaderObject**



            + SoVertexShader
            + SoFragmentShader
            + SoGeometryShader
        * SoShaderProgram
        * **SoShaderParameter**



            + **SoUniformShaderParameter**



                - SoShaderParameter1f
                - SoShaderParameter1i
                - SoShaderParameter2f
                - SoShaderParameter2i
                - SoShaderParameter3f
                - SoShaderParameter3i
                - SoShaderParameter4f
                - SoShaderParameter4i
                - SoShaderParameterArray1f
                - SoShaderParameterArray1i
                - SoShaderParameterArray2f
                - SoShaderParameterArray2i
                - SoShaderParameterArray3f
                - SoShaderParameterArray3i
                - SoShaderParameterArray4f
                - SoShaderParameterArray4i
                - SoShaderParameterMatrix
                - SoShaderParameterMatrixArray
                - SoShaderStateMatrixParameter
                - SoShaderParameterStruct
            + **SoVertexShaderParameter**



                - SoVertexShaderParameter1f
                - SoVertexShaderParameter1s
                - SoVertexShaderParameter2f
                - SoVertexShaderParameter2s
                - SoVertexShaderParameter3f
                - SoVertexShaderParameter3s
                - SoVertexShaderParameter4b
                - SoVertexShaderParameter4i
                - SoVertexShaderParameter4f
                - SoVertexShaderParameter4s
                - SoVertexShaderParameter4ub
                - SoVertexShaderParameter4ui
                - SoVertexShaderParameter4us
                - SoVertexShaderParameterMatrix

Figure 21.4. Shader node classes

Shaders are managed by the node class SoShaderProgram, a property node that defines the current shader program for all subsequent shapes.

SoShaderObject is the abstract class defining the different types of shaders which may be a vertex shader (SoVertexShader), a geometry shader (SoGeometryShader), or a fragment shader (SoFragmentShader).

SoShaderParameter and its derived classes are discussed in the section called “SoShaderParameter Nodes”.

SoShaderProgram and SoShaderObject Nodes

The SoShaderProgram node has the following field:

shaderObject (SoMFNode) Specifies the list of shader objects (i.e., vertex shaders, geometry
shader, or fragment shaders) which form the shader program.

The SoShaderObject node has the following fields:

isActive(SoSFBool) Specifies if the shader is active or not.
sourceType(SoSFEnum) Specifies the source type defined within the **
sourceProgram** field. Possible values as follows:* GLSL_PROGRAM: The source is a GLSL program. * FILENAME: Only the name of the file containing the source is given
(default).
sourceProgram(SoSFString) Contains the shader object’s source program, specified by a filename (sourceType set to FILENAME) or by the string containing the program (sourceType GLSL_PROGRAM).
parameter(SoMFShaderParameter) Defines a set of uniform parameters for the shader object.

SoShaderParameter Nodes

These nodes allow you to provide uniform parameters (SoUniformShaderParameter) or varying parameters (SoVertexShaderParameter) to a shader object and thus to the corresponding vertex and/or geometry and/or fragment shader.

The SoShaderParameter node has the following fields:

name(SoSFString) Specifies the parameter’s string name. This name is declared and used within high-level shading programs (GLSL).
identifier(SoSFInt32) Specifies the parameter’s integer identifier.

SoShaderParameter is a base class and its derived classes are actually used to set parameter values. The fields inherited from SoShaderParameter specify the name/identifier of the parameter, and the fields of the derived class specify the value of the parameter. For example, SoShaderParameter2f and SoVertexShaderParameter2f store a two-dimensional (float) vector and SoShaderParameterArray3f stores an array of three-dimensional (float) vectors.

Uniform shader parameter nodes (SoUniformShaderParameter) can be added directly to the scene graph or added to the parameter field of an SoVertexShader, SoGeometryShader, or SoFragmentShader node, whereas varying parameters (SoVertexShaderParameter) should be inserted directly into the scene graph (like other property nodes, such as SoNormal, …).