Screen-Space Ambient Occlusion for volumes

December 19, 2023

Screen-space ambient occlusion (SSAO) was introduced in VTK 9.0 to simulate the ambient occlusion on surfaces where light is obstructed by the surrounding geometry. The approach is an approximation of the ambient occlusion you get with more advanced rendering approaches like ray tracing, but it runs in real time with a very low impact on performances and produces outstanding results when it comes to increasing the depth perception on a rendered model.
The approach has been extended and is now available for volume rendering (not just surfaces).

A volume-compatible approach

The idea is to extend the volume rendering raycasting algorithm to output the normal and position information that is required by the SSAO algorithm.
The SSAO pass can then combine this information as it would do for regular surface rendering, in order to add ambient occlusion to the rendered volume.

Volume rendered CT scan of Drosophila: left: SSAO enabled, right: SSAO disabled

The fragment position is by nature computed during the raycasting algorithm and corresponds to the position of the current sample along the ray.
Similarly, normals are already computed using the local gradient value for each sample when shading is enabled.
The GPU volume raycast mapper has been modified in VTK to allow encoding the such positions and normals in additional GPU textures as required by the SSAO pass.
However the SSAO approach works by design on surfaces, where positions, normals and depth are located on the same surface layer. When adapting the algorithm to volume rendered data, we must define the opacity isovalue for which a sample should write the required information. The first sample along the ray having an opacity greater than this threshold value will write its position and normal into the textures and prevent any further voxel along the ray to override this information.
This produces an opacity layer (isocontour) on which ambient occlusion will be applied. The SSAO pass can then use this information as if it was a regular surface.

Internal textures generated when rendering a volume with SSAO

Because the management of the internal textures presented above is done at the pass level, the volume information is written in the same textures as previously rendered opaque surfaces. Hence the effect is fully compatible with volumes being mixed with surfaces.

How to use

The setup of the SSAO pass is the same as when using surface only, except that the format of its depth texture must be set to Fixed32 for the GPU volume mapper to copy the existing depth texture successfully.
The opacity threshold value defining the ambient occlusion layer has a default value of 0.9 but can be controlled using `vtkSSAOPass::SetVolumeOpacityThreshold`
As a rule of thumb this value can be set to the opacity value of the first visible pixels at the boundaries of your volume.
Finally, it is required to turn on shading on the volume property to successfully compute and provide normals to the SSAO pass.

// Shading must be turned on to compute normals


vtkNew<vtkRenderStepsPass> basicPasses;
double sceneSize; // e.g. the diagonal of the bounding box

vtkNew<vtkSSAOPass> ssao;
ssao->SetRadius(0.1 * sceneSize); // comparison radius
ssao->SetBias(0.001 * sceneSize); // comparison bias
ssao->SetKernelSize(128); // number of samples used
ssao->BlurOn(); // blur occlusion
// The depth format must be Fixed32 for the volume mapper to successfully copy the existing depth texture
// Control the opacity threshold defining the occlusion layer


Colorize Volume

The implementation described above has been carried by the interest and efforts from the 3D Slicer community.
The idea of adapting SSAO to volume rendering follows the addition of the Colorize Volume module in 3D Slicer, and was driven by the desire to have more comprehensive volume rendered representations with few impact on performances. This Colorize Volume approach highlights anatomical structures by combining a CT scan with the corresponding segmented labelmap. Adding SSAO to such representations allows for enhancing the depth perception of anatomical structures further, and increases spatial understanding of the whole volume.

More information will be provided when the combination of both the Colorized Volume and SSAO for volumes techniques will be fully available in 3D Slicer.

Colorize Volume with opaque transfer function: left: SSAO enabled, right: SSAO disabled
Colorize Volume with translucent transfer function: left: SSAO enabled, right: SSAO disabled

Collaborate with Kitware

This work has been completed thanks to internal efforts and funding from Kitware Europe.
Our teams are mainly composed of computer scientists, software engineers, and visualization experts. We provide professional support for the development of applications using VTK, including training, consulting and technical support services.

Contact us to learn how Kitware can help leverage the functionality and integrate it in your custom application.

Leave a Reply