Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoVolumeShader Class Reference

VolumeViz Shader node for volume rendering. More...

#include <VolumeViz/nodes/SoVolumeShader.h>

+ Inheritance diagram for SoVolumeShader:

Public Types

enum  ShaderPosition {
  GEOMETRY_MAIN =0 ,
  DATA_COMBINE_FUNCTION ,
  GET_DATA_FUNCTION ,
  FRAGMENT_COMPUTE_COLOR ,
  VERTEX_MAIN ,
  FRAGMENT_MAIN ,
  VERTEX_POSTPROCESSING ,
  CLIPPING_FUNCTION ,
  TESS_VERTEX_SHIFT ,
  CUSTOM_SHADER = 64
}
 Specifies the position of the shader pipeline stages in the field shaderObject. More...
 
- Public Types inherited from SoShaderProgram
enum  GeometryInputType {
  POINTS_INPUT = GL_POINTS ,
  LINES_INPUT = GL_LINES ,
  TRIANGLES_INPUT = GL_TRIANGLES
}
 Geometry input type. More...
 
enum  GeometryOutputType {
  POINTS_OUTPUT = GL_POINTS ,
  LINE_STRIP_OUTPUT = GL_LINE_STRIP ,
  TRIANGLE_STRIP_OUTPUT = GL_TRIANGLE_STRIP
}
 Geometry ouput type. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoVolumeShader ()
 Constructor.
 
virtual SoFragmentShadersetFragmentShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Creates a fragment shader with the given filename and add it at the given pos.
 
virtual SoVertexShadersetVertexShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Creates a vertex shader with the given filename and adds it at the given pos.
 
- Public Member Functions inherited from SoShaderProgram
 SoShaderProgram ()
 Constructor.
 
SoFragmentShadergetFragmentShader (int pos) const
 Returns the fragment shader at the specified position.
 
SoVertexShadergetVertexShader (int pos) const
 Returns the vertex shader at the specified position.
 
SoGeometryShadergetGeometryShader (int pos) const
 Returns the geometry shader at the specified position.
 
virtual SoGeometryShadersetGeometryShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a geometry shader with the specified filename and add it at the specified position.
 
virtual SoComputeShadersetComputeShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a compute shader with the specified filename and add it at the specified position.
 
SoTessellationControlShadergetTessellationControlShader (int pos) const
 Returns the tessellation control shader at the specified position.
 
SoTessellationEvaluationShadergetTessellationEvaluationShader (int pos) const
 Returns the tessellation evaluation shader at the specified position.
 
virtual SoTessellationControlShadersetTessellationControlShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a tessellation control shader with the specified filename and add it at the specified position.
 
virtual SoTessellationEvaluationShadersetTessellationEvaluationShader (int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
 Convenience method to create a tessellation evaluation shader with the specified filename and add it at the specified position.
 
SoShaderParameterImageaddShaderParameterImage (const SbString &name, SoTexture *tex)
 Convenience method to create an SoShaderParameterImage with the specified name and value and add it to this shader program.
 
- 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 SoNodecopy (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 SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (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 SbBool isSupported (SoState *state=NULL)
 Returns TRUE if SoVolumeShader is supported by the current graphics board.
 
- Static Public Member Functions inherited from SoShaderProgram
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static unsigned int getNumReservedTextures ()
 Returns the number of reserved texture units.
 
- Static Public Member Functions inherited from SoNode
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoNodegetByName (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 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.
 
- Public Attributes inherited from SoShaderProgram
SoMFNode shaderObject
 Specifies the list of shader objects (i.e., vertex shaders, geometry and fragment shaders) which form the shader program.
 
SoSFEnum geometryInputType
 Specifies the input primitive type of the current geometry shader if any (not used otherwise).
 
SoSFEnum geometryOutputType
 Specifies the output primitive type of the current geometry shader if any (not used otherwise).
 
SoSFBool vertexProgramTwoSide
 If set to TRUE, vertex shaders will operate in two-sided color mode.
 
SoSFBool shadowShader
 Only used when an SoShadowGroup is active.
 
SoSFInt32 maxGeometryOutputVertices
 Set the maximum number of vertices the geometry shader will emit in one invocation.
 
SoSFBool generateTransparency
 If set to TRUE, then shapes affected by this shader will be considered transparent.
 
SoSFInt32 patchLength
 Set the length of the fixed-size collection of vertices used by tessellation shaders.
 
SoMFNode bufferObjects
 Specifies a list of SoShaderParameterBufferObject to use with this shader.
 
SoMFNode images
 Specifies a list of SoShaderParameterImage nodes to use with this shader.
 

Detailed Description

VolumeViz Shader node for volume rendering.

This node manages the VolumeViz GLSL shader pipeline. It is derived from SoShaderProgram and behaves in a 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 minimum new codes. The VolumeViz GLSL shader pipeline API is described in the VolumeViz Shader API 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 must still 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+SoShaderProgramgetNumReservedTextures()-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.

Composition with Multiple Data:
When compositing multiple datasets that have different dimensions or extents using a custom shader, it is necessary to convert texture coordinates from one dataset to another in order to fetch the correct data values.
For this purpose, texture coordinates conversion functions are provided in the VolumeViz/vvizStructure.h shader include.
For instance,

vec3 VVizTextureToTextureVec(in VVizDataSetId datasetSrc, in VVizDataSetId datasetDst, in vec3 texCoord);
vec3 VVizTextureToTextureVec(in VVizDataSetId datasetSrc, in VVizDataSetId datasetDst, in vec3 texCoord)
Converts the input vector from the texture space of one dataset to the texture space of another datas...

can be used to convert texture coordinates related to one dataset to texture coordinates related to another dataset.
The conversion is based solely on the transformations applied to each dataset, which are defined by their model matrix and their extent.
Please note that the model matrix of a dataset is defined by to the SoTransformation nodes that are placed before the SoDataSet node in the order of the traversal.

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. 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 any 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.

The VolumeViz shader API is described in VolumeViz Shader API.

Available vertex program functions are described in Vertex shaders.

Available fragment program functions are described in Fragment shaders.

Available constants, macros and data structures are described in Data structures and constant.

EXAMPLE

FILE FORMAT/DEFAULT

    SoShaderProgram {
    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

Definition at line 292 of file SoVolumeShader.h.

Member Enumeration Documentation

◆ ShaderPosition

Specifies the position of the shader pipeline stages in the field shaderObject.

In other words, use these enumeration values for the first parameter of the set1Value() method when setting a custom shader in the SoVolumeShader node.

Enumerator
GEOMETRY_MAIN 

The main geometry program used for rendering.

Notes: Defining a custom GEOMETRY_MAIN slot is only supported for compatibility. It is not compatible with the volume rendering.

DATA_COMBINE_FUNCTION 

This shader is used for GPU multi-data composition.

It must contain an application defined data combining function whose prototype is:

VVIZ_DATATYPE VVizCombineData(in vec3 dataCoord);
VVIZ_DATATYPE VVizCombineData(in vec3 dataCoord)
SoVolumeShader::DATA_COMBINE_FUNCTION function.

The subtraction of two volumes can be written in GLSL like this:

// !oiv_include <VolumeViz/vvizGetData_frag.h>
// !oiv_include <VolumeViz/vvizCombineData_frag.h>
uniform VVizDataSetId dataId1;
uniform VVizDataSetId dataId2;
VVIZ_DATATYPE VVizCombineData(vec3 tcoord)
{
VVIZ_DATATYPE d1 = VVizGetData(dataId1, tcoord);
VVIZ_DATATYPE d2 = VVizGetData(dataId2, tcoord);
return d1-d2;
}
VVIZ_DATATYPE VVizGetData(in VVizDataSetId dataset, in vec3 dataCoord)
SoVolumeShader::GET_DATA_FUNCTION function.

First volume Second volume Subtraction

NOTE: On the GPU, voxel values are always returned as a normalized value in the range 0..1. If the actual voxel value is needed, the shader function must compute that value using the current data range (see SoDataRange). The application must pass the data range to the shader function as a uniform parameter.

See Fragment shaders for more details.

GET_DATA_FUNCTION 

This shader is used to access datasets.

It must contain an application defined data accessor function whose prototype is:

VVIZ_DATATYPE VVizGetData(in VVizDataSetId dataset, in vec3 dataCoord);

The default implementation is defined as follows:

// !oiv_include <VolumeViz/vvizGetData_frag.h>
// Default 3D DATA interpolation
VVIZ_DATATYPE VVizGetData(VVizDataSetId tex, vec3 tcoord)
{
return VVizGetRawData(tex, tcoord);
}
VVIZ_DATATYPE VVizGetRawData(in VVizDataSetId dataset, in vec3 dataCoord)
Default SoVolumeShader::GET_DATA_FUNCTION function.

This function can be used to apply filters on each data volume. The following example shows how to make a smoothing filter which will remove some noise:

// !oiv_include <VolumeViz/vvizGetData_frag.h>
VVIZ_DATATYPE VVizGetData(in VVizDataSetId dataset, vec3 tcoord)
{
vec3 voxelDim = VVizGetVoxelDimensions(dataset);
vec3 du = vec3(voxelDim[0], 0., 0.);
vec3 dv = vec3(0., voxelDim[1], 0.);
vec3 dw = vec3(0., 0., voxelDim[2]);
return 1./6.*(VVizGetRawData(dataset, tcoord-du).w+VVizGetRawData(dataset, tcoord+du).w+
VVizGetRawData(dataset, tcoord-dv).w+VVizGetRawData(dataset, tcoord+dv).w+
VVizGetRawData(dataset, tcoord-dw).w+VVizGetRawData(dataset, tcoord+dw).w);
}
vec3 VVizGetVoxelDimensions(in VVizDataSetId dataset)
Returns volume dataset uniform voxel dimensions.

Non filtered data Filtered data

NOTE: On the GPU, voxel values are always returned as a normalized value in the range 0..1. If the actual voxel value is needed, the shader function must compute that value using the current data range (see SoDataRange). The application must pass the data range to the shader function as a uniform parameter.

See Fragment shaders for more details.

FRAGMENT_COMPUTE_COLOR 

This shader is used to compute the current fragment color.

Note: VVizComputePreIntegrated should only be called when SoVolumeRendering::renderMode is set to VOLUME_RENDERING (the default). It is not appropriate for MIN, MAX, etc composition.

It must contain an application defined compute fragment color function whose prototype is:

// For an SoVolumeRender node
vec4 VVizComputeFragmentColor(in VVizDataSetId dataset, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int mask);
vec4 VVizComputeFragmentColor(in VVizDataSetId dataset, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int mask)
SoVolumeShader::FRAGMENT_COMPUTE_COLOR function.
Defines voxel state info used with the VolumeViz Shader Library API.
// For all other VolumeViz shape nodes (SoOrthoSlice, SoObliqueSlice, SoVolumeSkin ...)
vec4 VVizComputeFragmentColor(in VVIZ_DATATYPE vox, in vec3 dataCoord);

This function can be used to do co-blending on multiple data volumes. The following example shows how to blend two volumes:

// !oiv_include <VolumeViz/vvizGetData_frag.h>
// !oiv_include <VolumeViz/vvizTransferFunction_frag.h>
uniform VVizDataSetId data1;
uniform VVizDataSetId data2;
vec4 blend(in vec3 texCoord)
{
VVIZ_DATATYPE index1 = VVizGetData(data1, texCoord);
vec4 data1Color = VVizTransferFunction(index1, 0);
VVIZ_DATATYPE index2 = VVizGetData(data2, texCoord);
vec4 data2Color = VVizTransferFunction(index2, 1);
// Color modulated by intensity from volume2
data2Color.rgb *= data1Color.r;
data2Color.a *= data1Color.a;
return res;
}
// Implement VVizComputeFragmentColor for slice nodes
vec4 VVizComputeFragmentColor(in VVIZ_DATATYPE vox, in vec3 texCoord)
{
return blend(texCoord);
}
// Implement VVizComputeFragmentColor for SoVolumeRender
vec4 VVizComputeFragmentColor(in VVizDataSetId data, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int maskId)
{
return blend(voxelInfoFront.texCoord);
}
vec4 VVizTransferFunction(in VVIZ_DATATYPE voxelValue, in int Id)
1D transfer function.

Composition of multiple independent volumes:

The following code gives an example of how to blend two independent volumes (different dimensions or extents).
The main difference with the previous example is that this one must transform the texture coordinates passed as parameter to the correct space before calling VVizGetData().

// !oiv_include <VolumeViz/vvizStructure.h>
// !oiv_include <VolumeViz/vvizGetData_frag.h>
// !oiv_include <VolumeViz/vvizTransferFunction_frag.h>
uniform VVizDataSetId DataSet1;
uniform VVizDataSetId DataSet2;
vec4 alphaBlend(in vec4 dst, in vec4 src)
{
vec4 res = src.a * (1.0 - dst.a) * vec4(src.rgb, 1.0) + dst.a * vec4(dst.rgb, 1.0);
res.rgb = (res.a != 0.0) ? (res.rgb / res.a) : vec3(0.0);
return res;
}
vec4 blend(in VVizDataSetId data, in vec3 texCoord)
{
vec4 outputColor = vec4(0.0);
vec3 data1Coord = VVizTextureToTextureVec(data, DataSet1, texCoord);
if (!VVizIsOutsideTexture(data1Coord))
{
VVIZ_DATATYPE index1 = VVizGetData(DataSet1, data1Coord);
vec4 data1Color = VVizTransferFunction(index1, DataSet1);
outputColor = alphaBlend(outputColor, data1Color);
}
vec3 data2Coord = VVizTextureToTextureVec(data, DataSet2, texCoord);
if (!VVizIsOutsideTexture(data2Coord))
{
VVIZ_DATATYPE index2 = VVizGetData(DataSet2, data1Coord);
vec4 data2Color = VVizTransferFunction(index2, DataSet2);
outputColor = alphaBlend(outputColor, data2Color);
}
return outputColor;
}
// Implement VVizComputeFragmentColor for slice nodes
vec4 VVizComputeFragmentColor(in VVIZ_DATATYPE vox, in vec3 texCoord)
{
return blend(VVizGetDefaultDataSet(), texCoord);
}
// Implement VVizComputeFragmentColor for SoVolumeRender
vec4 VVizComputeFragmentColor(in VVizDataSetId data, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int maskId)
{
return blend(data, voxelInfoFront.texCoord);
}
VVizDataSetId VVizGetDefaultDataSet()
Returns the default DataSet ID.

See Fragment shaders for more details.

NOTE: enumeration value available since Open Inventor 9.0

VERTEX_MAIN 

Main vertex shader used for rendering.

This stage should not be redefined unless you know exactly what you are doing. If the goal of your application is to compute specific varying attributes to pass to the fragment shader you should use the shaderPosition slot named VERTEX_POSTPROCESSING.

Notes: Defining a custom VERTEX_MAIN slot is only supported for compatibility. It is not compatible with the raycasting volume rendering technique which is now the default for SoVolumeRender.

See Vertex shaders for more details.

FRAGMENT_MAIN 

Main fragment shader used for rendering.

This stage should not be redefined unless you know exactly what you are doing. If the goal of your application is to blend colors or add effects to the existing pipeline you should use the shaderPosition slot named FRAGMENT_COMPUTE_COLOR.

Notes: Defining a custom FRAGMENT_MAIN slot is only supported for compatibility. It is not compatible with the raycasting volume rendering technique.

See Fragment shaders for more details.

VERTEX_POSTPROCESSING 

Method called at the end of the VolumeViz vertex shader stage.


This shader allows the application to generate custom varying values at the vertex shader stage for use in the fragment shader stage.

See Vertex shaders for more details.

NOTE: enumeration value available since Open Inventor 9.0

CLIPPING_FUNCTION 

This method can be used to implement a custom clipping algorithm.

Note that when using this method, it may not always be possible for VolumeViz to correctly manage slicing artifacts. You have to use SoVolumeRender::samplingAlignement = BOUNDARY_ALIGNED to avoid slicing artifacts.

When applying a custom clipping function with SoVolumeRenderingQuality::voxelizedRendering = TRUE, the voxels will be hollow.

NOTE: enumeration value available since Open Inventor 9.7

TESS_VERTEX_SHIFT 

Shader function used to modify the position of vertices during HeightField rendering.

This shader slot must be set with an SoTessellationEvaluationShader.

The shader must contain a function whose prototype is:

vec3 VVizTessVertexShift( in vec3 position, in vec2 texCoord );
vec3 VVizTessVertexShift(in vec3 position, in vec2 texCoord)
SoVolumeShader::TESS_VERTEX_SHIFT function.

The input position represents the 3D position of a vertex on the HeightField surface in model space: X and Y coordinates are mapped to [-1, 1] and the Z coordinate corresponds to the data set value, either normalized to [0, 1] for unsigned integer data types, [-1, 1] for signed integer datatypes, or used "as is" for floating point data types.

texCoord represents the 2D texture coordinate associated with the position.

The position returned by the function is expected to be the modified vertex position and must also be set in model space.

A vertex shift using a shift texture can be written in GLSL like this:

// !oiv_include <VolumeViz/vvizVertexShift_tess.h>
uniform sampler2D shiftTexture;
vec3
VVizTessVertexShift( in vec3 position, in vec2 texCoord )
{
return position + texture( shiftTexture, texCoord ).xyz;
}

Notes & Limitations:

  • This shader is available only for HeightField rendering. It is ignored during volume rendering and slice rendering.
  • The default shader returns the input position unmodified.
  • Although the shader must be an SoTessellationEvaluationShader, the GLSL function VVizTessVertexShift() will also be called internally during the tessellation control stage and the fragment stage, so the shader must only use the GLSL API that is common to those 3 stages.
  • Bounding Box, Tile Loading & Picking: Because this shader slot allows to modify the geometry of the rendered object, a discrepancy may arise that can lead to a misaligned bounding box, defective tile loading and incorrect picking values. These issues can be avoided by deriving the SoHeightFieldGeometry class and overriding the methods voxelToXYZ() and XYZToVoxel(). The voxelToXYZ() method is used by the bounding box computation and the tile loading and would need to re-implement the vertex shift transformation. The XYZToVoxel(SbVec3f) method is used for picking and would need to implement the inverse vertex shift transformation in order to be correct.

See Tessellation shaders

NOTE: enumeration value available since Open Inventor 10.8

CUSTOM_SHADER 

This position and all subsequent positions CUSTOM_SHADER+x are freely available for user-defined shaders.

NOTE: enumeration value available since Open Inventor 9.0

Definition at line 308 of file SoVolumeShader.h.

Constructor & Destructor Documentation

◆ SoVolumeShader()

SoVolumeShader::SoVolumeShader ( )

Constructor.

Member Function Documentation

◆ getClassTypeId()

static SoType SoVolumeShader::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getTypeId()

virtual SoType SoVolumeShader::getTypeId ( ) const
virtual

Returns the type identifier for this specific instance.

Reimplemented from SoShaderProgram.

Reimplemented in SoVolumeIsosurface, and SoVolumeRenderingQuality.

◆ isSupported()

static SbBool SoVolumeShader::isSupported ( SoState state = NULL)
static

Returns TRUE if 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.

◆ setFragmentShader()

virtual SoFragmentShader * SoVolumeShader::setFragmentShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Creates a fragment shader with the given filename and add it at the given pos.

Return value is the new fragment shader.

Reimplemented from SoShaderProgram.

◆ setVertexShader()

virtual SoVertexShader * SoVolumeShader::setVertexShader ( int  pos,
const SbString filenameOrSource,
SoShaderObject::SourceType  sourceType = SoShaderObject::FILENAME 
)
virtual

Creates a vertex shader with the given filename and adds it at the given pos.

Returns
the new vertex shader.

Reimplemented from SoShaderProgram.

Member Data Documentation

◆ forVolumeOnly

SoSFBool SoVolumeShader::forVolumeOnly

Set to TRUE if the shader should be called for volume rendering (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 must still 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 different cases.)

Definition at line 670 of file SoVolumeShader.h.

◆ interpolateOnMove

SoSFBool SoVolumeShader::interpolateOnMove

When set to FALSE, interpolation between LDM tiles (across the tile boundary) is not done when rendering in interactive mode.

This increases the interactive rendering frame rate at the cost of some rendering artifacts at the tile boundaries (seen as horizontal and vertical "lines" in the rendered image) and a small lag when switching between still and interactive. If your rendering shaders do not need to access voxel's neighbor (for lighting or gradient computation for instance), you should set this field to TRUE as the cost of interpolation is not significant in this case.

Default is TRUE.

NOTE: field available since Open Inventor 9.0

Definition at line 687 of file SoVolumeShader.h.


The documentation for this class was generated from the following file: