Enum Class SoVolumeShader.ShaderPositions

java.lang.Object
java.lang.Enum<SoVolumeShader.ShaderPositions>
com.openinventor.volumeviz.nodes.SoVolumeShader.ShaderPositions
All Implemented Interfaces:
IntegerValuedEnum, Serializable, Comparable<SoVolumeShader.ShaderPositions>, Constable
Enclosing class:
SoVolumeShader

public static enum SoVolumeShader.ShaderPositions extends Enum<SoVolumeShader.ShaderPositions> implements IntegerValuedEnum
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.
  • Enum Constant Details

    • GEOMETRY_MAIN

      public static final SoVolumeShader.ShaderPositions 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

      public static final SoVolumeShader.ShaderPositions 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);

      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;
       }

        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 VolumeVizFragmentShaders for more details.

    • GET_DATA_FUNCTION

      public static final SoVolumeShader.ShaderPositions 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);
       }

      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);
       
       }

        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 VolumeVizFragmentShaders for more details.

    • FRAGMENT_COMPUTE_COLOR

      public static final SoVolumeShader.ShaderPositions 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);
       // 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);
       }

      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);
       }

      See VolumeVizFragmentShaders for more details.

      Since:
      Open Inventor 9.0

    • VERTEX_MAIN

      public static final SoVolumeShader.ShaderPositions 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 VolumeVizVertexShaders for more details.

    • FRAGMENT_MAIN

      public static final SoVolumeShader.ShaderPositions 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 VolumeVizFragmentShaders for more details.

    • VERTEX_POSTPROCESSING

      public static final SoVolumeShader.ShaderPositions 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 VolumeVizVertexShaders for more details.

      Since:
      Open Inventor 9.0

    • CLIPPING_FUNCTION

      public static final SoVolumeShader.ShaderPositions 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.

      Since:
      Open Inventor 9.7

    • TESS_VERTEX_SHIFT

      public static final SoVolumeShader.ShaderPositions 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 );

      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 VolumeVizTessellationShaders

      Since:
      Open Inventor 10.8

    • CUSTOM_SHADER

      public static final SoVolumeShader.ShaderPositions CUSTOM_SHADER
      This position and all subsequent positions CUSTOM_SHADER+x are freely available for user-defined shaders.

      Since:
      Open Inventor 9.0

  • Method Details

    • values

      public static SoVolumeShader.ShaderPositions[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static SoVolumeShader.ShaderPositions valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • valueOf

      public static SoVolumeShader.ShaderPositions valueOf(int val)
      Returns the enum constant of this type with the specified integer value
      Returns:
      the enum constant of this type with the specified integer value.
    • getValue

      public int getValue()
      Description copied from interface: IntegerValuedEnum
      Returns the integer value of the enum constant.
      Specified by:
      getValue in interface IntegerValuedEnum
      Returns:
      the integer value of the enum constant.