Voxel Cone Tracing with 3D Clipmaps in DirectX

Voxel cone tracing is a real-time global illumination technique that approximates ray tracing by voxelizing scene geometry and casting wide cones through a filtered spatial hierarchy to compute indirect lighting, specular reflections, and ambient occlusion. Because storing uniform high-resolution voxel grids over large scenes requires prohibitive amounts of video memory, developers employ 3D clipmaps—a series of nested, view-dependent 3D grids—to manage memory and detail. Within Microsoft DirectX, these clipmaps are realized through 3D textures, conservative rasterization, and compute shaders, delivering scalable, dynamic indirect lighting for modern graphical applications.

Understanding Voxel Cone Tracing

Voxel cone tracing (VCT) simplifies the computational burden of traditional path tracing. Instead of evaluating thousands of individual rays per pixel to resolve indirect light paths, the scene is transformed into an emissive and opaque 3D volume known as a voxel grid. During rendering, shaders trace continuous cones through this volume.

As a cone advances through space, its radius expands proportionally with distance. The shader queries pre-filtered voxel data whose level of detail matches the footprint of the cone at that specific distance. A narrow cone with a tight opening angle represents sharp, glossy reflections, while a wide cone simulates diffuse indirect bounces or ambient occlusion. This process relies on hardware trilinear interpolation between filtered voxel levels, turning what would be thousands of stochastic ray-triangle intersections into a handful of texture samples.

The Problem of Spatial Scale and the 3D Clipmap Solution

A naive voxel grid scales cubically: doubling the resolution across three dimensions increases memory consumption by a factor of eight. A uniform grid dense enough to capture fine geometry across a typical game world quickly exceeds modern GPU memory limits.

To solve this, developers implement 3D clipmaps (or cascading voxel grids). Rather than maintaining a single high-resolution grid for the entire scene, 3D clipmaps arrange multiple concentric voxel volumes centered around the camera:

  • Inner Levels: Cover a small volume immediately surrounding the viewer at very high spatial density, preserving geometric detail where it is most noticeable.
  • Outer Levels: Span exponentially larger volumes with progressively lower spatial resolution, capturing distant blockers and large-scale light bouncers.

When a cone is traced, it starts in the finest clipmap level. If the cone travels beyond the boundaries of that level or expands wider than the level's cell resolution, the sampling algorithm smoothly transitions into the next, coarser clipmap level.

Implementing 3D Clipmaps in DirectX

Modern DirectX (DirectX 11 and DirectX 12) provides the low-level graphics pipeline controls required to generate and sample 3D clipmaps efficiently.

1. Storage via Texture3D Arrays and UAVs

Clipmap levels are commonly allocated as a single Texture3D array or multiple flat 3D texture resources bound to the pipeline. In DirectX 12, these textures are accessed via Unordered Access Views (UAVs) using formats such as DXGI_FORMAT_R8G8B8A8_UNORM for color and occlusion, or 16-bit half-float formats for higher dynamic range radiance.

2. Voxelization and Conservative Rasterization

Geometry is injected into the clipmap during a voxelization pass without generating an actual 2D render target. DirectX’s hardware Conservative Rasterization (available through Direct3D 12 Feature Levels 12_0 and higher) ensures that any voxel touched by a triangle fragment—even partially—is rasterized. Geometry shaders or primitive amplification route the primitives to the major projection axis (X, Y, or Z) to maximize the projected surface area, and pixel shaders write directly to the 3D texture UAV using atomic operations to accumulate color, normal, and opacity values.

3. Toroidal Addressing for Dynamic Camera Movement

Re-voxelizing the entire world every frame is computationally expensive. As the camera translates through the world, DirectX compute shaders update the clipmaps using toroidal (wrap-around) addressing. The 3D coordinates wrap mathematically using modulo arithmetic. When the camera shifts, only the newly exposed boundary slices of the clipmap volume need to be cleared and re-voxelized, while existing data remains valid and shifts virtually within memory.

4. Cone Sampling in HLSL

During the final deferred shading or forward-plus pass, High-Level Shading Language (HLSL) shaders cast cones from visible surface positions. The sampling routine checks the cone's current world-space footprint against the resolution of the clipmap levels. The shader queries the appropriate clipmap texture using hardware filtering, blending across clipmap boundaries to eliminate visual popping. This architecture enables dynamic environments to exhibit accurate, soft global illumination and realistic secondary light bounces at interactive frame rates.