Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
Fragment shaders

VolumeViz VolumeViz GLSL fragment shaders API. More...

Functions

bool VVizIsClipped (vec3 tCoord)
 Customizes the SoVolumeShader::CLIPPING_FUNCTION shader stage.
 
bool VVizIsClippedByROI (in VVizDataSetId dataset, in vec3 texCoord)
 Returns true if the given coordinate is clipped by a ROI applied on the given dataset.
 
void VVizClipVoxel ()
 Applies clipping when using an SoVolumeClippingGroup or SoUniformGridClipping node.
 
VVIZ_DATATYPE VVizCombineData (in vec3 dataCoord)
 SoVolumeShader::DATA_COMBINE_FUNCTION function.
 
vec4 VVizComputeFragmentColor (in VVizDataSetId dataset, in vec3 rayDir, inout VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, in int mask)
 SoVolumeShader::FRAGMENT_COMPUTE_COLOR function.
 
vec3 VVizComputeCoordinates (const vec3 dataCoord)
 Compute new coordinates from input coordinates.
 
vec3 VVizComputeCoordinates (in VVizDataSetId dataset, const vec3 dataCoord)
 Compute new coordinates from input coordinates.
 
vec4 VVizOverOperator (vec4 underCol, vec4 overCol)
 Blend 2 colors using the over operator, result color is not alpha premultiplied.
 
float VVizGetLuminance (VVIZ_DATATYPE data)
 Compute the luminance of a voxel value.
 
vec3 VVizGetNearestCoord (in VVizVoxelInfo voxelInfo)
 Returns virtual coordinates of nearest voxel center, taking in account current voxel resolution.
 
vec3 VVizGetNearestCoord (in VVizDataSetId dataset, in VVizVoxelInfo voxelInfo)
 Returns virtual coordinates of nearest voxel center, taking in account current voxel resolution.
 
vec3 VVizComputePreintegratedGradient (vec3 tcoord0, vec3 tcoord1)
 Returns the gradient at the center of the two slices.
 
vec3 VVizComputeNormal (vec3 view, vec3 grad)
 Returns the current normal.
 
vec3 VVizComputeNormal (vec3 tcoordVirt)
 Compute normal in surface of 2D shapes (slices, volumeGeometry, volumeSkin, hzighfield) at given coordinates.
 
vec3 VVizComputeNormal (in VVizDataSetId dataset, vec3 tcoordVirt)
 Compute normal in surface of 2D shapes (slices, volumeGeometry, volumeSkin, hzighfield) at given coordinates.
 
vec4 VVizComputeIsoMaterial (VVizDataSetId tex, in VVizVoxelInfo voxelInfoFront, in VVizVoxelInfo voxelInfoBack, int maskId)
 Returns the color of the lighted pixel belonging to the isosurface.
 
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.
 
vec4 VVizComputeVolumeRendering (VVIZ_DATATYPE sf)
 Returns the conversion of the volume data value sf to color by lookup in the colormap.
 
vec4 VVizComputeVolumeRenderingLighting (in vec4 col, in vec3 normal, in float gradLength)
 Add lighting to the color col.
 
vec4 VVizComputeVolumeRenderingLighting (in VVizDataSetId dataset, in vec4 col, in vec3 normal, in float gradLength)
 Add lighting to the color col.
 
vec4 VVizComputePreintegratedLighting (in vec4 col, in vec3 normal, in float gradLength)
 Add lighting to the color col in the case of pre-integrated rendering.
 
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.
 
vec3 VVizComputeViewVec ()
 Returns the current viewing vector in the model space of the default dataset.
 
vec3 VVizComputeViewVec (in VVizDataSetId dataset)
 Returns the current viewing vector in the model space of the given dataset.
 
void VVizComputeGradientCommon (in vec3 tcoordFront, in vec3 tcoordBack, out vec3 gradient, out vec3 normal)
 Computes gradient and normal values at the given texture coordinates.
 
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.
 
VVIZ_DATATYPE VVizGetData (in VVizDataSetId dataset, in vec3 dataCoord)
 SoVolumeShader::GET_DATA_FUNCTION function.
 
VVIZ_DATATYPE VVizGetRawData (in VVizDataSetId dataset, in vec3 dataCoord)
 Default SoVolumeShader::GET_DATA_FUNCTION function.
 
int VVizGetMask (in vec3 tcoord)
 Returns the mask value at the given texture coordinate.
 
void VVizOutputColor (vec4 color)
 This function sends the final fragment color to OpenGL.
 
vec4 VVizTransferFunction (in VVIZ_DATATYPE voxelValue, in int Id)
 1D transfer function.
 
vec4 VVizTransferFunction (in VVIZ_DATATYPE frontVoxelValue, in VVIZ_DATATYPE backVoxelValue, in int Id)
 Pre-integrated transfer function.
 

Detailed Description

VolumeViz VolumeViz GLSL fragment shaders API.

Function Documentation

◆ VVizClipVoxel()

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.

◆ VVizCombineData()

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
dataCoordUniform data coordinate in the volume space of the default DataSet (see VVizGetDefaultDataSet()).
Returns
voxel data value.

◆ VVizComputeCoordinates() [1/2]

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
dataCoordCoordinates of point, in the normalized volume space of the default DataSet.
Returns
Projected coord if requested, returns dataCoord by default.

◆ VVizComputeCoordinates() [2/2]

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
datasetDataset id
dataCoordCoordinates of point, in the normalized volume space of dataset.
Returns
Projected coord if requested, returns dataCoord by default.

◆ VVizComputeFragmentColor()

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
datasetDataset id
rayDirray Direction in the volume space of dataset.
voxelInfoFrontVoxel info of front slice.
voxelInfoBackVoxel info of back slice
maskCurrent mask Id

◆ VVizComputeGradientCommon() [1/2]

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)

◆ VVizComputeGradientCommon() [2/2]

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.

◆ VVizComputeIsoMaterial()

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.

◆ VVizComputeNormal() [1/3]

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.

◆ VVizComputeNormal() [2/3]

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)

◆ VVizComputeNormal() [3/3]

vec3 VVizComputeNormal ( vec3  view,
vec3  grad 
)

Returns the current normal.

◆ VVizComputePreIntegrated()

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.

◆ VVizComputePreintegratedGradient()

vec3 VVizComputePreintegratedGradient ( vec3  tcoord0,
vec3  tcoord1 
)

Returns the gradient at the center of the two slices.

◆ VVizComputePreintegratedLighting() [1/2]

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.

◆ VVizComputePreintegratedLighting() [2/2]

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.

◆ VVizComputeViewVec() [1/2]

vec3 VVizComputeViewVec ( )

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

◆ VVizComputeViewVec() [2/2]

vec3 VVizComputeViewVec ( in VVizDataSetId  dataset)

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

◆ VVizComputeVolumeRendering()

vec4 VVizComputeVolumeRendering ( VVIZ_DATATYPE  sf)

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

◆ VVizComputeVolumeRenderingLighting() [1/2]

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

Add lighting to the color col.

col is usually the result of VVizComputeVolumeRendering.

◆ VVizComputeVolumeRenderingLighting() [2/2]

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.

◆ VVizGetData()

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
datasetThe dataset to read
dataCoordUniform data coordinates in volume space.
Returns
voxel data value.

◆ VVizGetLuminance()

float VVizGetLuminance ( VVIZ_DATATYPE  data)

Compute the luminance of a voxel value.

Parameters
datavalue to convert
Returns
Luminance of data.

◆ VVizGetMask()

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.

◆ VVizGetNearestCoord() [1/2]

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.

◆ VVizGetNearestCoord() [2/2]

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.

◆ VVizGetRawData()

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
datasetThe dataset to read
dataCoorduniform data coordinates in volume space.
Returns
voxel data value

◆ VVizIsClipped()

bool VVizIsClipped ( vec3  tCoord)

Customizes the SoVolumeShader::CLIPPING_FUNCTION shader stage.

Parameters
tCoordCoordinate in the volume space of the default DataSet (see VVizGetDefaultDataSet())
Returns
TRUE if given tCoord should be clipped.

◆ VVizIsClippedByROI()

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.

◆ VVizOutputColor()

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
colorthe color to render.

◆ VVizOverOperator()

vec4 VVizOverOperator ( vec4  underCol,
vec4  overCol 
)

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

Parameters
underColFirst color to blend.
overColSecond color to blend.
Returns
Blended color.

◆ VVizTransferFunction() [1/2]

vec4 VVizTransferFunction ( in VVIZ_DATATYPE  frontVoxelValue,
in VVIZ_DATATYPE  backVoxelValue,
in int  Id 
)

Pre-integrated transfer function.

Parameters
frontVoxelValueInput voxel data value of the front slice.
backVoxelValueInput voxel data value of the back slice.
Idof the transfer function to use.
Returns
Color of the value based on the transfer function id

◆ VVizTransferFunction() [2/2]

vec4 VVizTransferFunction ( in VVIZ_DATATYPE  voxelValue,
in int  Id 
)

1D transfer function.

Parameters
voxelValueInput voxel data value
Idof the transfer function to use.
Returns
Color of the value based on the transfer function id