Volume Rendering Enhancements in VTK

VTK is undergoing an overhaul in its backend rendering engine to provide faster high-performance rendering and support the latest hardware infrastructures. One of the many areas of improvement in VTK is its volume rendering capabilities. Back in October 2014, we introduced the new vtkOpenGLGPUVolumeRayCastMapper under the vtkRenderingOpenGLNew module. Since then, the new mapper has been through tremendous improvement. This write-up will highlights some of these improvements.

 

The temporary module vtkRenderingOpenGLNew has been obsoleted in VTK version 6.3. The new mapper along with its helper classes are now part of the vtkRenderingVolumeOpenGL2 module. This means the new volume mapper is available to all applications that use VTK with its OpenGL2 rendering backend. Most of the initial features of the new vtkOpenGLGPUVolumeRayCastMapper are demonstrated in the Kitware Source article from October 2014 titled “Volume Rendering Improvements in VTK”. These include supporting a wide array of data types, cropping using a set of 6 planes to define 27 cropping regions, clipping using arbitrary clipping planes, opacity blend modes, masking and gradient magnitude based opacity modulation.

 

Multi-Component data support

Often times, there is a need to visualize volumetric data using multiple channels at the same time. The vtkGPUVolumeRayCastMapper now supports volumes with more than one component.

There are two different modes supported: Representing components independently (the default) or defining a relationship among them. The representation can be defined by calling the (Set/Get)IndependentComponents function on the vtkVolumeProperty. By default, this property is enabled and each component’s value is mapped through the color and opacity lookup tables provided. When IndependentComponents is disabled, the following logic is used:

  • Volumes with 2 dependent components: The first component defines the final rendered color value based on a lookup table; whereas the second component determines the final opacity opacity value for that voxel.

  • Volumes with 4 dependent components: The first three components are used to directly represent red, green and blue color channels respectively while the last component is mapped through the opacity lookup table to define opacity value for the voxel.

 

 

Performance optimization

One major code optimization was in the computation of the lighting model. This improvement led to about 300% improvement in performance for the new renderer. The new mapper performs about 35% faster than its OpenGL version 1 counterpart and about 135% faster than the vtkFixedPointVolumeRayCastMapper, with shading enabled.

 

OpenGL 3.2 core context

The new volume mapper supports the OpenGL 3.2 Core context. Much of the calculations including bias and scale computations are offloaded to the GPU for faster computation.

 

Depth and Color data

vtkGPUVolumeRayCastMapper now has added functionality of being able to export the color and depth textures as vtkTextureObject / vtkImageData post rendering. This allows the mapper to be used in various deferred rendering setups including remote compositing and rendering. To enable this feature one must set the boolean “RenderToImage” on the mapper. When rendering to image, the mapper renders to a FrameBufferObject. The textures can then be retrieved using GetDepthImage / GetColorImage methods.

Other updates

  • New OpenGL2 GPU volume mapper respects Interpolation Type (Linear or Nearest). Default is Nearest as the one used by the OpenGL GPU mapper.

  • Fixed lighting bug. Number of lights kept increasing in the scene every time the volume property was modified.

  • Saving and Restoring GL state properly for textures

  • Changed some GL texture format information to support OpenGL 3 context

  • Fixed extensions not being reported correctly for OpenGL2 backend

  • Fixed few failing tests specifically on Mesa

  • Added convenience API to vtkSmartVolumeMapper

  • Fixed volume cropping bugs

  • Fixed crash when the underlying context changes

  • Fixed Mac OSX specific volume rendering issues

  • Improved interactive performance for large volumes

  • Fixed extents not getting updated in presence of other filters

  • Fixed window color adjustments

  • Fixed issue with noise textures

  • Added volume rendering benchmarking tests

  • Added new volume tests. Now testing various features that were not tested before (52 volume tests now)

  • Fixed graphics resource release issues

  • vtkGPUVolumeRayCastMapper now uses vtkTextureObject

  • Using the shader cache for volume rendering

Questions or comments are always welcome!