Open Inventor Release 2024.1.0
 
Loading...
Searching...
No Matches
SoShaderProgram Class Reference

VSG extension Shader program property node. More...

#include <Inventor/nodes/SoShaderProgram.h>

+ Inheritance diagram for SoShaderProgram:

Public Types

enum  GeometryInputType {
  POINTS_INPUT = GL_POINTS ,
  LINES_INPUT = GL_LINES ,
  TRIANGLES_INPUT = GL_TRIANGLES
}
 Geometry input type. More...
 
enum  GeometryOutputType {
  POINTS_OUTPUT = GL_POINTS ,
  LINE_STRIP_OUTPUT = GL_LINE_STRIP ,
  TRIANGLE_STRIP_OUTPUT = GL_TRIANGLE_STRIP
}
 Geometry ouput type. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoShaderProgram ()
 Constructor.
 
SoFragmentShadergetFragmentShader (int pos) const
 Returns the fragment shader at the specified position.
 
SoVertexShadergetVertexShader (int pos) const
 Returns the vertex shader at the specified position.
 
SoGeometryShadergetGeometryShader (int pos) const
 Returns the geometry shader at the specified position.
 
virtual SoFragmentShadersetFragmentShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a fragment shader with the specified filename and add it at the specified position.
 
virtual SoVertexShadersetVertexShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a vertex shader with the specified filename and add it at the specified position.
 
virtual SoGeometryShadersetGeometryShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a geometry shader with the specified filename and add it at the specified position.
 
virtual SoComputeShadersetComputeShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a compute shader with the specified filename and add it at the specified position.
 
SoTessellationControlShadergetTessellationControlShader (int pos) const
 Returns the tessellation control shader at the specified position.
 
SoTessellationEvaluationShadergetTessellationEvaluationShader (int pos) const
 Returns the tessellation evaluation shader at the specified position.
 
virtual SoTessellationControlShadersetTessellationControlShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a tessellation control shader with the specified filename and add it at the specified position.
 
virtual SoTessellationEvaluationShadersetTessellationEvaluationShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a tessellation evaluation shader with the specified filename and add it at the specified position.
 
SoShaderParameterImageaddShaderParameterImage (const SbString &name, SoTexture *tex)
 Convenience method to create an SoShaderParameterImage with the specified name and value and add it to this shader program.
 
- Public Member Functions inherited from SoNode
virtual void setOverride (const SbBool state)
 Turns the override flag on or off.
 
virtual SbBool isOverride () const
 Returns the state of the override flag.
 
virtual SoNodecopy (SbBool copyConnections=FALSE) const
 Creates and returns an exact copy of the node.
 
virtual SbBool affectsState () const
 Returns TRUE if a node has an effect on the state during traversal.
 
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 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.
 
SbBool set (const SbString &fieldDataString)
 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.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static unsigned int getNumReservedTextures ()
 Returns the number of reserved texture units.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (const SbName &name)
 A node's name can be set using SoBase::setName().
 
static int getByName (const SbName &name, SoNodeList &list)
 A node's name can be set using SoBase::setName().
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Public Attributes

SoMFNode shaderObject
 Specifies the list of shader objects (i.e., vertex shaders, geometry and fragment shaders) which form the shader program.
 
SoSFEnum geometryInputType
 Specifies the input primitive type of the current geometry shader if any (not used otherwise).
 
SoSFEnum geometryOutputType
 Specifies the output primitive type of the current geometry shader if any (not used otherwise).
 
SoSFBool vertexProgramTwoSide
 If set to TRUE, vertex shaders will operate in two-sided color mode.
 
SoSFBool shadowShader
 Only used when an SoShadowGroup is active.
 
SoSFInt32 maxGeometryOutputVertices
 Set the maximum number of vertices the geometry shader will emit in one invocation.
 
SoSFBool generateTransparency
 If set to TRUE, then shapes affected by this shader will be considered transparent.
 
SoSFInt32 patchLength
 Set the length of the fixed-size collection of vertices used by tessellation shaders.
 
SoMFNode bufferObjects
 Specifies a list of SoShaderParameterBufferObject to use with this shader.
 
SoMFNode images
 Specifies a list of SoShaderParameterImage nodes to use with this shader.
 

Friends

class SoUniformShaderParameter
 

Detailed Description

VSG extension Shader program property node.

This property node defines the complete shader program for all subsequent shapes. A shader program may contain any graphics pipeline stage defined by the derivatives of a SoShaderObject. These stage programs are stored in the field shaderObject. Any Modifications that occur in the shader objects are dynamically detected and the state is updated.

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 Shaders for detail.

Uniform shader parameters can be set per shader object and are available for all pipeline stages of the shader program. Uniform means a constant value during the shader execution. A uniform parameter is represented by an instance of a specific subclass of SoUniformShaderParameter. For example, an SoShaderParameter1i holds a single integer value.

Vertex parameters can be accessible from a vertex shader object. Vertex parameters are per-vertex data passed from the application to the vertex shader. A vertex parameter is represented by an instance of a specific subclass of SoVertexShaderParameter. For example, an SoVertexShaderParameter1f holds a set of floating point values and an SoVertexShaderParameter3f holds a set of SbVec3f values.

SoShaderProgram has specialized subclasses for volume visualization. If you are using the VolumeViz extension, see SoVolumeShader and SoVolumeRenderingQuality nodes.

Notes:

Tips:

  • To see the output from the GLSL compiler/linker, set the environment variable OIV_GLSL_DEBUG.
  • 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 the shader source code without needing to restart your application after each shader modification.
  • If your shader makes geometry transparent (sets alpha values < 1), you should set the generateTransparency field to TRUE. This ensures that Open Inventor knows to apply the correct handling for the current transparency mode.
  • Since the GLSL specification doesn't currently provide a "#include" directive, Open Inventor provides this service through the comment directive "//!oiv_include". This provides greater flexibility in implementing complex GLSL shaders. Included files are loaded using SoInput and respect the same search path order. For example:

FILE FORMAT/DEFAULT

EXAMPLE

ACTION BEHAVIOR

    SoGLRenderAction
    Sets the Open Inventor state with the active shader program. Sets: SoGLShaderProgramElement

SEE ALSO

Shaders, SoFragmentShader, SoGeometryShader, SoShaderObject, SoTessellationControlShader, SoTessellationEvaluationShader, SoUniformShaderParameter, SoVertexShader, SoVertexShaderParameter

Definition at line 231 of file SoShaderProgram.h.

Member Enumeration Documentation

◆ GeometryInputType

Geometry input type.

Used with field geometryInputType.

Enumerator
POINTS_INPUT 

The input geometry should be interpreted as points.

Geometry shaders that operate on points are valid only for the SoPointSet and SoIndexedPointSet nodes. There is only a single vertex available for each geometry shader invocation.

LINES_INPUT 

The input geometry should be interpreted as lines.

Geometry shaders that operate on line segments are valid only for the SoLineSet or SoIndexedLineSet nodes. There are two vertices available for each geometry shader invocation. The first vertex refers to the vertex at the beginning of the line segment and the second vertex refers to the vertex at the end of the line segment.

TRIANGLES_INPUT 

The input geometry should be interpreted as triangles.

Geometry shaders that operate on triangles are valid only for geometry nodes that generate triangles, for example, SoTriangleStripSet. There are three vertices available for each program invocation. The first, second and third vertices refer to attributes of the first, second and third vertex of the triangle, respectively. Default.

Definition at line 239 of file SoShaderProgram.h.

◆ GeometryOutputType

Geometry ouput type.

Used with field geometryOutputType.

Enumerator
POINTS_OUTPUT 
LINE_STRIP_OUTPUT 
TRIANGLE_STRIP_OUTPUT 

Default.

Definition at line 273 of file SoShaderProgram.h.

Constructor & Destructor Documentation

◆ SoShaderProgram()

SoShaderProgram::SoShaderProgram ( )

Constructor.

Member Function Documentation

◆ addShaderParameterImage()

SoShaderParameterImage * SoShaderProgram::addShaderParameterImage ( const SbString name,
SoTexture tex 
)

Convenience method to create an SoShaderParameterImage with the specified name and value and add it to this shader program.

◆ getClassTypeId()

static SoType SoShaderProgram::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getFragmentShader()

SoFragmentShader * SoShaderProgram::getFragmentShader ( int  pos) const
inline

Returns the fragment shader at the specified position.

Definition at line 782 of file SoShaderProgram.h.

◆ getGeometryShader()

SoGeometryShader * SoShaderProgram::getGeometryShader ( int  pos) const
inline

Returns the geometry shader at the specified position.

Definition at line 812 of file SoShaderProgram.h.

◆ getNumReservedTextures()

static unsigned int SoShaderProgram::getNumReservedTextures ( )
static

Returns the number of reserved texture units.

◆ getTessellationControlShader()

SoTessellationControlShader * SoShaderProgram::getTessellationControlShader ( int  pos) const
inline

Returns the tessellation control shader at the specified position.

Definition at line 827 of file SoShaderProgram.h.

◆ getTessellationEvaluationShader()

SoTessellationEvaluationShader * SoShaderProgram::getTessellationEvaluationShader ( int  pos) const
inline

Returns the tessellation evaluation shader at the specified position.

Definition at line 842 of file SoShaderProgram.h.

◆ getTypeId()

virtual SoType SoShaderProgram::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoNode.

Reimplemented in SoVolumeIsosurface, SoVolumeRenderingQuality, and SoVolumeShader.

◆ getVertexShader()

SoVertexShader * SoShaderProgram::getVertexShader ( int  pos) const
inline

Returns the vertex shader at the specified position.

Definition at line 797 of file SoShaderProgram.h.

◆ setComputeShader()

virtual SoComputeShader * SoShaderProgram::setComputeShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a compute shader with the specified filename and add it at the specified position.

Return value is the new compute shader.

◆ setFragmentShader()

virtual SoFragmentShader * SoShaderProgram::setFragmentShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a fragment shader with the specified filename and add it at the specified position.

Return value is the new fragment shader.

Reimplemented in SoVolumeShader.

◆ setGeometryShader()

virtual SoGeometryShader * SoShaderProgram::setGeometryShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a geometry shader with the specified filename and add it at the specified position.

Return value is the new geometry shader.

◆ setTessellationControlShader()

virtual SoTessellationControlShader * SoShaderProgram::setTessellationControlShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a tessellation control shader with the specified filename and add it at the specified position.

Return value is the new tessellation control shader.

◆ setTessellationEvaluationShader()

virtual SoTessellationEvaluationShader * SoShaderProgram::setTessellationEvaluationShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a tessellation evaluation shader with the specified filename and add it at the specified position.

Return value is the new tessellation evaluation shader.

◆ setVertexShader()

virtual SoVertexShader * SoShaderProgram::setVertexShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Convenience method to create a vertex shader with the specified filename and add it at the specified position.

Return value is the new vertex shader.

Reimplemented in SoVolumeShader.

Friends And Related Symbol Documentation

◆ SoUniformShaderParameter

friend class SoUniformShaderParameter
friend

Definition at line 776 of file SoShaderProgram.h.

Member Data Documentation

◆ bufferObjects

SoMFNode SoShaderProgram::bufferObjects

Specifies a list of SoShaderParameterBufferObject to use with this shader.

Default is empty. NOTE: field available since Open Inventor 9.8

Definition at line 368 of file SoShaderProgram.h.

◆ generateTransparency

SoSFBool SoShaderProgram::generateTransparency

If set to TRUE, then shapes affected by this shader will be considered transparent.

Otherwise, the shape transparency is deducted from the state.

This allows Open Inventor to apply the correct handling for the current transparency mode.

Default is FALSE.

NOTE: field available since Open Inventor 9.0

Definition at line 353 of file SoShaderProgram.h.

◆ geometryInputType

SoSFEnum SoShaderProgram::geometryInputType

Specifies the input primitive type of the current geometry shader if any (not used otherwise).

Use enum GeometryInputType. Default is TRIANGLES_INPUT.

NOTE: field available since Open Inventor 7.0

Definition at line 297 of file SoShaderProgram.h.

◆ geometryOutputType

SoSFEnum SoShaderProgram::geometryOutputType

Specifies the output primitive type of the current geometry shader if any (not used otherwise).

Use enum GeometryOutputType. Default is TRIANGLE_STRIP_OUTPUT.

NOTE: field available since Open Inventor 7.0

Definition at line 305 of file SoShaderProgram.h.

◆ images

SoMFNode SoShaderProgram::images

Specifies a list of SoShaderParameterImage nodes to use with this shader.

Default is empty. NOTE: field available since Open Inventor 10.10

Definition at line 375 of file SoShaderProgram.h.

◆ maxGeometryOutputVertices

SoSFInt32 SoShaderProgram::maxGeometryOutputVertices

Set the maximum number of vertices the geometry shader will emit in one invocation.

Default is -1 which means it is set to the hardware limit.

NOTE: field available since Open Inventor 8.1

Definition at line 340 of file SoShaderProgram.h.

◆ patchLength

SoSFInt32 SoShaderProgram::patchLength

Set the length of the fixed-size collection of vertices used by tessellation shaders.

Default is 0.

NOTE: field available since Open Inventor 9.3

Definition at line 361 of file SoShaderProgram.h.

◆ shaderObject

SoMFNode SoShaderProgram::shaderObject

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

Be careful, with some languages (CG_PROGRAM or ARB_PROGRAM), only one vertex program and one fragment program can be active at the same time. In this case, only the first vertex shader and the first fragment shader are used.

Definition at line 289 of file SoShaderProgram.h.

◆ shadowShader

SoSFBool SoShaderProgram::shadowShader

Only used when an SoShadowGroup is active.

Default is FALSE. If set to FALSE, a default shader will be used during the shadowmap generation pass. If TRUE, the shader will be used as is and must handle the shadowmap pass correctly:

  • If the uniform OivShadowPass is true, call OivGenerateShadowMap() and output nothing into gl_FragColor, but discard fragments if needed.
  • If the uniform OivShadowPass is false, follow the normal render path If the shader doesn't modify the depth (with a discard or an alpha test), Open Inventor will handle the shadowmap generation pass automatically. Default is FALSE
    See also: SoShadowGroup

NOTE: field available since Open Inventor 8.1

Definition at line 332 of file SoShaderProgram.h.

◆ vertexProgramTwoSide

SoSFBool SoShaderProgram::vertexProgramTwoSide

If set to TRUE, vertex shaders will operate in two-sided color mode.

Default is FALSE.

NOTE: field available since Open Inventor 7.2

Definition at line 313 of file SoShaderProgram.h.


The documentation for this class was generated from the following file: