21.2. Shader Nodes

Figure 21.4. Shader node classes


Shaders are managed by the node class SoShaderProgram( C++ | Java | .NET ), a property node that defines the current shader program for all subsequent shapes.

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

SoShaderParameter( C++ | Java | .NET ) and its derived classes are discussed in the section called “SoShaderParameter Nodes”.

The SoShaderProgram( C++ | Java | .NET ) node has the following field:

The SoShaderObject( C++ | Java | .NET ) node has the following fields:

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

The SoShaderParameter( C++ | Java | .NET ) node has the following fields:

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

Uniform shader parameter nodes (SoUniformShaderParameter( C++ | Java | .NET )) 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( C++ | Java | .NET )) should be inserted directly into the scene graph (like other property nodes, such as SoNormal( C++ | Java | .NET ), …).