2D Transfer Function Support in GPUVolumeMapper

September 1, 2017

It is well known that transfer function specification is a crucial task for quality volume rendering, given that transfer functions map original data values to properties such as color and opacity.  Unfortunately, their specification can prove a challenging task.

Volume mappers in VTK have always supported specifying color and opacity based on two independent characteristics of the scalar field to render: scalar value and gradient magnitude.   Currently, these two parameters are used to map color and opacity using three independent 1D functions:  scalar value to color,  scalar value to opacity and  gradient magnitude to opacity.  This method has a clear advantage: its simplicity.  A single parameter per function normally keeps things straightforward enough for a user to find a relatively good transfer function.

In some cases however, it is advantageous to increase the number of parameters in a function in order to improve discrimination between structures in the volume data.  This, given that the combined parametric information allows to disambiguate areas that fall within a given range for those parameters simultaneously.  Thanks to recent developments in tomviz under DOE Office of Science contract DE-SC0011385, it was possible to add support for 2D transfer functions in the GPU mapper (scalar value vs. gradient magnitude).  This will enable users to choose between either the legacy 1D transfer functions or a single 2D transfer function, depending on their needs.  vtkVolumeProperty holds references to all of the transfer functions so it is possible to switch between the two modes by setting the appropriate flags.  The legacy 1D triad will be used by default so 2D mode needs to be enabled explicitly.

Additions to vtkVolumeProperty

A 2D transfer function is defined as a 4-component-float vtkImageData object.  The property keeps track of these instances and exposes them to the volume mapper at render time.  Only vtkGPUVolumeRayCastMapper supports this functionality (OpenGL2 backend).

vtkNew<vtkImagData> transferFunc;

// Fill up transferFunc with meaningful information

vtkNew<vtkVolumeProperty> property;

// Switch between 1D transfers and 2D

More information can be found in TestGPURayCastTransfer2D.

In progress

Although mapper support for this feature is already available in VTK, widgets to aid the definition of these functions is work-in-progress.  An initial version of a widget for this purpose (based on the vtkContextItem framework) with basic functionality is currently available only in tomviz and will be ported to VTK in the future.

1 comment to 2D Transfer Function Support in GPUVolumeMapper

Leave a Reply