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:
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 | true |
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
SoNode.RenderModes
Inventor.ConstructorCommand
Modifier and Type | Field and Description |
---|---|
SoSFBool |
forVolumeOnly
Set to true if the shader should be called for volume rendering (
SoVolumeRender ). |
SoSFBool |
interpolateOnMove
When set to false, interpolation between LDM tiles (across the tile boundary) is not done when rendering in interactive mode.
|
bufferObjects, generateTransparency, geometryInputType, geometryOutputType, maxGeometryOutputVertices, patchLength, shaderObject, shadowShader, 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, 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 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.)
public final SoSFBool interpolateOnMove
Default is true.
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 July 31, 2019, Copyright © Thermo Fisher Scientific. All rights reserved. http://www.openinventor.com