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.
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.
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.
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).
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.
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.
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.
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.
These results were generated in VTK and in ParaView and represent various types of datasets.
|Dataset (fps)||Scattering off||GI = 0.0||GI = 0.1||GI = 0.2||GI = 0.3||GI = 0.4||GI = 0.5||GI = 0.6||GI = 0.7||GI = 0.8||GI = 0.9||GI = 1.0|
|Cloud bunny (25MB)||92||72||25||14||8.5||7.0||6.3||4.6||4.1||3.6||3.4||3.4|
|Average relative render time||x1||x1.6||x8.3||x17||x26||x36||x45||x56||x63||x69||x72||x75|
This work was funded by an internal innovative effort of Kitware Europe.