Fragment shaders
[VolumeViz Shader API]

VolumeViz VolumeViz GLSL fragment shaders API. More...

Functions

bool VVizIsClipped (vec3 tCoord)
bool VVizIsClippedByROI (in VVizDataSetId dataset, in vec3 texCoord)
void VVizClipVoxel ()
VVIZ_DATATYPE VVizCombineData (in vec3 dataCoord)
vec4 VVizComputeFragmentColor (in VVizDataSetId dataset, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int mask)
vec3 VVizComputeCoordinates (const vec3 dataCoord)
vec3 VVizComputeCoordinates (in VVizDataSetId dataset, const vec3 dataCoord)
vec4 VVizOverOperator (vec4 underCol, vec4 overCol)
float VVizGetLuminance (VVIZ_DATATYPE data)
vec3 VVizGetNearestCoord (in VVizVoxelInfo voxelInfo)
vec3 VVizGetNearestCoord (in VVizDataSetId dataset, in VVizVoxelInfo voxelInfo)
vec3 VVizComputePreintegratedGradient (vec3 tcoord0, vec3 tcoord1)
vec3 VVizComputeNormal (vec3 view, vec3 grad)
vec3 VVizComputeNormal (vec3 tcoordVirt)
vec3 VVizComputeNormal (in VVizDataSetId dataset, vec3 tcoordVirt)
vec4 VVizComputeIsoMaterial (VVizDataSetId tex, in VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, int maskId)
vec4 VVizComputePreIntegrated (VVIZ_DATATYPE sf, VVIZ_DATATYPE sb)
vec4 VVizComputeVolumeRendering (VVIZ_DATATYPE sf)
vec4 VVizComputeVolumeRenderingLighting (in vec4 col, in vec3 normal, in float gradLength)
vec4 VVizComputeVolumeRenderingLighting (in VVizDataSetId dataset, in vec4 col, in vec3 normal, in float gradLength)
vec4 VVizComputePreintegratedLighting (in vec4 col, in vec3 normal, in float gradLength)
vec4 VVizComputePreintegratedLighting (in VVizDataSetId dataset, in vec4 col, in vec3 normal, in float gradLength)
vec3 VVizComputeViewVec ()
vec3 VVizComputeViewVec (in VVizDataSetId dataset)
void VVizComputeGradientCommon (in vec3 tcoordFront, in vec3 tcoordBack, out vec3 gradient, out vec3 normal)
void VVizComputeGradientCommon (VVizDataSetId dataset, in vec3 tcoordFront, in vec3 tcoordBack, out vec3 gradient, out vec3 normal)
VVIZ_DATATYPE VVizGetData (in VVizDataSetId dataset, in vec3 dataCoord)
VVIZ_DATATYPE VVizGetRawData (in VVizDataSetId dataset, in vec3 dataCoord)
int VVizGetMask (in vec3 tcoord)
void VVizOutputColor (vec4 color)
vec4 VVizTransferFunction (in VVIZ_DATATYPE voxelValue, in int Id)
vec4 VVizTransferFunction (in VVIZ_DATATYPE frontVoxelValue, in VVIZ_DATATYPE backVoxelValue, in int Id)

Detailed Description

VolumeViz VolumeViz GLSL fragment shaders API.


Function Documentation

void VVizClipVoxel (  ) 

Applies clipping when using an SoVolumeClippingGroup or SoUniformGridClipping node.

If no SoUniformGridClipping or SoVolumeClippingGroup nodes are present in the scene graph, this function will have no effect.

Must be called in a custom FRAGMENT_MAIN shader only.

VVIZ_DATATYPE VVizCombineData ( in vec3  dataCoord  ) 

SoVolumeShader::DATA_COMBINE_FUNCTION function.

Applications can replace this method to customize the SoVolumeShader::DATA_COMBINE_FUNCTION shader stage.

Parameters:
dataCoord Uniform data coordinate in the volume space of the default DataSet (see VVizGetDefaultDataSet()).
Returns:
voxel data value.
vec3 VVizComputeCoordinates ( in VVizDataSetId  dataset,
const vec3  dataCoord 
)

Compute new coordinates from input coordinates.


This method is used to support rectilinear coordinates or custom projection. It computes voxel coordinates and must be used instead of gl_TexCoord[0].xyz. If not used, texture coordinates may not be clamped, scaled, etc... as necessary in order to have correct rendering.

The parameter usually is gl_TexCoord[0].xyz (in slicing mode only). The returned coordinate is in general directly passed to VVizCombineData method.

Parameters:
dataset Dataset id
dataCoord Coordinates of point, in the normalized volume space of dataset.
Returns:
Projected coord if requested, returns dataCoord by default.
vec3 VVizComputeCoordinates ( const vec3  dataCoord  ) 

Compute new coordinates from input coordinates.


This method is used to support rectilinear coordinates or custom projection. It computes voxel coordinates and must be used instead of gl_TexCoord[0].xyz. If not used, texture coordinates may not be clamped, scaled, etc... as necessary in order to have correct rendering.

The parameter usually is gl_TexCoord[0].xyz (in slicing mode only). The returned coordinate is in general directly passed to VVizCombineData method.

Parameters:
dataCoord Coordinates of point, in the normalized volume space of the default DataSet.
Returns:
Projected coord if requested, returns dataCoord by default.
vec4 VVizComputeFragmentColor ( in VVizDataSetId  dataset,
in vec3  rayDir,
inout VVizVoxelInfo  voxelInfoFront,
in VVizVoxelInfo  voxelInfoBack,
in int  mask 
)

SoVolumeShader::FRAGMENT_COMPUTE_COLOR function.

Applications can replace this method to customize the SoVolumeShader::FRAGMENT_COMPUTE_COLOR shader stage.
Note: This version of the method is only used by the SoVolumeRender node.

Parameters:
dataset Dataset id
rayDir ray Direction in the volume space of dataset.
voxelInfoFront Voxel info of front slice.
voxelInfoBack Voxel info of back slice
mask Current mask Id
void VVizComputeGradientCommon ( VVizDataSetId  dataset,
in vec3  tcoordFront,
in vec3  tcoordBack,
out vec3  gradient,
out vec3  normal 
)

Computes gradient and normal values for the given dataset at the given texture coordinates.

Only available for Volume Rendering because the gradient is computed using texel neighbors in the 3D texture.

void VVizComputeGradientCommon ( in vec3  tcoordFront,
in vec3  tcoordBack,
out vec3  gradient,
out vec3  normal 
)

Computes gradient and normal values at the given texture coordinates.

Only available for Volume Rendering because the gradient is computed using texel neighbors in the 3D texture.

This method is for the default DataSet. For a specific dataset, see VVizComputeGradientCommon(in VVizDataSetId, in vec3, in vec3, out vec3, out vec3)

vec4 VVizComputeIsoMaterial ( VVizDataSetId  tex,
in VVizVoxelInfo  voxelInfoFront,
in VVizVoxelInfo  voxelInfoBack,
int  maskId 
)

Returns the color of the lighted pixel belonging to the isosurface.

sf and sb are usually the volume data which have the texture coordinate gl_TexCoord[0] and gl_TexCoord[1] computed by VVizComputeFrontSliceTexCoord and VVizComputeBackSliceTexCoord. If there is no isosurface between sf and sb, a transparent pixel will be returned. Lighting is computed with the first directional light found in the scene graph.
Because it needs a special texture, this function can only be used with SoVolumeIsosurface.

vec3 VVizComputeNormal ( in VVizDataSetId  dataset,
vec3  tcoordVirt 
)

Compute normal in surface of 2D shapes (slices, volumeGeometry, volumeSkin, hzighfield) at given coordinates.

Normal is returned in eye space. If bump mapping is currently enabled, the normal corresponding to bump effect will be returned.

vec3 VVizComputeNormal ( vec3  tcoordVirt  ) 

Compute normal in surface of 2D shapes (slices, volumeGeometry, volumeSkin, hzighfield) at given coordinates.

Normal is returned in eye space. If bump mapping is currently enabled, the normal corresponding to bump effect will be returned.

This method is only for the default DataSet. For a specific dataset, see VVizComputeNormal(in VVizDataSetId, vec3)

vec3 VVizComputeNormal ( vec3  view,
vec3  grad 
)

Returns the current normal.

vec4 VVizComputePreIntegrated ( VVIZ_DATATYPE  sf,
VVIZ_DATATYPE  sb 
)

Convert the volume data values (sf, sb) to a color by lookup in the pre-integrated table.

The pre-integrated table is a precomputed table which gives an approximation of the volume rendering integral between two slices.
Because it needs a special texture, this function can only be used with SoVolumeRenderingQuality.

vec3 VVizComputePreintegratedGradient ( vec3  tcoord0,
vec3  tcoord1 
)

Returns the gradient at the center of the two slices.

vec4 VVizComputePreintegratedLighting ( in VVizDataSetId  dataset,
in vec4  col,
in vec3  normal,
in float  gradLength 
)

Add lighting to the color col in the case of pre-integrated rendering.

col is usually the result of VVizComputePreintegrated. The difference with the VVizComputeVolumeRenderingLighting function is that the normal used for lighting is at the middle of the space between the front and the back slice. Lighting is computed with the first directional light found in the scene graph.
Because it needs a special texture, this function can only be used with SoVolumeRenderingQuality.

vec4 VVizComputePreintegratedLighting ( in vec4  col,
in vec3  normal,
in float  gradLength 
)

Add lighting to the color col in the case of pre-integrated rendering.

col is usually the result of VVizComputePreintegrated. The difference with the VVizComputeVolumeRenderingLighting function is that the normal used for lighting is at the middle of the space between the front and the back slice. Lighting is computed with the first directional light found in the scene graph.
Because it needs a special texture, this function can only be used with SoVolumeRenderingQuality.

vec3 VVizComputeViewVec ( in VVizDataSetId  dataset  ) 

Returns the current viewing vector in the model space of the given dataset.

vec3 VVizComputeViewVec (  ) 

Returns the current viewing vector in the model space of the default dataset.

vec4 VVizComputeVolumeRendering ( VVIZ_DATATYPE  sf  ) 

Returns the conversion of the volume data value sf to color by lookup in the colormap.

vec4 VVizComputeVolumeRenderingLighting ( in VVizDataSetId  dataset,
in vec4  col,
in vec3  normal,
in float  gradLength 
)

Add lighting to the color col.

col is usually the result of VVizComputeVolumeRendering.

vec4 VVizComputeVolumeRenderingLighting ( in vec4  col,
in vec3  normal,
in float  gradLength 
)

Add lighting to the color col.

col is usually the result of VVizComputeVolumeRendering.

VVIZ_DATATYPE VVizGetData ( in VVizDataSetId  dataset,
in vec3  dataCoord 
)

SoVolumeShader::GET_DATA_FUNCTION function.

Applications can replace this method to customize the SoVolumeShader::GET_DATA_FUNCTION shader stage.

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 explicitly pass the current data range to the shader function as a uniform parameter.

Parameters:
dataset The dataset to read
dataCoord Uniform data coordinates in volume space.
Returns:
voxel data value.
float VVizGetLuminance ( VVIZ_DATATYPE  data  ) 

Compute the luminance of a voxel value.

Parameters:
data value to convert
Returns:
Luminance of data.
int VVizGetMask ( in vec3  tcoord  ) 

Returns the mask value at the given texture coordinate.

If there is no SoVolumeMask, the returned value is the id of the transfer function on the state.

vec3 VVizGetNearestCoord ( in VVizDataSetId  dataset,
in VVizVoxelInfo  voxelInfo 
)

Returns virtual coordinates of nearest voxel center, taking in account current voxel resolution.

This can be used to avoid having interpolation issues by taking the true value of voxel.

vec3 VVizGetNearestCoord ( in VVizVoxelInfo  voxelInfo  ) 

Returns virtual coordinates of nearest voxel center, taking in account current voxel resolution.

This can be used to avoid having interpolation issues by taking the true value of voxel.

VVIZ_DATATYPE VVizGetRawData ( in VVizDataSetId  dataset,
in vec3  dataCoord 
)

Default SoVolumeShader::GET_DATA_FUNCTION function.

Method to access dataset, that can be used by VVizGetData custom implementation. It may apply different interpolation (linear, cubix, trilinear, multi-sample12) depending on SoVolumeRenderingQuality and SoVolumeRender nodes setup.

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 explicitly pass the current data range to the shader function as a uniform parameter.

Parameters:
dataset The dataset to read
dataCoord uniform data coordinates in volume space.
Returns:
voxel data value
bool VVizIsClipped ( vec3  tCoord  ) 

Customizes the SoVolumeShader::CLIPPING_FUNCTION shader stage.

Parameters:
tCoord Coordinate in the volume space of the default DataSet (see VVizGetDefaultDataSet())
Returns:
TRUE if given tCoord should be clipped.
bool VVizIsClippedByROI ( in VVizDataSetId  dataset,
in vec3  texCoord 
)

Returns true if the given coordinate is clipped by a ROI applied on the given dataset.

The given texture coordinate is defined in the texture coordinate space of the given dataset. e.g. the coordinates (0.5, 0.5, 0.5) correspond to the center of the given dataset.

void VVizOutputColor ( vec4  color  ) 

This function sends the final fragment color to OpenGL.


It should be used instead of directly setting gl_FragColor, in order to allow VolumeViz to do final manipulation of the color.

Should be used at the end of FRAGMENT_MAIN shader only.

Parameters:
color the color to render.
vec4 VVizOverOperator ( vec4  underCol,
vec4  overCol 
)

Blend 2 colors using the over operator, result color is not alpha premultiplied.

Parameters:
underCol First color to blend.
overCol Second color to blend.
Returns:
Blended color.
vec4 VVizTransferFunction ( in VVIZ_DATATYPE  frontVoxelValue,
in VVIZ_DATATYPE  backVoxelValue,
in int  Id 
)

Pre-integrated transfer function.

Parameters:
frontVoxelValue Input voxel data value of the front slice.
backVoxelValue Input voxel data value of the back slice.
Id of the transfer function to use.
Returns:
Color of the value based on the transfer function id
vec4 VVizTransferFunction ( in VVIZ_DATATYPE  voxelValue,
in int  Id 
)

1D transfer function.

Parameters:
voxelValue Input voxel data value
Id of the transfer function to use.
Returns:
Color of the value based on the transfer function id

Open Inventor Toolkit reference manual, generated on 4 Sep 2023
Copyright © Thermo Fisher Scientific All rights reserved.
https://www.openinventor.com/