SoShaderObject Class |
Abstract node class which defines a shader object.
Namespace: OIV.Inventor.Nodes
The SoShaderObject type exposes the following members.
Name | Description | |
---|---|---|
AddShaderParameter(String, SbVec2f) | ||
AddShaderParameter(String, SbVec2i32) | ||
AddShaderParameter(String, SbVec3f) | ||
AddShaderParameter(String, SbVec3i32) | ||
AddShaderParameter(String, SbVec4f) | ||
AddShaderParameter(String, SbVec4i32) | ||
AddShaderParameter(String, Int32) | ||
AddShaderParameter(String, Single) | ||
AffectsState | Returns true if a node has an effect on the state during traversal. | |
Callback | (Inherited from SoNode.) | |
Copy | Calls Copy(false). (Inherited from SoNode.) | |
Copy(Boolean) | Creates and returns an exact copy of the node. | |
CopyFieldValues(SoFieldContainer) | Calls CopyFieldValues(fc, false). (Inherited from SoFieldContainer.) | |
CopyFieldValues(SoFieldContainer, Boolean) | Copies the contents of fc's fields into this object's fields. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Distribute | (Inherited from SoNode.) | |
DoAction | (Inherited from SoNode.) | |
EnableNotify | Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false). | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FieldsAreEqual | Returns true if this object's fields are exactly equal to fc's fields. | |
Get | Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
GetAllFields | Returns a list of fields, including the eventIn's and eventOut's. | |
GetAlternateRep | This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type). | |
GetBoundingBox | (Inherited from SoNode.) | |
GetEventIn | Returns a the eventIn with the given name. | |
GetEventOut | Returns the eventOut with the given name. | |
GetField | Returns a the field of this object whose name is fieldName. | |
GetFieldName | Returns the name of the given field in the fieldName argument. | |
GetFields | Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetMatrix | (Inherited from SoNode.) | |
GetName | Returns the name of an instance. | |
GetPrimitiveCount | (Inherited from SoNode.) | |
GetRenderEngineMode | Returns the supported Render engine mode. | |
GetRenderUnitID | (Inherited from SoNode.) | |
GetShaderType | Must be redefined by derived class. | |
GetStringName | (Inherited from SoBase.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GLRender | (Inherited from SoNode.) | |
GLRenderBelowPath | (Inherited from SoNode.) | |
GLRenderInPath | (Inherited from SoNode.) | |
GLRenderOffPath | (Inherited from SoNode.) | |
GrabEventsCleanup | (Inherited from SoNode.) | |
GrabEventsSetup | (Inherited from SoNode.) | |
HandleEvent | (Inherited from SoNode.) | |
HasDefaultValues | Returns true if all of the object's fields have their default values. | |
IsBoundingBoxIgnoring | This method is used by getBoundingBox action traversal to know if the current node must be traversed or not, ie the bounding should be ignored. | |
IsNotifyEnabled | Notification is the process of telling interested objects that this object has changed. | |
IsOverride | Returns the state of the override flag. | |
IsSynchronizable | Gets the ScaleViz synchronizable state of this object. | |
Pick | (Inherited from SoNode.) | |
RayPick | (Inherited from SoNode.) | |
Search | (Inherited from SoNode.) | |
Set | Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format. | |
SetName | (Inherited from SoBase.) | |
SetOverride | Turns the override flag on or off. | |
SetShaderParameter(String, SbVec2f) | ||
SetShaderParameter(String, SbVec2i32) | ||
SetShaderParameter(String, SbVec3f) | ||
SetShaderParameter(String, SbVec3i32) | ||
SetShaderParameter(String, SbVec4f) | ||
SetShaderParameter(String, SbVec4i32) | ||
SetShaderParameter(String, Int32) | ||
SetShaderParameter(String, Single) | ||
SetSynchronizable | Sets this to be a ScaleViz synchronizable object. | |
SetToDefaults | Sets all fields in this object to their default values. | |
ToString |
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.) | |
Touch | Marks an instance as modified, simulating a change to it. | |
Write | (Inherited from SoNode.) |
Name | Description | |
---|---|---|
isActive | Specifies if the shader object is active or not. | |
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) | |
parameter | Contains the shader's uniform parameters. | |
sourceProgram | Contains the shader object's source program, specified by a filename (OIV.Inventor.Nodes.SoShaderObject.sourceType set to OIV.Inventor.Nodes.SoShaderObject.SourceTypes.FILENAME) or by the string containing the program (OIV.Inventor.Nodes.SoShaderObject.sourceType set to OIV.Inventor.Nodes.SoShaderObject.SourceTypes.GLSL_PROGRAM). | |
sourceType | Specifies the shader object's source type. | |
UserData |
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.) |
This abstract class is the parent of classes that define a programmable graphics pipeline stage that composes a shader program.
There are five types of shader objects that can be added to a shader program. Any of these stages can be user defined.
Vertex shader The vertex shader is executed once for each vertex (usually in parallel). The main purpose is to transform each vertex's 3D position from model space to projection space. Vertex shaders can manipulate properties such as position, color and texture coordinate, but cannot create new vertices.
Tessellation control shader This shader accepts a list of vertices defined as a patch to control the amount of tessellation applied to the patch. Following the execution of this shader, a tessellator computes a set of triangles in a parametric space.
Tessellation evaluation shader This shader is executed at least once for each vertex that was created by the tesselator in the parametric space. The TES takes the parametric coordinate and the patch data output by the TCS to generate a final position for the surface.
Geometry shader The geometry shader acts on a complete primitive (triangle or line): it can modify existing primitives, it can insert (create) new primitives, it can remove (destroy) existing primitives.
Fragment shader Fragment shaders compute color and other attributes of each fragment.
Note: Compute shaders are not part of the rendering pipeline. They represent a shader stage used entirely for computing arbitrary information.
Shader object nodes cannot be inserted directly in a scene graph. They must be added to the field shaderObject of an OIV.Inventor.Nodes.SoShaderProgram node.
A shader object is defined by the following properties:
Source program, which is the shader's source code (see OIV.Inventor.Nodes.SoShaderObject.sourceProgram field),
Uniform parameters set by the application (see OIV.Inventor.Nodes.SoShaderObject.parameter field),
State (active or not) (see OIV.Inventor.Nodes.SoShaderObject.isActive field).
The source program can be specified either by a string containing the program source code, or by a filename which contains the program source code. How the sourceProgram field is interpreted depends on the field OIV.Inventor.Nodes.SoShaderObject.sourceType.
The supported shading language of the program source is OpenGL Shader Language (GLSL) . Furthermore, the Open Inventor shader API or VolumeViz shader API must be used to write any GLSL shader program. See ShaderAPI for detail.
Uniform parameters can be set through the OIV.Inventor.Nodes.SoShaderObject.parameter field. Uniform means, in the case of a vertex or geometry program, a value which is the same for all vertices in a primitive, and, in the case of a fragment program, a value which is the same for all fragments created by a primitive. Each uniform parameter is represented by an instance of a specific subclass of OIV.Inventor.Nodes.SoUniformShaderParameter. For example, an OIV.Inventor.Nodes.SoShaderParameter1i holds a single integer value. A uniform parameter has no effect if it is not valid, that is, if there is no corresponding name (identifier) in the GLSL source program. An OIV.Inventor.Nodes.SoShaderParameter1i must be used for each texture sampler in order to specify the texture unit and texture sampler uniform parameter name pair.
A vertex shader can also use vertex parameters, which are per-vertex data passed from the application to the vertex shader. Vertex parameters are represented by an instance of a specific subclass of OIV.Inventor.Nodes.SoVertexShaderParameter. For example, an OIV.Inventor.Nodes.SoVertexShaderParameter1f holds a set of floating point values and an OIV.Inventor.Nodes.SoVertexShaderParameter3f holds a set of OIV.Inventor.SbVec3f values. Vertex parameter nodes are property nodes (similar to materials or normals) and should be added directly in the scene graph, not in the shader object.
Tips:
Set the environment variable OIV_GLSL_DEBUG to get the GLSL compile/link output in the console.
If you set the environment variable OIV_SHADER_CHECK_INTERVAL, the shader source file is checked for a change every n seconds, where n is the value specified by the variable. This allows you to edit a shader source file without needing to restart your application after each shader modification.
This is an abstract class. See the reference page of a derived class for the format and default values.
Simple fragment shader with one uniform parameter:
SoFragmentShader fragmentShader = new SoFragmentShader(); fragmentShader.sourceProgram.Value = "filename.glsl"; SoShaderParameter1i parameter = new SoShaderParameter1i(); parameter.name.Value = "data1"; parameter.value.Value = 1; fragmentShader.parameter[0] = parameter; SoShaderProgram shaderProgram = new SoShaderProgram(); shaderProgram.shaderObject[0] = fragmentShader; root.AddChild(shaderProgram);