Froxel Volumetric Fog
Scatter light into a low-resolution 3D grid that follows the camera frustum, then integrate front to back to get in-scattering and transmittance for each pixel from a single texture fetch.
Also known as frustum-aligned voxel fog, volumetric fog
In the family Atmosphere, water & volumes, fog
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | Environment.volumetric_fog_enabled = true (plus FogVolume nodes) docs Forward+ only. |
| Unity | Built in | Volume > Add Override > Fog > Enable Volumetric Fog; Local Volumetric Fog docs HDRP only (froxel-based). URP volumetric fog is not in Unity 6.3. |
| Unreal 5.7 | Built in | Exponential Height Fog actor > Volumetric Fog checkbox docs |
| Blender 5.2 | Built in | EEVEE Volumetrics evaluates participating media on a frustum-aligned 3D froxel grid in eevee_volume.cc docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The view frustum is cut into a 3D texture (typically 160x90x64 or similar) with exponentially spaced depth slices, so each cell is a froxel. A compute pass writes extinction and albedo per froxel from fog volumes, height falloff and particle density. A second pass loops over lights, evaluating each light's contribution at the froxel centre with its shadow map or cascades and a phase function, and temporally jitters the sample position and blends with the previous frame to hide the low resolution. A final pass integrates along depth, storing accumulated scattered light and transmittance per slice. Opaque and transparent surfaces then fetch the volume at their view depth and apply scattered plus transmittance times surface colour. Because lighting is separated from integration, many lights and shadows are cheap.
When to choose it
Reach for it when
- need light shafts and fog that react to lights
- real-time volumetric fog in a game
- fog should be lit by many lights and shadowed
- cheap participating media with temporal accumulation
Choose it for dense, local, light-reactive fog and god-ray effects in a deferred or forward+ engine where you need shadowed light shafts from many lights, particles contributing density, and consistent fog on transparents.
Prefer Exponential Height Fog when only an analytic haze is needed. Prefer Screen-space Volumetric Light Scattering (God Rays) for a single sun with a screen-space trick. Prefer Ray-marched Participating Media per pixel for a few hero volumes where froxel resolution is insufficient.
Field marks
- Temporal ghosting trailing behind moving lights and density
- Blocky or flickering light shafts when the froxel resolution is too low for thin shadow casters
- Depth-slice banding near the camera with linear slices, or loss of detail far away with exponential slices
- Fog leaks across thin geometry because the froxel integrates across the full cell
- Edge halos on foreground objects when applied at low resolution without depth-aware upsampling
Presets
Froxel volumetric fog — exponential depth-slice in-scattering with Henyey-Greenstein shafts
{
"DENSITY": 0.18,
"ANISOTROPY": 0.72,
"FROXEL_SLICES": 36,
"SCATTER_GAIN": 3.2
}Show GLSL (129 lines)
const float DENSITY = 0.18; // P
const float ANISOTROPY = 0.72; // P
const int FROXEL_SLICES = 36; // P
const float SCATTER_GAIN = 3.2; // P
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);
}
// Dark vaulted hall with tall right-side colonnade windows letting diagonal sunbeams enter
float mapScene(vec3 p) {
float floorD = p.y + 1.3;
float leftWall = p.x + 2.4;
float backWall = p.z + 11.5;
vec3 q = p;
q.z = mod(q.z + 1.5, 3.0) - 1.5;
// Right colonnade wall with tall vertical window slits
float colWall = sdBox(vec3(p.x - 1.55, p.y - 0.35, q.z), vec3(0.28, 2.0, 0.58));
float lintel = sdBox(vec3(p.x - 1.55, p.y - 2.15, p.z + 5.0), vec3(0.32, 0.45, 9.0));
float roof = sdBox(vec3(p.x + 0.5, p.y - 2.35, p.z + 5.0), vec3(2.2, 0.25, 9.0));
float plinth = sdBox(p - vec3(-0.35, -0.82, -3.8), vec3(0.45, 0.48, 0.45));
float d = min(floorD, min(leftWall, backWall));
d = min(d, min(colWall, min(lintel, min(roof, plinth))));
return d;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.004, 0.0);
return normalize(vec3(
mapScene(p + e.xyy) - mapScene(p - e.xyy),
mapScene(p + e.yxy) - mapScene(p - e.yxy),
mapScene(p + e.yyx) - mapScene(p - e.yyx)
));
}
float shadowVisibility(vec3 ro, vec3 rd) {
float t = 0.06;
for (int i = 0; i < 22; i++) {
vec3 pos = ro + rd * t;
if (pos.x > 2.05) return 1.0;
float d = mapScene(pos);
if (d < 0.012) return 0.0;
t += max(d, 0.07);
if (t > 6.5) break;
}
return 1.0;
}
float hgPhase(float cosT, float g) {
float g2 = g * g;
return (1.0 - g2) / (12.56637 * pow(max(1.0 + g2 - 2.0 * g * cosT, 0.001), 1.5));
}
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.65, -0.1, 1.5);
vec3 rd = normalize(vec3(uv.x + 0.16, uv.y + 0.04, -1.18));
float sunSweep = 0.25 * sin(iTime * 0.45);
if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {
vec2 m = iMouse.xy / iResolution.xy * 2.0 - 1.0;
sunSweep = m.x * 0.85;
}
vec3 sunDir = normalize(vec3(0.84, 0.46, -0.45 + sunSweep));
vec3 sunCol = vec3(1.0, 0.78, 0.42);
float tHit = 0.1;
bool hit = false;
for (int i = 0; i < 64; i++) {
float d = mapScene(ro + rd * tHit);
if (d < 0.004) { hit = true; break; }
tHit += d;
if (tHit > 15.0) break;
}
vec3 surf = vec3(1.8, 1.45, 0.95) * (0.4 + 0.8 * pow(max(dot(rd, sunDir), 0.0), 3.0));
if (hit) {
vec3 p = ro + rd * tHit;
vec3 n = calcNormal(p);
float vis = shadowVisibility(p + n * 0.03, sunDir);
float nl = max(dot(n, sunDir), 0.0);
vec2 tile = floor(p.xz * 1.3);
float chk = mod(tile.x + tile.y, 2.0);
vec3 albedo = mix(vec3(0.11, 0.13, 0.17), vec3(0.24, 0.23, 0.22), 0.5 + 0.5 * chk);
surf = albedo * (vec3(0.03, 0.05, 0.09) + sunCol * nl * vis * 5.5);
}
// Frustum-aligned exponential depth-slice froxel integration
int slices = clamp(FROXEL_SLICES, 8, 64);
float zNear = 0.35, zFar = min(tHit, 13.5);
float ratio = max(zFar / zNear, 1.01);
float jitter = fract(sin(dot(fragCoord, vec2(12.9898, 78.233))) * 43758.5453);
float cosT = dot(rd, sunDir);
float phase = hgPhase(cosT, clamp(ANISOTROPY, -0.85, 0.90));
float densBase = max(DENSITY, 0.0);
float gain = max(SCATTER_GAIN, 0.0);
vec3 inScatter = vec3(0.0);
float transmittance = 1.0;
float prevZ = zNear;
for (int i = 0; i < 64; i++) {
if (i >= slices) break;
float f = (float(i) + 1.0) / float(slices);
float currZ = zNear * pow(ratio, f);
float dt = currZ - prevZ;
float zMid = mix(prevZ, currZ, jitter);
vec3 wp = ro + rd * zMid;
float hFog = exp(-max(wp.y + 1.2, 0.0) * 0.32);
float sigma = densBase * (0.35 + 0.9 * hFog);
float lit = shadowVisibility(wp, sunDir);
vec3 scatter = (sunCol * lit * (0.35 + phase * 18.0) + vec3(0.008, 0.016, 0.035)) * gain * sigma;
float stepTrans = exp(-sigma * dt * 0.45);
inScatter += transmittance * scatter * (1.0 - stepTrans) / max(sigma, 1e-4);
transmittance *= stepTrans;
prevZ = currZ;
if (transmittance < 0.02) break;
}
vec3 col = surf * transmittance + inScatter;
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| froxel-volumetric-fog-live | Tesla T4 1920x1080 | 336× baseline (extreme) · 11.0 ms / 11.2 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| froxel-volumetric-fog-live | NVIDIA L4 1920x1080 | 349× baseline (extreme) · 5.55 ms / 5.61 ms · 2.0× faster on L4 | opengl-timer-query · Cross-architecture validation |
| froxel-volumetric-fog-live | NVIDIA A100-SXM4-40GB 1920x1080 | 201× baseline (extreme) · 5.79 ms / 5.80 ms · 1.9× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Fog that flows through generated caves: Procedural caves and dungeons whose fog actually moves through them: drafts along corridors, eddies behind pillars. The generator's voxel grid is used directly as the fluid solver's solid boundary, so no remeshing sits between level and air.
- Scale-consistent volumetric fog shafts through Mip-Splatting scenes: Alias-free Mip-Splatting captures gain crisp, depth-aware volumetric fog and sunbeams by injecting band-limited 3D splat opacity directly into a camera-aligned froxel volume instead of faking depth fog in post.
- Fog shafts that do not flicker: Volumetric fog whose light shafts stay soft and stable behind foliage and fences. Prefiltered moment shadow maps let each froxel fetch the average visibility over its footprint in one lookup instead of point-sampling a hard shadow map.
- Scalable Production Sky and Atmosphere (Hillaire): Aerial perspective volume and fog froxels can share one front-to-back integration.
- Henyey-Greenstein Phase Function: Phase function applied when each light is scattered into a froxel.
Sources
- primaryBartlomiej Wronski. Volumetric Fog: Unified compute shader based solution to atmospheric scattering. SIGGRAPH 2014.Verified via live page · 2026-11-29