LightningChart .NETVolume Rendering

ArticleReviewing the LightningChart .NET VolumeRendering function.

Written by human | Updated on February 23rd, 2024

Volume Rendering: VolumeModels

VolumeModels is a tool for volume data visualization via Direct Volume Rendering. The VolumeModel takes the volume data inside and visualizes it. LightningChart’s volume rendering engine is based on Volume Ray Casting.

An image is produced by the algorithm via the volume data sampling along the tracks of the rays that travel inside the dataset. A simple realization of hardware acceleration for Volume Ray Casting requires generating boundaries for a volume object. Usually, they are represented by a cube. High rendering quality without artifacts and usage of the interchangeable ray function are the main advantages of this technology.

RayFunction is the core of the algorithm providing it with a very high level of flexibility. The technique is powerful because it specifies the way how the data is sampled and combined. This makes it a very useful tool for feature extraction. Note that VolumeModels are available only when DirectX 11 renderer is used.

Loading Data

There are several ways how the data can be imported into the VolumeModelto create volume rendering applications with LightningChart .NET:

  • Data can be supplied to Data property as a collection of images that represent slices of the dataset
  • Data can be supplied directly to the constructor of the VolumeModel in various ways
  • Data can be supplied to the VolumeModel via one of the load functions

Load functions and constructors allow supplying data as a collection of slices (similarly to Data property) or as a string with a path to the folder with the slices (as .Net supported image extension). The data can also be provided as a texture map created by our tool. A texture map consists of slices, but its supplement also needs additional information about the number of slices in the picture. This is required for efficient usage of GPU input buffers. Texture maps can be created via ChartTools.CreateMap function. Direct input of texture map is used to speed up the start of an application for a very big dataset.

Properties

VolumeModel contains typical properties of a 3D object in LightningChart, for example Visible, Rotation, Size, Position, and AllowUserInteraction. In addition, the object has specific properties, which define how the Volume Rendering engine handles it.

Property-Tree-Volume-Models

Figure 7‑80. Property tree of VolumeModels

Ray Function

The RayFunction property allows choosing one of the three ways of voxel sampling and composition available in the LightningChart Volume Rendering Engine:

  • RayFunction.Accumulation collects and combines as much data as possible. The visualization which is produced by this technique looks like a semi-transparent gel. The figure below shows an example of RayFunction.Accumulation application visualizing a medical dataset.
Example-of-a-medical-application-for-the-RayFunction.Accumulation

Figure 7‑81. Example of a medical application for the RayFunction.Accumulation

  • MaximalIntensity takes into account only the brightest values sampled by the ray. Visually it provides a very similar result to X-ray images. It allows us to get additional information about the internal structure of the object. RayFunction.MaximalIntensity applications for skeleton visualization and ultrasound wave interference simulation are shown below.
Examples-of-a-Maximum-Intensity-Ray-Function-application

Figure 7‑82. Examples of a Maximum Intensity Ray Function application

RayFunction.Isosurface draws the model surface in a way that looks like a polygonal model rendering. The result is very similar to those produced by Indirect Volume Rendering. Figures show examples of RayFunction.Isosurface applications for the visualization of human skull CT and simulation of water flow.

Figure 7‑83. Examples of an Isosurface Ray Function application

Threshold

The Volume Rendering Engine can apply a threshold range by a property to the VolumeModel. There is a separate boundary for every color channel. The voxel is visualized only if the corresponding color values are lower than the high boundary and higher than the low boundary at all the channels. Acceptable areas are invisible. This property is not taken into consideration by the mouse hit test.

volume-rendering-Example-of-two-different-threshold-settings

Figure 7‑84. Example of two different threshold settings

Color clipping

The Volume models have ClipColorRange and ColorRangeToClip properties, just as Threshold, can be used to clip certain colors from the model. However, they work the opposite way. Color clipping doesn’t render colors within the defined color ranges, whereas Threshold removes colors outside the range.

ClipColorRange controls whether color clipping is enabled or not. ColorRangeToClip allows setting the actual color ranges that should be removed. The minimum and maximum clip values can be set via the Min and Max properties for each color channel, separately. Alternatively, all values can be modified simultaneously by assigning the RangeRGB object to ColorRangeToClip. The clipped values should be between 0 and 1 where 0 means color value 0 and 1 value 255. After the ranges have been set, each color combination that is within the defined ranges will be clipped. Clipping takes all color channels into account simultaneously.

// Enabling color clipping.
_chart.View3D.VolumeModels[0].ClipColorRange = true;

// Modifying a single channel value.
_chart.View3D.VolumeModels[0].ColorRangeToClip.Min.R = 0.1;

// Assigning all clip ranges simultaneously.
_chart.View3D.VolumeModels[0].ColorRangeToClip =
new RangeRGB(new PointRGB(0, 0, 0), new PointRGB(0.2, 0.2, 0.2));
Original-Volume-Model-on-the-left.-On-the-right,-color-clipping-is-used-to-remove-the-blue-channel.

Figure 7‑85. Original Volume Model on the left. On the right, color clipping is used to remove the blue channel.

Slice Range

SliceRange property allows cutting away a part of the VolumeModel. It is a very useful tool for the exploration of the object’s internal structure. SliceRange contains two boundaries, Min and Max, both of which are represented by three pointing float values.

Example-of-Accumulation-Ray-Function-and-SliceRange-modification

Figure 7‑86. Example of Accumulation Ray Function and SliceRange modification

Sampling Rate Options

SamplingRate is a very important property of the final image quality. It defines how often the volume dataset is sampled along the ray’s track. Higher SamplingRate produces better quality but requires more powerful hardware. SamplingRate influences RayFunction options, especially Accumulation. Artifacts produced by a low sampling rate are less noticeable when using Maximal Intensity. Furthermore, the Isosurface can be too sharp at a very high sampling rate. Usually, the sweet spot equals the number of voxels on the side that is placed along the ray tracks.

SamplingRateOptions contains several options for SamplingRateManager. SamplingRateManager is needed to reach the optimal balance between quality and frame rate for hardware. By default, SamplingRateManager is turned on by the property Enabled is set to true. If set to false, the ManualSamplingRate value will be used. SamplingRateRange defines the boundaries for SamplingRateManager. Inertness specifies how rapid is the reaction of the sampling rate in case of performance changes. TargetFPS is a target value, that which sampling rate manager tries to achieve.

Example-of-low-sampling-rate

Figure 7‑87. Example of low sampling rate: 32(left), 64(right)

Smoothness

Smoothness property prevents too high detalization of the surface. It smoothens the surface of the model and reduces some noise and other artifacts.

Example-of-too-high-sampling-rate,-fixed-by-smoothness-property

Figure 7‑88. An example of too high sampling rate, fixed by the smoothness property

EmptySpaceSkipping

EmptySpaceSkipping property defines a resolution of empty space, skipping sampling. A low value (16-32) of EmptySpaceSkipping improves the performance but can cause artifacts in the model edges.

Example-of-too-high-sampling-rate,-fixed-by-smoothness-property

Figure 7‑89. Example of too low EmptySpaceSkipping property value

Opacity, Brightness, & Darkness

The volume rendering property features Opacity that specifies the behavior of the Accumulation option of the RayFunction. The lower the Opacity, the more transparent the object will be.

The brightness and darkness properties define the image’s transfer function. Every change has its transfer function. It is represented by the linear function:

output = Brightness * input - Darkness

volume-rendering-opacity-example

Figure 7‑90. Example of Accumulation Ray Function Opacity modification: 15% (left), 45(right)

Conclusion

In this article, we introduced the concept and techniques of volume rendering, a data visualization method that creates a 3D representation of a scalar field. You know now how to implement texture-based volume rendering on modern GPUs, using the LightningChart .NET. Some key takeaways are:

  • Direct volume rendering: how to map data values to optical properties and accumulate them along viewing rays.
  • Texture-based volume rendering: how to use 3D textures and slicing planes to approximate the ray integration process.
  • Implementation details: how to load data, set up transfer functions, apply clipping and slicing, adjust sampling rate and smoothness, and enable EmptySpaceSkipping.
  • Advanced techniques: how to enhance the rendering with lighting effects and procedural details.

I invite you to continue developing volume rendering applications with our latest volumetric rendering .NET tutorial.

Kestutis Gurevicius

Kestutis Gurevicius

CTO, Scientific Software Analyst, Support, Team Lead (.NET)

LinkedIn icon
divider-light

Continue learning with LightningChart