SoVolumeShaderShaderPositions Enumeration |
Specifies the position of the shader pipeline stages in the field shaderObject.
Namespace: OIV.VolumeViz.Nodes
Member name | Value | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
GEOMETRY_MAIN | 0 | 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 | 1 | 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: 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;
}
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 OIV.LDM.Nodes.SoDataRange). The application must pass the data range to the shader function as a uniform parameter. See VolumeVizFragmentShaders for more details. | |||||||
GET_DATA_FUNCTION | 2 | 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: 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: 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); }
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 OIV.LDM.Nodes.SoDataRange). The application must pass the data range to the shader function as a uniform parameter. See VolumeVizFragmentShaders for more details. | |||||||
FRAGMENT_COMPUTE_COLOR | 3 | 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: vec4 VVizComputeFragmentColor(in VVizDataSetId dataset, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int mask); 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: 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; } vec4 VVizComputeFragmentColor(in VVIZ_DATATYPE vox, in vec3 texCoord) { return blend(texCoord); } 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(). 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; } vec4 VVizComputeFragmentColor(in VVIZ_DATATYPE vox, in vec3 texCoord) { return blend(VVizGetDefaultDataSet(), texCoord); } 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.
| |||||||
VERTEX_MAIN | 4 | 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 OIV.VolumeViz.Nodes.SoVolumeRender. See VolumeVizVertexShaders for more details. | |||||||
FRAGMENT_MAIN | 5 | 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 | 6 | 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.
| |||||||
CLIPPING_FUNCTION | 7 | 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 OIV.VolumeViz.Nodes.SoVolumeRenderingQuality.voxelizedRendering = true, the voxels will be hollow.
| |||||||
TESS_VERTEX_SHIFT | 8 | Shader function used to modify the position of vertices during HeightField rendering. This shader slot must be set with an OIV.Inventor.Nodes.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: uniform sampler2D shiftTexture; vec3 VVizTessVertexShift( in vec3 position, in vec2 texCoord ) { return position + texture( shiftTexture, texCoord ).xyz; } Notes & Limitations:
See VolumeVizTessellationShaders
| |||||||
CUSTOM_SHADER | 64 | This position and all subsequent positions CUSTOM_SHADER+x are freely available for user-defined shaders.
|
In other words, use these enumeration values for the first parameter of the set1Value() method when setting a custom shader in the OIV.VolumeViz.Nodes.SoVolumeShader node.