Voxel Cone Tracing
Voxelizes the lit scene into a mip-mapped 3D texture and approximates diffuse and glossy indirect light by marching a handful of wide cones through the mip chain, instead of tracing many thin rays.
Also known as VXGI, SVOGI, voxel GI
In the family Light transport & global illumination, voxel-based GI
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { vxgi } from 'three/addons/lighting/vxgi/VXGINode.js' docs WebGPURenderer with WebGPU backend only. |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | Add a VoxelGI node and bake it (VoxelGI.bake()) docs Forward+ and Mobile. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Each frame (or when geometry changes) the scene is voxelized: triangles are rasterized into a 3D grid, usually with conservative rasterization, storing albedo, normal and emissive. A light-injection pass computes direct lighting (with shadow maps) for each occupied voxel, giving outgoing radiance plus an anisotropic opacity per voxel.
The grid is mip-mapped, with an anisotropic variant storing directional values in each of six faces so that averaging does not blur thin walls into translucent fog. At a shading point, a small set of cones (about five to nine) is traced over the hemisphere. A cone steps along its axis; at distance d the radius is d * tan(half-angle), so the sample is taken from the mip level whose voxel size matches the footprint. Radiance is accumulated front-to-back using the sampled opacity, as in volume rendering.
A narrow cone gives specular reflections; a wide cone gives soft occlusion for AO. A few wide cones replace the hundreds of rays of path tracing, trading exactness for stable, noise-free results.
When to choose it
Reach for it when
- need dynamic gi and glossy reflections without ray tracing hardware
- indirect lighting that updates as lights and objects move
- bounce light for fully dynamic scenes on older gpus
- few wide samples instead of many noisy rays
- diffuse and specular indirect from a voxel scene
Choose it for fully dynamic GI and glossy reflections on GPUs without hardware ray tracing, in bounded scenes where a voxel volume around the camera is enough.
Prefer Dynamic Diffuse Global Illumination (DDGI) when you have ray tracing and want a clean grid of probes and fewer leaks. Prefer SDF-Based Software Ray Tracing GI (Lumen-style) for large production scenes with software and hardware ray tracing fallbacks. Prefer Light Propagation Volumes for a cheaper, lower quality approximation. Prefer Lightmap Baking when the scene is static and quality matters more than dynamism.
Field marks
- Light leaking and over-darkening through thin walls because voxels average geometry (partially mitigated by anisotropic voxels)
- Aliasing and temporal flicker when the camera moves and the voxel grid snaps
- Specular reflections are blurry and miss anything outside the voxelized volume
- Voxelization cost and memory (hundreds of MB for large volumes) limit scene size, so clipmaps are needed
Presets
Voxel cone tracing — hierarchical mip-voxel indirect bounce & glossy cone aperture
{
"P_CONE_APERTURE": 0.55,
"P_GI_BOUNCE": 1.3,
"P_VOXEL_RES": 12,
"P_GLOSSINESS": 0.72
}Show GLSL (171 lines)
const float P_CONE_APERTURE = 0.55; // P Cone Aperture [0.15, 1.1, 0.03]
const float P_GI_BOUNCE = 1.3; // P Indirect GI [0.0, 2.5, 0.05]
const float P_VOXEL_RES = 12.0; // P Voxel Grid [6.0, 24.0, 1.0]
const float P_GLOSSINESS = 0.72; // P Glossy Spec [0.0, 1.4, 0.04]
float sdBox(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
// Analytical scene SDF (Cornell room + glossy sphere + matte monolith)
vec2 mapScene(vec3 p) {
vec2 res = vec2(1.0 + p.y, 1.0); // floor
float ceilD = 1.0 - p.y; if (ceilD < res.x) res = vec2(ceilD, 1.0);
float backD = 1.4 + p.z; if (backD < res.x) res = vec2(backD, 1.0);
float leftD = 1.4 + p.x; if (leftD < res.x) res = vec2(leftD, 2.0); // orange-red emitter wall
float rightD = 1.4 - p.x; if (rightD < res.x) res = vec2(rightD, 3.0); // cobalt-cyan wall
float dBox = sdBox(p - vec3(-0.48, -0.45, -0.45), vec3(0.35, 0.55, 0.35));
if (dBox < res.x) res = vec2(dBox, 4.0);
vec3 sPos = vec3(0.45, -0.52 + 0.12 * sin(iTime * 0.9), -0.15);
float dSph = length(p - sPos) - 0.38;
if (dSph < res.x) res = vec2(dSph, 5.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
));
}
// Sample quantized voxel radiance volume at mip level corresponding to cone diameter
vec4 sampleVoxelMip(vec3 p, float coneDiameter, float voxRes, vec3 emPos) {
float mipScale = max(voxRes / max(1.0, coneDiameter * voxRes * 0.65), 2.0);
vec3 vp = (floor(p * mipScale) + 0.5) / mipScale;
vec2 h = mapScene(vp);
float voxelSize = 1.0 / mipScale;
float occ = smoothstep(voxelSize * 0.85, -voxelSize * 0.25, h.x);
vec3 rad = vec3(0.0);
if (occ > 0.01) {
if (h.y < 1.5) rad = vec3(0.42, 0.43, 0.46);
else if (h.y < 2.5) rad = vec3(1.45, 0.32, 0.14);
else if (h.y < 3.5) rad = vec3(0.14, 0.68, 1.35);
else rad = vec3(0.72, 0.72, 0.74);
// Modulate voxel radiance by proximity to moving glowing emitter bar
float lDist = length(vp - emPos);
rad *= (0.45 + 1.85 / (0.35 + lDist * lDist));
}
// Glowing emissive voxel strip
float dEm = length(vp - emPos) - 0.24;
float emOcc = smoothstep(voxelSize * 0.9, -voxelSize * 0.2, dEm);
if (emOcc > 0.01) {
rad = mix(rad, vec3(3.2, 2.4, 1.4), emOcc);
occ = max(occ, emOcc);
}
return vec4(rad, occ);
}
// Trace a single VCT cone with front-to-back alpha accumulation: c += (1 - a) * c_i; a += (1 - a) * a_i
vec4 traceCone(vec3 ro, vec3 rd, float aperture, float voxRes, vec3 emPos) {
vec3 accum = vec3(0.0);
float alpha = 0.0;
float t = 0.12;
for (int i = 0; i < 8; i++) {
float diam = max(0.08, 2.0 * t * aperture);
vec4 vox = sampleVoxelMip(ro + rd * t, diam, voxRes, emPos);
float a = clamp(vox.a * 0.72, 0.0, 1.0);
accum += (1.0 - alpha) * vox.rgb * a;
alpha += (1.0 - alpha) * a;
if (alpha > 0.94 || t > 3.2) break;
t += diam * 0.62;
}
return vec4(accum, alpha);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.04, 2.38);
vec3 rd = normalize(vec3(uv, -1.35));
float voxRes = clamp(P_VOXEL_RES, 5.0, 28.0);
float aperture = clamp(P_CONE_APERTURE, 0.12, 1.2);
float giGain = max(P_GI_BOUNCE, 0.0);
float gloss = max(P_GLOSSINESS, 0.0);
vec3 emPos = vec3(0.55 * sin(iTime * 0.65), 0.72, -0.35 + 0.35 * cos(iTime * 0.65));
float t = 0.0;
float matId = 1.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec2 h = mapScene(ro + rd * t);
if (h.x < 0.002) { matId = h.y; hit = true; break; }
t += h.x;
if (t > 9.0) break;
}
vec3 col = vec3(0.02);
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
vec3 alb = vec3(0.76, 0.76, 0.78);
if (matId > 1.5 && matId < 2.5) alb = vec3(0.88, 0.24, 0.12);
else if (matId > 2.5 && matId < 3.5) alb = vec3(0.14, 0.54, 0.88);
else if (matId > 4.5) alb = vec3(0.90, 0.92, 0.95);
// Subtle voxel lattice visualization etched on room walls
vec3 vg = abs(fract(p * voxRes * 0.5 - 0.5) - 0.5);
float grid = smoothstep(0.055, 0.01, min(min(vg.x, vg.y), vg.z));
alb *= (1.0 - 0.12 * grid * step(matId, 3.5));
// Direct light from moving orb
vec3 toL = emPos - p;
float lDist = length(toL) + 1e-4;
vec3 lDir = toL / lDist;
float ndl = max(dot(n, lDir), 0.0);
float sh = 1.0;
float ts = 0.05;
for (int s = 0; s < 16; s++) {
float dh = mapScene(p + n * 0.02 + lDir * ts).x;
sh = min(sh, clamp(5.0 * dh / ts, 0.0, 1.0));
ts += max(dh, 0.06);
if (ts > lDist - 0.1) break;
}
vec3 direct = alb * vec3(2.4, 1.95, 1.45) * ndl * sh / (0.45 + lDist * lDist);
// Diffuse VCT: 5 wide hemisphere cones (1 normal + 4 tilted)
vec3 tanV = normalize(abs(n.y) < 0.9 ? cross(n, vec3(0.0, 1.0, 0.0)) : cross(n, vec3(1.0, 0.0, 0.0)));
vec3 bitV = cross(n, tanV);
vec4 c0 = traceCone(p + n * 0.06, n, aperture, voxRes, emPos);
vec4 c1 = traceCone(p + n * 0.06, normalize(n * 0.65 + tanV * 0.76), aperture, voxRes, emPos);
vec4 c2 = traceCone(p + n * 0.06, normalize(n * 0.65 - tanV * 0.76), aperture, voxRes, emPos);
vec4 c3 = traceCone(p + n * 0.06, normalize(n * 0.65 + bitV * 0.76), aperture, voxRes, emPos);
vec4 c4 = traceCone(p + n * 0.06, normalize(n * 0.65 - bitV * 0.76), aperture, voxRes, emPos);
vec3 diffGI = (c0.rgb * 0.28 + (c1.rgb + c2.rgb + c3.rgb + c4.rgb) * 0.18) * giGain;
float voxAO = 1.0 - 0.55 * (c0.a * 0.28 + (c1.a + c2.a + c3.a + c4.a) * 0.18);
// Glossy specular VCT cone along reflection vector (tighter aperture on sphere & floor)
vec3 rDir = reflect(rd, n);
float specAp = (matId > 4.5) ? max(0.09, aperture * 0.25) : max(0.22, aperture * 0.5);
vec4 cSpec = traceCone(p + n * 0.06, rDir, specAp, voxRes, emPos);
float fres = 0.06 + 0.94 * pow(1.0 - max(dot(n, -rd), 0.0), 5.0);
float specAmt = (matId > 4.5) ? (0.45 + 0.55 * fres) : (0.18 * fres);
col = direct + alb * (diffGI + vec3(0.04, 0.045, 0.055) * voxAO) + cSpec.rgb * specAmt * gloss;
}
// Visible glowing light orb in scene
vec3 toEm = emPos - ro;
float proj = dot(toEm, rd);
if (proj > 0.0 && (!hit || proj < t)) {
float dPerp = length(toEm - rd * proj);
col += vec3(3.2, 2.3, 1.2) * exp(-dPerp * 14.0);
col += vec3(4.0, 3.6, 2.8) * smoothstep(0.11, 0.05, dPerp);
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| voxel-cone-tracing-live | Tesla T4 1920x1080 | 119× baseline (extreme) · 3.92 ms / 4.03 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| voxel-cone-tracing-live | NVIDIA L4 1920x1080 | 103× baseline (extreme) · 1.63 ms / 1.69 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| voxel-cone-tracing-live | NVIDIA A100-SXM4-40GB 1920x1080 | 69.2× baseline (extreme) · 1.99 ms / 2.00 ms · 2.0× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Reflective Shadow Maps, Light Propagation Volumes, Instant Radiosity (Virtual Point Lights), Toksvig normal-map filtering, Lightcuts; cited by Neural Radiance Caching.
Crosses
- Generated levels with free voxel GI: Tile-based generated levels get dynamic global illumination with no voxelisation pass: the solver's voxel grid is the cone-tracing volume. Each tile type carries pre-voxelised directional opacity, so thin walls stop leaking light.
- Screen-Space Global Illumination: Screen-space gathers fill in the contact-scale detail that voxel resolution misses.
Sources
- primaryCyril Crassin, Fabrice Neyret, Miguel Sainz, Simon Green, Elmar Eisemann (2011). Interactive Indirect Illumination Using Voxel Cone Tracing. Computer Graphics Forum.Verified via crossref · 2026-11-30doi:10.1111/j.1467-8659.2011.02063.x