public class SoShaderProgram extends SoNode
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:
SoGetBoundingBoxAction
, SoGetPrimitiveCountAction
and SoRayPickAction
.
Tips:
generateTransparency
field to true. This ensures that Open Inventor knows to apply the correct handling for the current transparency mode.
SoInput
and respect the same search path order. For example:
File format/default://!oiv_include <MyShaderDirectory/common.h>
shaderObject | NULL |
geometryInputType | TRIANGLES_INPUT |
geometryOutputType | TRIANGLE_STRIP_OUTPUT |
vertexProgramTwoSide | false |
shadowShader | false |
maxGeometryOutputVertices | -1 |
generateTransparency | false |
patchLength | 0 |
Shader program with one fragment shader with one uniform parameter.
// Simple fragment shader with one uniform parameter // First load the fragment shader code SoFragmentShader fragmentShader = new SoFragmentShader(); fragmentShader.sourceProgram.setValue( "filename.glsl" ); // Set the shader parameter SoShaderParameter1i parameter = new SoShaderParameter1i(); parameter.name.setValue( "data1" ); parameter.value.setValue( 1 ); fragmentShader.parameter.set1Value( 0, parameter ); // Associate fragment shader with a shader program node SoShaderProgram shaderProgram = new SoShaderProgram(); shaderProgram.shaderObject.set1Value( 0, fragmentShader ); root.addChild(shaderProgram);
Action behavior:
SoGLRenderAction
Sets the Open Inventor state with the active shader program. Sets: SoGLShaderProgramElement
See also:
SoFragmentShader
, SoGeometryShader
, SoShaderObject
, SoTessellationControlShader
, SoTessellationEvaluationShader
, SoUniformShaderParameter
, SoVertexShader
, SoVertexShaderParameter
Modifier and Type | Class and Description |
---|---|
static class |
SoShaderProgram.GeometryInputTypes
Geometry input type.
|
static class |
SoShaderProgram.GeometryOutputTypes
Geometry ouput type.
|
SoNode.RenderModes
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoMFNode |
bufferObjects
Specifies a list of
SoShaderParameterBufferObject to use with this shader. |
SoSFBool |
generateTransparency
If set to true, then shapes affected by this shader will be considered transparent.
|
SoSFEnum<SoShaderProgram.GeometryInputTypes> |
geometryInputType
Specifies the input primitive type of the current geometry shader if any (not used otherwise).
|
SoSFEnum<SoShaderProgram.GeometryOutputTypes> |
geometryOutputType
Specifies the output primitive type of the current geometry shader if any (not used otherwise).
|
SoSFInt32 |
maxGeometryOutputVertices
Set the maximum number of vertices the geometry shader will emit in one invocation.
|
SoSFInt32 |
patchLength
Set the length of the fixed-size collection of vertices used by tessellation shaders.
|
SoMFNode |
shaderObject
Specifies the list of shader objects (i.e., vertex shaders, geometry and fragment shaders) which form the shader program.
|
SoSFBool |
shadowShader
Only used when an
SoShadowGroup is active. |
SoSFBool |
vertexProgramTwoSide
If set to true, vertex shaders will operate in two-sided color mode.
|
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoShaderProgram()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
SoFragmentShader |
getFragmentShader(int pos)
Returns the fragment shader at the specified position.
|
SoGeometryShader |
getGeometryShader(int pos)
Returns the geometry shader at the specified position.
|
static int |
getNumReservedTextures()
Returns the number of reserved texture units.
|
SoTessellationControlShader |
getTessellationControlShader(int pos)
Returns the tessellation control shader at the specified position.
|
SoTessellationEvaluationShader |
getTessellationEvaluationShader(int pos)
Returns the tessellation evaluation shader at the specified position.
|
SoVertexShader |
getVertexShader(int pos)
Returns the vertex shader at the specified position.
|
SoFragmentShader |
setFragmentShader(int pos,
java.lang.String filenameOrSource)
Calls setFragmentShader(pos, filenameOrSource, SoShaderObject.SourceTypes.valueOf( SoShaderObject.SourceTypes.FILENAME.getValue() )).
|
SoFragmentShader |
setFragmentShader(int pos,
java.lang.String filenameOrSource,
SoShaderObject.SourceTypes sourceType)
Convenience method to create a fragment shader with the specified filename and add it at the specified position.
|
SoGeometryShader |
setGeometryShader(int pos,
java.lang.String filenameOrSource)
Calls setGeometryShader(pos, filenameOrSource, SoShaderObject.SourceTypes.valueOf( SoShaderObject.SourceTypes.FILENAME.getValue() )).
|
SoGeometryShader |
setGeometryShader(int pos,
java.lang.String filenameOrSource,
SoShaderObject.SourceTypes sourceType)
Convenience method to create a geometry shader with the specified filename and add it at the specified position.
|
SoTessellationControlShader |
setTessellationControlShader(int pos,
java.lang.String filenameOrSource)
Calls setTessellationControlShader(pos, filenameOrSource, SoShaderObject.SourceTypes.valueOf( SoShaderObject.SourceTypes.FILENAME.getValue() )).
|
SoTessellationControlShader |
setTessellationControlShader(int pos,
java.lang.String filenameOrSource,
SoShaderObject.SourceTypes sourceType)
Convenience method to create a tessellation control shader with the specified filename and add it at the specified position.
|
SoTessellationEvaluationShader |
setTessellationEvaluationShader(int pos,
java.lang.String filenameOrSource)
Calls setTessellationEvaluationShader(pos, filenameOrSource, SoShaderObject.SourceTypes.valueOf( SoShaderObject.SourceTypes.FILENAME.getValue() )).
|
SoTessellationEvaluationShader |
setTessellationEvaluationShader(int pos,
java.lang.String filenameOrSource,
SoShaderObject.SourceTypes sourceType)
Convenience method to create a tessellation evaluation shader with the specified filename and add it at the specified position.
|
SoVertexShader |
setVertexShader(int pos,
java.lang.String filenameOrSource)
Calls setVertexShader(pos, filenameOrSource, SoShaderObject.SourceTypes.valueOf( SoShaderObject.SourceTypes.FILENAME.getValue() )).
|
SoVertexShader |
setVertexShader(int pos,
java.lang.String filenameOrSource,
SoShaderObject.SourceTypes sourceType)
Convenience method to create a vertex shader with the specified filename and add it at the specified position.
|
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, getRenderEngineMode, getRenderUnitID, GLRender, GLRenderBelowPath, GLRenderInPath, GLRenderOffPath, grabEventsCleanup, grabEventsSetup, handleEvent, isBoundingBoxIgnoring, isOverride, pick, rayPick, search, setOverride, touch, write
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable
getNativeResourceHandle
public final SoMFNode shaderObject
public final SoSFEnum<SoShaderProgram.GeometryInputTypes> geometryInputType
GeometryInputType
. Default is TRIANGLES_INPUT.
public final SoSFEnum<SoShaderProgram.GeometryOutputTypes> geometryOutputType
GeometryOutputType
. Default is TRIANGLE_STRIP_OUTPUT.
public final SoSFBool vertexProgramTwoSide
public final SoSFBool shadowShader
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:
SoShadowGroup
public final SoSFInt32 maxGeometryOutputVertices
public final SoSFBool generateTransparency
This allows Open Inventor to apply the correct handling for the current transparency mode.
Default is false.
public final SoSFInt32 patchLength
public final SoMFNode bufferObjects
SoShaderParameterBufferObject
to use with this shader.
Default is empty.
public SoFragmentShader setFragmentShader(int pos, java.lang.String filenameOrSource)
public SoTessellationControlShader setTessellationControlShader(int pos, java.lang.String filenameOrSource)
public SoTessellationEvaluationShader setTessellationEvaluationShader(int pos, java.lang.String filenameOrSource)
public SoVertexShader setVertexShader(int pos, java.lang.String filenameOrSource)
public SoGeometryShader setGeometryShader(int pos, java.lang.String filenameOrSource)
public static int getNumReservedTextures()
public SoTessellationEvaluationShader getTessellationEvaluationShader(int pos)
public SoGeometryShader setGeometryShader(int pos, java.lang.String filenameOrSource, SoShaderObject.SourceTypes sourceType)
public SoVertexShader setVertexShader(int pos, java.lang.String filenameOrSource, SoShaderObject.SourceTypes sourceType)
public SoTessellationControlShader getTessellationControlShader(int pos)
public SoTessellationControlShader setTessellationControlShader(int pos, java.lang.String filenameOrSource, SoShaderObject.SourceTypes sourceType)
public SoTessellationEvaluationShader setTessellationEvaluationShader(int pos, java.lang.String filenameOrSource, SoShaderObject.SourceTypes sourceType)
public SoFragmentShader getFragmentShader(int pos)
public SoVertexShader getVertexShader(int pos)
public SoFragmentShader setFragmentShader(int pos, java.lang.String filenameOrSource, SoShaderObject.SourceTypes sourceType)
public SoGeometryShader getGeometryShader(int pos)
Generated on July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com