Click or drag to resize
SoShaderObject Class

Abstract node class which defines a shader object.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.1.1.0 (2024.1.1)
Syntax
public abstract class SoShaderObject : SoNode

The SoShaderObject type exposes the following members.

Methods
  NameDescription
Public methodAddShaderParameter(String, SbVec2f)
Public methodAddShaderParameter(String, SbVec2i32)
Public methodAddShaderParameter(String, SbVec3f)
Public methodAddShaderParameter(String, SbVec3i32)
Public methodAddShaderParameter(String, SbVec4f)
Public methodAddShaderParameter(String, SbVec4i32)
Public methodAddShaderParameter(String, Int32)
Public methodAddShaderParameter(String, Single)
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
(Inherited from SoNode.)
Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
(Inherited from SoNode.)
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method is called by actions to allow the node to provide an "alternate representation" when appropriate (typically depending on the action type).

(Inherited from SoNode.)
Public methodGetBoundingBox
(Inherited from SoNode.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoNode.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetPrimitiveCount
(Inherited from SoNode.)
Public methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetShaderType

Must be redefined by derived class.

Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
(Inherited from SoNode.)
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
(Inherited from SoNode.)
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsBoundingBoxIgnoring

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.

(Inherited from SoNode.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override flag.

(Inherited from SoNode.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoNode.)
Public methodRayPick
(Inherited from SoNode.)
Public methodSearch
(Inherited from SoNode.)
Public methodSet

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.

(Inherited from SoFieldContainer.)
Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Turns the override flag on or off.

(Inherited from SoNode.)
Public methodSetShaderParameter(String, SbVec2f)
Public methodSetShaderParameter(String, SbVec2i32)
Public methodSetShaderParameter(String, SbVec3f)
Public methodSetShaderParameter(String, SbVec3i32)
Public methodSetShaderParameter(String, SbVec4f)
Public methodSetShaderParameter(String, SbVec4i32)
Public methodSetShaderParameter(String, Int32)
Public methodSetShaderParameter(String, Single)
Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoNode.)
Top
Properties
  NameDescription
Public propertyisActive

Specifies if the shader object is active or not.

Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertyparameter

Contains the shader's uniform parameters.

Public propertysourceProgram
Public propertysourceType

Specifies the shader object's source type.

Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Top
Remarks

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:

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.

FILE FORMAT/DEFAULT

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

EXAMPLE

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);

See Also
Inheritance Hierarchy
SystemObject
  OIV.InventorSoNetBase
    OIV.InventorSoDisposable
      OIV.Inventor.MiscSoBase
        OIV.Inventor.FieldsSoFieldContainer
          OIV.Inventor.NodesSoNode
            OIV.Inventor.NodesSoShaderObject
              OIV.Inventor.NodesSoComputeShader
              OIV.Inventor.NodesSoFragmentShader
              OIV.Inventor.NodesSoGeometryShader
              OIV.Inventor.NodesSoTessellationControlShader
              OIV.Inventor.NodesSoTessellationEvaluationShader
              OIV.Inventor.NodesSoVertexShader