Abstract node class which defines a shader object. More...
#include <Inventor/nodes/SoShaderObject.h>
Public Types | |
enum | SourceType { ARB_PROGRAM , CG_PROGRAM , GLSL_PROGRAM , FILENAME } |
Shader Object source type possible values. More... | |
enum | ShaderType { VERTEX_SHADER = SbEnums::SHADER_TYPE_VERTEX , GEOMETRY_SHADER = SbEnums::SHADER_TYPE_GEOMETRY , FRAGMENT_SHADER = SbEnums::SHADER_TYPE_FRAGMENT , TESSELLATION_CONTROL_SHADER = SbEnums::SHADER_TYPE_TESS_CTRL , TESSELLATION_EVALUATION_SHADER = SbEnums::SHADER_TYPE_TESS_EVAL , COMPUTE_SHADER = SbEnums::SHADER_TYPE_COMPUTE } |
Type of the shader. More... | |
Public Member Functions | |
virtual SoType | getTypeId () const |
Returns the type identifier for this specific instance. | |
template<typename UniformParamType , typename ParamValueType > | |
UniformParamType * | addShaderParameter (const SbString &name, ParamValueType val) |
Convenience method to create an SoShaderUniformParameter with the specified name and value and add it to the given shader object. | |
virtual ShaderType | getShaderType () const =0 |
Must be redefined by derived class. | |
template<typename UniformParamType , typename ParamValueType > | |
void | setShaderParameter (const SbString &name, ParamValueType val) |
UniformParamType is the type of parameter to set. | |
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 SoNode * | copy (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 SoField * | getField (const SbName &fieldName) const |
Returns a the field of this object whose name is fieldName. | |
virtual SoField * | getEventIn (const SbName &fieldName) const |
Returns a the eventIn with the given name. | |
virtual SoField * | getEventOut (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 Public Member Functions inherited from SoNode | |
static SoType | getClassTypeId () |
Returns the type identifier for this class. | |
static SoNode * | getByName (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 | |
SoSFBool | isActive |
Specifies if the shader object is active or not. | |
SoSFEnum | sourceType |
Specifies the shader object's source type. | |
SoSFFilePathString | sourceProgram |
Contains the shader object's source program, specified by a filename (sourceType set to FILENAME) or by the string containing the program (sourceType set to GLSL_PROGRAM). | |
SoMFUniformShaderParameter | parameter |
Contains the shader's uniform parameters. | |
Friends | |
class | SoShaderProgram |
Abstract node class which defines a shader object.
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.
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 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 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 Shaders for detail.
Uniform parameters can be set through the 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 SoUniformShaderParameter. For example, an 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 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 SoVertexShaderParameter. For example, an SoVertexShaderParameter1f holds a set of floating point values and an SoVertexShaderParameter3f holds a set of 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:
Shaders, SoVertexShader, SoGeometryShader, SoFragmentShader, SoShaderProgram, SoShaderParameter, SoUniformShaderParameter, SoVertexShaderParameter, SoTessellationControlShader, SoTessellationEvaluationShader
Definition at line 204 of file SoShaderObject.h.
Type of the shader.
Definition at line 295 of file SoShaderObject.h.
Shader Object source type possible values.
Definition at line 212 of file SoShaderObject.h.
UniformParamType * SoShaderObject::addShaderParameter | ( | const SbString & | name, |
ParamValueType | val | ||
) |
Convenience method to create an SoShaderUniformParameter with the specified name and value and add it to the given shader object.
UniformParamType is the type of parameter to add. This function also generates the following helper methods not visible in the documentation:
These are template methods, so ParamValueType must have an operator= compatible with the field value of the corresponding SoShaderParameter (for example, addShaderParameter2f can take an SbVec2f as ParamValueType)
Definition at line 601 of file SoShaderObject.h.
|
static |
Returns the type identifier for this class.
|
pure virtual |
Must be redefined by derived class.
Implemented in SoComputeShader, SoFragmentShader, SoGeometryShader, SoTessellationControlShader, SoTessellationEvaluationShader, and SoVertexShader.
|
virtual |
Returns the type identifier for this specific instance.
Reimplemented from SoNode.
Reimplemented in SoComputeShader, SoFragmentShader, SoGeometryShader, SoTessellationControlShader, SoTessellationEvaluationShader, and SoVertexShader.
void SoShaderObject::setShaderParameter | ( | const SbString & | name, |
ParamValueType | val | ||
) |
UniformParamType is the type of parameter to set.
This function also generates the following helper methods not visible in the documentation:
These are template methods, so ParamValueType must have an operator= compatible with the field value of the corresponding SoShaderParameter (for example, setShaderParameter2f can take an SbVec2f as ParamValueType).
Definition at line 623 of file SoShaderObject.h.
|
friend |
Definition at line 486 of file SoShaderObject.h.
SoSFBool SoShaderObject::isActive |
Specifies if the shader object is active or not.
Definition at line 240 of file SoShaderObject.h.
SoMFUniformShaderParameter SoShaderObject::parameter |
Contains the shader's uniform parameters.
Definition at line 273 of file SoShaderObject.h.
SoSFFilePathString SoShaderObject::sourceProgram |
Contains the shader object's source program, specified by a filename (sourceType set to FILENAME) or by the string containing the program (sourceType set to GLSL_PROGRAM).
If the filename is not an absolute path name, the list of directories maintained by SoInput is searched. If the source program is not found in any of those directories, then the file is searched for relative to the directory from which the SoShaderObject node was read.
NOTE: The source type (sourceType) must be specified before the source program is specified.
Definition at line 267 of file SoShaderObject.h.
SoSFEnum SoShaderObject::sourceType |
Specifies the shader object's source type.
The type of source can be either a filename containing the program (FILENAME), or a string containing the source program (GLSL_PROGRAM). Use enum SourceType. Default is FILENAME.
NOTE: The source type must be specified before the source program (sourceProgram) is specified.
Definition at line 251 of file SoShaderObject.h.