public class SoVolumeShader extends SoShaderProgram
SoShaderProgram
and behaves in similar way. It allows you to supply custom shaders for all VolumeViz rendering shapes (SoVolumeRender
, SoOrthoSlice
, etc.).
Note: GLSL is the only shading language supported by this node.
SoVolumeShader
fields provide different pre-implemented rendering effect options, but the application is free to redefine some stages of the VolumeViz shader pipeline by inserting GLSL shader functions in the shaderObject
field (inherited from SoShaderProgram
). The shaderObject multi-field contains only application redefined shaders. The position of a shader in the multi-field explicitly specifies the pipeline shader stage to redefine. Customizable stages are described below in the ShaderPosition
enum. For example, a seismic application could implement co-blending of multiple volumes by supplying a replacement for the VVizComputeFragmentColor() function in the FRAGMENT_COMPUTE_COLOR position of the shaderObject field.
Note: The advanced rendering options, e.g. lighting, are provided by the SoVolumeRenderingQuality
node (a subclass of SoVolumeShader
). Generally if an application wants to redefine a stage of the shader pipeline but still be able to use these advanced options, it should create an SoVolumeRenderingQuality
node and set the replacement shader functions in the shaderObject field of that node.
VolumeViz provides a shader pipeline API composed of GLSL functions that are automatically loaded. This allows the application to modify existing effects or add new effects with a minimum of new code. The VolumeViz GLSL shader pipeline API is described in the VolumeVizShaders document.
Use the forVolumeOnly
field to specify if the shader is to be used for volume rendering or for non-volume rendering (slice, volume geometry, etc). In some cases it may be possible to use the same shader source for both volume and non-volume rendering. However the application still must create two shader nodes, one with the forVolumeOnly
field set to true and one with it set to false, even if both nodes load the same shader source file. (This is necessary because the shader source must be compiled with different parameters for the different cases.)
No more than one SoVolumeShader
(or derived class) can be used with one volume visualization node, e.g. SoVolumeRender
. Since SoVolumeIsosurface
and SoVolumeRenderingQuality
are derived from this class, only one (or none) of these three nodes can be used at the same time. Exception: Since Open Inventor 7.1 it is possible to use both SoVolumeRenderingQuality
and SoVolumeIsosurface
with SoVolumeRender
.
Remember that this is an SoShaderProgram
node. The effect will usually be undesirable if it is applied to non-VolumeViz geometry (polygons, lines, etc). Therefore applications should generally keep the volume visualization nodes and standard geometry nodes separate in the scene graph (i.e. under different SoSeparator
nodes).
Reserved texture units:
Because some rendering methods need to create and use special textures, some texture units must be reserved for internal use. The application can specify which texture units VolumeViz should use by setting environment variables (see SoPreferences
). The texture units between OIV_FIRST_RESERVED_TEXTURE_UNIT and OIV_FIRST_RESERVED_TEXTURE_UNIT+SoShaderProgram.getNumReservedTextures()-1 inclusive are reserved for internal VolumeViz use. If OIV_FIRST_RESERVED_TEXTURE_UNIT is not set, its default value is SoFragmentShader.getMaxTextureImageUnit()
- SoShaderProgram.getNumReservedTextures()
. Note: The value returned by SoShaderProgram.getNumReservedTextures()
may change between VolumeViz versions. The total number of available texture units depends on the graphics hardware.
Limitations:
Only graphics cards supporting the GLSL language can use this node.
Shader filenames beginning with "vviz" are reserved.
Filenames set in a public slot with this prefix will be ignored.
Fragment shaders must not use the GLSL discard keyword when volume rendering is using the ray casting algorithm (the default since v9.0). If discard is used, the rendering will be incorrect. If a fragment should not affect the frame buffer, set it to completely transparent. If you are discarding fragments in the #VVizGetData() function (i.e. before assigning color), then you must reserve one entry in the color map to be completely transparent and return the appropriate data value. The easiest way to do this is to make the first color map entry transparent, either explicitly or by setting the SoTransferFunction
node's
minValue field to 1. Because the VVizGetData() works with normalized data values in the range 0..1, returning 0 will select the transparent entry regardless of the actual data range.
Note: Since the GLSL specification doesn't currently allow the use of an include directive, Open Inventor provides this service through a comment directive. This provides greater flexibility in implementing complex GLSL shaders. Included files are loaded using SoInput
and use the same search path order.
//!oiv_include <VolumeViz/vvizCombine_frag.h>
The VolumeViz shader API is described in VolumeVizShaders.
Available vertex program functions are described in VolumeVizVertexShaders.
Available fragment program functions are described in VolumeVizFragmentShaders.
Available constants, macros and data structures are described in VolumeVizShadersData.
Load a fragment shader in the COMPUTE_COLOR slot.
// Create an SoVolumeData node SoVolumeData volData = new SoVolumeData(); volData.dataSetId.setValue( 1 ); volSep.addChild( volData ); // Create an integer uniform parameter for the dataSetId SoShaderParameter1i paramTex1 = new SoShaderParameter1i(); paramTex1.name.setValue( "dataId1" ); paramTex1.value.setValue( volData.dataSetId.getValue() ); // Create a fragment shader, load the source file and add the parameter SoFragmentShader fragmentShader = new SoFragmentShader(); fragmentShader.sourceProgram.setValue( SHADER_FILENAME ); fragmentShader.parameter.set1Value( 0, paramTex1 ); // Create a shader program and add the fragment shader SoVolumeShader volShader = new SoVolumeShader(); int shaderPosition = SoVolumeShader.ShaderPositions.FRAGMENT_COMPUTE_COLOR.getValue(); volShader.shaderObject.set1Value( shaderPosition, fragmentShader ); volSep.addChild( volShader );
File format/default:
shaderObject | [ |
GEOMETRY_MAIN shader | |
DATA_COMBINE_FUNCTION shader, | |
GET_DAT_FUNCTION shader, | |
FRAGMENT_COMPUTE_COLOR shader, | |
VERTEX_MAIN shader, | |
VERTEX_MAIN shader, | |
FRAGMENT_MAIN shader, | |
... (reserved) | |
CUSTOM_SHADER shader | |
... (free for apps) | |
] | |
forVolumeOnly | false |
raycasting | true |
interpolateOnMove | false |
See also:
SoShaderProgram
, SoVolumeRenderingQuality
, SoMultiDataSeparator
, SoVolumeIsosurface
, SoPreferences
Modifier and Type | Class and Description |
---|---|
static class |
SoVolumeShader.ShaderPositions
Specifies the position of the shader pipeline stages in the field
shaderObject . |
SoShaderProgram.GeometryInputTypes, SoShaderProgram.GeometryOutputTypes
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
static int |
CLIPPING_FUNCTION
Deprecated.
Use
SoVolumeShader.ShaderPositions.CLIPPING_FUNCTION instead. |
static int |
CUSTOM_SHADER
Deprecated.
Use
SoVolumeShader.ShaderPositions.CUSTOM_SHADER instead. |
static int |
DATA_COMBINE_FUNCTION
Deprecated.
Use
SoVolumeShader.ShaderPositions.DATA_COMBINE_FUNCTION instead. |
SoSFBool |
forVolumeOnly
Set to true if the shader should be called for volume rendering (
SoVolumeRender ). |
static int |
FRAGMENT_COMPUTE_COLOR
Deprecated.
|
static int |
FRAGMENT_MAIN
Deprecated.
Use
SoVolumeShader.ShaderPositions.FRAGMENT_MAIN instead. |
static int |
GEOMETRY_MAIN
Deprecated.
Use
SoVolumeShader.ShaderPositions.GEOMETRY_MAIN instead. |
static int |
GET_DATA_FUNCTION
Deprecated.
Use
SoVolumeShader.ShaderPositions.GET_DATA_FUNCTION instead. |
SoSFBool |
interpolateOnMove
When set to false, interpolation between LDM tiles (across the tile boundary) is not done when rendering in interactive mode.
|
SoSFBool |
raycasting
Deprecated.
As of Open Inventor 9620 See documentation for more details
|
static int |
VERTEX_MAIN
Deprecated.
Use
SoVolumeShader.ShaderPositions.VERTEX_MAIN instead. |
static int |
VERTEX_POSTPROCESSING
Deprecated.
Use
SoVolumeShader.ShaderPositions.VERTEX_POSTPROCESSING instead. |
bufferObjects, generateTransparency, geometryInputType, geometryOutputType, LINE_STRIP_OUTPUT, LINES_INPUT, maxGeometryOutputVertices, patchLength, POINTS_INPUT, POINTS_OUTPUT, shaderObject, shadowShader, TRIANGLE_STRIP_OUTPUT, TRIANGLES_INPUT, vertexProgramTwoSide
VERBOSE_LEVEL, ZeroHandle
Constructor and Description |
---|
SoVolumeShader()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
isSupported()
Calls isSupported((com.openinventor.inventor.misc.SoState)null).
|
static boolean |
isSupported(SoState state)
Returns true if
SoVolumeShader is supported by the current graphics board. |
getFragmentShader, getGeometryShader, getNumReservedTextures, getTessellationControlShader, getTessellationEvaluationShader, getVertexShader, setFragmentShader, setFragmentShader, setGeometryShader, setGeometryShader, setTessellationControlShader, setTessellationControlShader, setTessellationEvaluationShader, setTessellationEvaluationShader, setVertexShader, setVertexShader
affectsState, callback, copy, copy, distribute, doAction, getAlternateRep, getBoundingBox, getByName, getMatrix, getPrimitiveCount, 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, getEXTERNPROTO, getName, getPROTO, isDisposable, isSynchronizable, setName, setSynchronizable
getAddress, getNativeResourceHandle, startInternalThreads, stopInternalThreads
@Deprecated public static final int GEOMETRY_MAIN
SoVolumeShader.ShaderPositions.GEOMETRY_MAIN
instead.@Deprecated public static final int DATA_COMBINE_FUNCTION
SoVolumeShader.ShaderPositions.DATA_COMBINE_FUNCTION
instead.@Deprecated public static final int GET_DATA_FUNCTION
SoVolumeShader.ShaderPositions.GET_DATA_FUNCTION
instead.@Deprecated public static final int FRAGMENT_COMPUTE_COLOR
SoVolumeShader.ShaderPositions.FRAGMENT_COMPUTE_COLOR
instead.@Deprecated public static final int VERTEX_MAIN
SoVolumeShader.ShaderPositions.VERTEX_MAIN
instead.@Deprecated public static final int FRAGMENT_MAIN
SoVolumeShader.ShaderPositions.FRAGMENT_MAIN
instead.@Deprecated public static final int VERTEX_POSTPROCESSING
SoVolumeShader.ShaderPositions.VERTEX_POSTPROCESSING
instead.@Deprecated public static final int CLIPPING_FUNCTION
SoVolumeShader.ShaderPositions.CLIPPING_FUNCTION
instead.@Deprecated public static final int CUSTOM_SHADER
SoVolumeShader.ShaderPositions.CUSTOM_SHADER
instead.public final SoSFBool forVolumeOnly
SoVolumeRender
).
Set to false if it should be called for other VolumeViz shapes (SoOrthoSlice
, SoObliqueSlice
, SoVolumeSkin
, volume geometry, etc). Default is false.
true means that if the shader uses texture coordinates, they will be 3D texture coordinates. false means they will be 2D texture coordinates.
In some cases it may be possible to use the same shader source for both volume and non-volume rendering. However the application still must create two shader nodes, one with true and one with false, even if both nodes load the same shader source file. (This is necessary because the shader source must be compiled with different parameters for the different cases.)
@Deprecated public final SoSFBool raycasting
SoVolumeRender
).
Note: Has no effect unless the forVolumeOnly
field is true. Default is true.
public final SoSFBool interpolateOnMove
Default is false.
public static boolean isSupported()
public static boolean isSupported(SoState state)
SoVolumeShader
is supported by the current graphics board.
When using a debug build of Open Inventor, some "no context available" warning messages may be generated. You can ignore them or see SoGLExtension
for an example of using SoGLContext
to avoid them.Generated on January 23, 2025, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com