Class SoVertexShaderParameter

All Implemented Interfaces:
SafeDisposable
Direct Known Subclasses:
SoVertexShaderParameter1f, SoVertexShaderParameter1s, SoVertexShaderParameter2f, SoVertexShaderParameter2s, SoVertexShaderParameter3f, SoVertexShaderParameter3s, SoVertexShaderParameter4b, SoVertexShaderParameter4f, SoVertexShaderParameter4i, SoVertexShaderParameter4s, SoVertexShaderParameter4ub, SoVertexShaderParameter4ui, SoVertexShaderParameter4us, SoVertexShaderParameterBufferObject, SoVertexShaderParameterMatrix

public abstract class SoVertexShaderParameter extends SoShaderParameter
Abstract base class for all vertex shader parameter nodes. This is the abstract class from which all the vertex shader parameter nodes are derived.

These nodes allow applications to provide per-vertex parameters to shader objects.

Vertex shader parameter nodes must be inserted in the scene graph.

Each parameter is defined by the following properties:

  • name and/or identifier,
  • values.

Note that, unlike uniform parameters, the value field must contain as many values as there are vertices in the geometry to be rendered.

Warning Whatever the type of SoVertexShaderParameter (int, float, short, etc...), values are always converted to "float" before being sent to the shader, so you have to use a floating type (float, vec2, vec3, vec4, ...) when declaring the vertex parameter in the shader. Some types are directly cast to float while others may be normalized. If the subclass contains a field "rangeScaling", then you can request to normalize the data before sending them to shaders.

See the base class SoShaderParameter for information about how to specify the name and/or identifier of a parameter.

EXAMPLE

The following example shows how to set a vertex shader parameter named "scale" for each vertex in the geometry.

 int numValues = numVertices;
 float[] valuesArray = new float[numValues];
 
 SoVertexShaderParameter1f parameterNode = new SoVertexShaderParameter1f();
   parameterNode.name.setValue( "scale" );
   parameterNode.value.setValues(0, valuesArray);
 root.addChild(parameterNode); // Vertex parameters always added to scene graph
 
 SoVertexShader vertexShader = new SoVertexShader();
   vertexShader.sourceProgram.setValue( "filename.glsl" );
 
 SoShaderProgram shaderProgram = new SoShaderProgram();
   shaderProgram.shaderObject.set1Value( 0, vertexShader );
 root.addChild(shaderProgram);

File format/default:

This is an abstract class. See the reference page of a derived class for the format and default values.

See Also: