Volumetric Rendering in VTK and ParaView: Introducing the Scattering Model on GPU

July 8, 2022

Introduction

Volumetric Rendering in VTK and ParaView offers many possibilities to users wishing to visualize volumetric data. Specifically, medical and climate data can benefit from these rich visualizations. This article describes recent development in this domain to provide cinematic volumetric rendering in VTK and ParaView.

Context

Volumetric mappers in VTK use ray marching algorithms to render a volume with a given opacity and color transfer functions. These methods compose colors along the ray to compute the final color for each pixel. An option allows the user to shade the volume in order to make surfaces appear more clearly during the rendering. Previously and when shading was enabled, the volume was approximated locally by a surface using the volume’s gradient and a standard Phong’s illumination model was applied.

This shading feature lets the observer intuitively understand the nature of the represented volume, its shape and its texture. However, it does not always yield realistic results and can fail to accurately represent the depth and density of the rendered material. The objective of this project was to develop new rendering techniques, based on light scattering, to increase volume rendering realism. 

This work was realized in VTK’s GPU-based volumetric mappers for image datasets. Unstructured grid and AMR mappers are not yet supported.

Comparison between the former shading model and the new one on a medical dataset representing a human thorax

Illumination model integrated into VTK

The newly implemented alternative illumination model is based on the physical behavior of light: while traversing a medium, photons can either be absorbed by matter or scattered in another direction. Both types of events are controlled by material-dependent properties. When we integrated our work into VTK, we associated both absorption and out-scattering with the volume’s opacity, because it corresponds to the light’s extinction inside the volume. In-scattered light is modeled by evaluating the light coming from secondary rays.

Absorption and scattering along the primary ray

Based on the state of the art, we decided to enhance the existing ray marching algorithm by adding a single secondary ray. More complex approaches computing multiple scattering were tested but were ultimatly not kept because interactive visualization of big datasets could not be performed in real time. As such, in our solution, at every sample point, we shoot a secondary ray towards each light source and estimate the light transmitted along each ray. The resulting quantity is integrated at each sample point and scattered using a Henyey-Greenstein phase function.

This new functionality is controlled via a new parameter in VTK, called Global Illumination Reach. It is a value between 0 and 1, and it acts as a trade-off between realism and performance. More precisely, it controls the extent of the secondary ray: a value close to 0 will result in very short secondary rays (less realistic, only ambient occlusion, but faster), whereas a value close to 1 will result in long-extent shadow rays (more realistic, but slower).

Secondary rays cast at each sample point inside the volume towards the light sources

Additionally, It is now possible to set the anisotropy of the volume in its properties, and to render complex physical effects in a forward or backward scattering medium. This parameter was already used by OSPRay, and is now a standard feature of VTK’s volume rendering.

Volumetric dataset of a cloud (Disney Enterprises, Inc. under the Creative Commons Attribution-ShareAlike 3.0 Unported License), a forward-scattering medium

Visual blending between the two models

As a result of this effort, there are now two rendering models for volumes: VTK’s native shading, and the new volumetric scattering model. Both models have advantages: the native one is specialized in extracting and highlighting local surfaces, while the new one is more realistic and is better at handling “soft volumes”. For these reasons, we decided to keep both models in VTK and to expose a blending coefficient, called Volumetric Scattering Blending. This coefficient, between 0 and 2, controls the blending between the two models, and can achieve renders with both highlighted local surfaces and volumetric scattering effects. Setting it to 0 (the default value) results in VTK’s native shading, while a value of 1 results in a smart combination of both models, and a value of 2 leads to a full volumetric model result. This smart combination gives priority to the first model when a high opacity gradient is encountered, and to the volumetric model otherwise.

An illustration of the effect of this new property is given below: the right half of the volume has a very high gradient as the sphere opacity goes from 0 to 1 in a single voxel, and the left one has a softer and cloudier opacity distribution. It is illuminated with VolumetricScatteringBlending = 1, so the right half is illuminated mainly according to Phong’s reflection, whereas the left half has a more volumetric shading, with ambient shadows and scattering.

Representation using the smart blending feature of a volume whose right half has a high density gradient, and whose left half has a smooth gradient

Integration into ParaView

In ParaView, several new parameters have been exposed: first, the Volumetric Scattering Blending and the Global Illumination Reach. They are specific to GPU-based volume rendering, and are listed in the “Volume Rendering” section. To enable GPU-based volume rendering once the dataset is loaded, the first step is to switch the representation type to “Volume”. Then, in the Display Properties and in the Volume Rendering section, it is possible to switch to GPU rendering with the “Volume Rendering Mode” option.

We also added a scattering anisotropy parameter in the Volume Rendering properties although it is not a rendering parameter but a volume property. Note that this is an advanced parameter. As OSPRay also had an anisotropy parameter, we deprecated this former parameter and removed it from the GUI. It used to be in the View Properties, and could be set in the OSPRay parameters when it was enabled. OSPRay now uses this new scattering anisotropy parameter, which is in the Volume Rendering properties.

New volumetric rendering features in ParaView

The integration of these new parameters into the UI is illustrated in the screenshot below. We also exposed the TwoSidedLighting parameter in the RenderView settings, in Edit -> Preferences -> Render View -> TwoSidedLighting. This feature allows the user to simulate both forward and backward flowing light, and can now be enabled or disabled in ParaView.

Results

These results were generated in VTK and in ParaView and represent various types of datasets.

Comparison of a combustion dataset with the former shading model, and with the new one
Comparison between VTK’s gradient shading and the new volumetric shading on three datasets: a cloud, and two medical datasets
Comparison between VTK’s gradient shading and the new volumetric shading on OpenVDB fog datasets
Dataset (fps)Scattering offGI = 0.0GI = 0.1GI = 0.2GI = 0.3GI = 0.4GI = 0.5GI = 0.6GI = 0.7GI = 0.8GI = 0.9GI = 1.0
Combustion (130MB)43255.22.51.61.10.850.690.590.540.530.52
Cloud (49MB)32162.11.00.650.470.370.300.270.250.240.23
Thorax (77MB)32194.02.01.30.920.710.590.510.460.430.42
Kidneys (29MB)4833169.27.14.53.62.92.52.32.12.1
Cloud bunny (25MB)927225148.57.06.34.64.13.63.43.4
Explosion (50MB)22161.90.940.610.450.360.300.260.240.230.22
Average relative render timex1x1.6x8.3x17x26x36x45x56x63x69x72x75
Benchmark of of the new features compared to the former render mode (without the scattering model). The measures were made on six datasets with still render, on a NVIDIA GeForce GTX 1050.

Acknowledgments

This work was funded by an internal innovative effort of Kitware Europe.

8 comments to Volumetric Rendering in VTK and ParaView: Introducing the Scattering Model on GPU

  1. Really nice!
    How can VDB files (such as the Disney Cloud dataset above) be loaded into Paraview? I couldn’t find a reader for that in Paraview GUI.

    1. The OpenVDB reader is a very recent reader which didn’t exist at the time of ParaView 5.10 and that will not be shipped with ParaView 5.11. However if you build your own ParaView you will be able to use it enabling the CMake option PARAVIEW_ENABLE_OPENVDB

  2. I have “volume renderding” my data. But the “Opacity” of the images remains the same. What is the reason for this.I would greatly appreciate your answer.Thanks

  3. Your work is fantastic, may I ask how exactly the rendering method based on multiple scattering model is done? Is there any relevant study material?

Leave a Reply