Shader program property node. More...
#include <Inventor/nodes/SoShaderProgram.h>
This property node defines the complete shader program for all subsequent shapes. A complete shader program may contain vertex shaders (SoVertexShader), geometry shaders (SoGeometryShader) and/or fragment shaders (SoFragmentShaders). See SoShaderObject for information common to all these classes.
With some languages such as NVIDIA Cg or assembly language (ARB_vertex_program/ARB_fragment_program), only one vertex and one fragment program can be active at the same time. The field shaderObject contains the vertex, geometry and fragment shader objects which form the shader program. Each shader object should be of type SoShaderObject. Modifications that occur in shader objects are dynamically detected and the state is updated.
Uniform parameters may be set for each shader object. 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.
Vertex parameters may be set for a vertex shader object. Vertex parameters 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.
SoShaderProgram has specialized subclasses for volume visualization. If you are using the VolumeViz extension, see SoVolumeShader and SoVolumeRenderingQuality nodes.
Notes:
Tips:
//!oiv_include <MyShaderDirectory/common.h>
shaderObject | NULL |
geometryInputType | TRIANGLES_INPUT |
geometryOutputType | TRIANGLE_STRIP_OUTPUT |
vertexProgramTwoSide | FALSE |
shadowShader | FALSE |
maxGeometryOutputVertices | -1 |
generateTransparency | FALSE |
patchLength | 0 |
// First load the fragment shader code SoFragmentShader* fragmentShader = new SoFragmentShader(); fragmentShader->sourceProgram = "filename.glsl"; // Set a shader parameter // The addShaderParameter1i method is equivalent to: // SoShaderParameter1i *parameter = new SoShaderParameter1i; // parameter->name = "data1"; // parameter->value = 1; // fragmentShader->parameter.set1Value(0, parameter); fragmentShader->addShaderParameter1i( "data1", 1 ); // Associate fragment shader with a shader program node SoShaderProgram* shaderProgram = new SoShaderProgram(); shaderProgram->shaderObject.set1Value(0, fragmentShader); root->addChild( shaderProgram );
SoFragmentShader, SoGeometryShader, SoShaderObject, SoTessellationControlShader, SoTessellationEvaluationShader, SoUniformShaderParameter, SoVertexShader, SoVertexShaderParameter
GPUGeometry, InterleavedVertexAttribFeedback, SimpleVertexAttribFeedback, VertexAttribFeedback, PointCloud, AnimatedFlag, GeometryShader, PixelLighting, shadowShader, SimplePassthrough, TessellationShader, ToonShading, ShadersBrowser, MultiTransferFunctions
Geometry input type.
Used with field geometryInputType.
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. |
Geometry ouput type.
Used with field geometryOutputType.
SoShaderProgram::SoShaderProgram | ( | ) |
Constructor.
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.
static SoType SoShaderProgram::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoNode.
Reimplemented in SoVolumeIsosurface, SoVolumeRenderingQuality, and SoVolumeShader.
SoFragmentShader * SoShaderProgram::getFragmentShader | ( | int | pos | ) | const [inline] |
Returns the fragment shader at the specified position.
SoGeometryShader * SoShaderProgram::getGeometryShader | ( | int | pos | ) | const [inline] |
Returns the geometry shader at the specified position.
static unsigned int SoShaderProgram::getNumReservedTextures | ( | ) | [static] |
Returns the number of reserved texture units.
SoTessellationControlShader * SoShaderProgram::getTessellationControlShader | ( | int | pos | ) | const [inline] |
Returns the tessellation control shader at the specified position.
SoTessellationEvaluationShader * SoShaderProgram::getTessellationEvaluationShader | ( | int | pos | ) | const [inline] |
Returns the tessellation evaluation shader at the specified position.
virtual SoType SoShaderProgram::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoNode.
Reimplemented in SoVolumeIsosurface, SoVolumeRenderingQuality, and SoVolumeShader.
SoVertexShader * SoShaderProgram::getVertexShader | ( | int | pos | ) | const [inline] |
Returns the vertex shader at the specified position.
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.
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.
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.
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.
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.
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.
friend class SoUniformShaderParameter [friend] |
Specifies a list of SoShaderParameterBufferObject to use with this shader.
Default is empty. NOTE: field available since Open Inventor 9.8
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.0Specifies 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.0Specifies 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.0Specifies a list of SoShaderParameterImage nodes to use with this shader.
Default is empty. NOTE: field available since Open Inventor 10.10
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.1Set the length of the fixed-size collection of vertices used by tessellation shaders.
Default is 0.
NOTE: field available since Open Inventor 9.3Specifies 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.
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 set to TRUE, vertex shaders will operate in two-sided color mode.
Default is FALSE.
NOTE: field available since Open Inventor 7.2