Advanced Homogeneous Volumes

Description

The previously implemented volumes were defined through a density scalar and assigning an albedo to the phase function. To accurately reflect reality, we need to substitute these simplified parameters with the physically based coefficients that define a homogeneous volume: the scattering coefficient \( \sigma_s \), the absorption coefficient \( \sigma_a \), and the emission coefficient \( \sigma_e \).

Reminder that the volume transfer equation is defined as: \[L_o(p, \omega_o) = L_o(z, \omega_o) T(||z - x||) + \int_{0}^{||z - x||} T(t) \left(\sigma_a(y) L_e(y, \omega_o) + \sigma_s(y) \int_{\Omega} f_p(y, \omega_i, \omega_o) L_i(y, \omega_i) d\omega_i \right) dt\] \[T(t) = e^{-\int_{0}^{t} \sigma_t(y) dy} \quad \text{with} \quad \sigma_t = \sigma_a + \sigma_s\] This extension allows us to capture real world volumetric effects such as colored shadows, volume gradients due to absorption, and self-emitting volumes.

Implementation Details

Spectral Coefficients & Data Structure:
To accurately model homogeneous media, I transitioned from simple scalar density and albedo values to full spectral Color coefficients for scattering (\(\sigma_s\)), absorption (\(\sigma_a\)), and emission (\(\sigma_e\)). This required updating the Intersect struct to carry this volumetric data and modifying the Volume class to store these channel-wise parameters. Consequently, the transmittance calculation within the integrator was updated to use the full extinction coefficient \(\sigma_t\) rather than a scalar density.

Intersection & Sampling Strategy:
The intersection routine was completely overhauled to support non-convex shapes using a ray-marching approach, allowing the renderer to find multiple intersection intervals within a single volume.
Because we must sample a specific color channel to determine intersection distance, a "sampling weight" must be tracked to correct for this Monte Carlo decision. This introduced a challenge for paths that miss the volume (or traverse it without interacting), as the channel selection probability must still be accounted for. To solve this, I implemented a new function in the shape interface, volumeMissSamplingWeight. This function traverses the scene to calculate the necessary weights for volumes that are missed, ensuring that the Next Event Estimation (NEE) and escape paths remain unbiased.

Volumetric Emission:
Finally, I added support for volumetric emission defined by either temperature or raw color values. Unlike the blackbody radiation implementation elsewhere, this allows rays to continue bouncing through the medium, accurately simulating glowing gas or plasma.

Renders

Advanced Homogeneous Volumes

Advanced Homogeneous Volumes showcasing all the implemented properties:
  • Mesh as the volume shape, accurately supports multiple intervals
  • Directional light (NEE) pointing towards the wall accurately creating colored shadows
  • BSDF lights (lamp and the emissive volume) also accurately creating colored shadows
  • The absorption of the volume itself causing its color to shift, as the light passing through it gets absorbed
Basic Homogeneous Volumes using density and albedo. Shadows of the same color as the volume, no absorption effect. Also no emission from the ellipsoid volume.

Basic Coefficients showcase with NEE light

Absorption and Scattering coefficients.
Scalar Density and Albedo.

Volumetric Emission

Volume with Emission coefficient.

Hollow Volume Test

Hollow volume test with a mesh shape.
Difficulties

The main difficulties were regarding the sampling weights, firstly in the interaction step. Another issue that came up was the modification of the Intersect struct, as I initially tried to add a Color field, but various include errors prevented that from working. I decided to just insert a Vector and cast it to a Color when needed.

The second big difficulty was actually implementing the missing sampling weight, as it was something I only realized was necessary way after I deemed the project be finished. There was some conceptual difficulty as I didn't want to re-traverse the entire scene for it, so I tried to find a way to calculate the data during the initial intersection. However, I realized that it was not possible, as the BVH traversal might return a surface hit that is inside the volume, but for which we calculated the entire miss sampling weight. Thus, I had to re-traverse the scene during the miss step, which was not ideal performance-wise, but it was the only way to ensure correctness.

Heterogeneous Volumes

Description

While homogeneous volumes assume constant properties, real-world media like smoke, fire, and clouds exhibit complex spatial variations in density and temperature. Heterogeneous volumes model these variations, allowing for rich details where the scattering and absorption coefficients change at every point within the medium. This feature enables the rendering of organic, spatially varying phenomena that interact with light in complex ways.

Implementation Details

Data Structures & Loading:
To handle heterogeneous volumetric data, I integrated the OpenVDB library—specifically the header-only NanoVDB variant to minimize dependencies. I created a new VoxelVolume class designed to load and query float grids for density and temperature, and implementing the intersection and transmittance functions.

Sampling Strategy (Delta & Ratio Tracking):
Unlike homogeneous volumes where distance sampling is analytical, heterogeneous volumes require stochastic sampling due to the varying extinction coefficient \(\sigma_t(x)\). I implemented Delta Tracking, which utilizes a global majorant coefficient \(\sigma_{t_{max}}\) that bounds the maximum density in the volume. The integrator samples tentative collisions based on this majorant and probabilistically accepts them based on the local ratio \(\frac{\sigma_t(x)}{\sigma_{t_{max}}}\). Similarly, for calculating transmittance (visibility), I implemented Ratio Tracking, which provides an unbiased estimator for the transmittance without needing expensive ray marching steps.

Emission Models:
The system supports two types of volumetric emission. The density grid can act as a scalar for a constant emission color. Alternatively, the temperature grid can drive a blackbody radiation model. Crucially, the blackbody implementation treats the emitting matter as opaque at the point of generation, terminating the path upon intersection to simulate thick, super-heated fuel.

Renders

Heterogeneous Volumes

  • Left: Fire with both density and temperature grids.
  • Middle: Fire with only a density grid.
  • Right: Fire with a density grid with emission.

Attributions

  • Fire VDB: "Fire" from OpenVDB sample models. Link
Difficulties

While the concepts of Delta and Ratio tracking were theoretically straightforward, the primary challenge lay in the practical integration of the NanoVDB library.