---
id: "froxel-volumetric-fog"
title: "Froxel Volumetric Fog"
aliases: [frustum-aligned voxel fog, volumetric fog]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [desktop-gpu, webgpu, unreal, unity]
year_introduced: 2014
inputs: [depth, volume-density, visibility-mask]
outputs: [radiance, volume-density]
style: "photoreal"
dynamic: "dynamic"
cost: "medium"
authority: "Wronski"
url: "https://texelatlas.vercel.app/t/froxel-volumetric-fog/"
sources_verified_at: "2026-11-29"
---
# Froxel Volumetric Fog (Wronski)

> 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.

## 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

## 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 use it

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](https://texelatlas.vercel.app/t/exponential-height-fog.md) when only an analytic haze is needed. Prefer [Screen-space Volumetric Light Scattering (God Rays)](https://texelatlas.vercel.app/t/volumetric-light-scattering-god-rays.md) for a single sun with a screen-space trick. Prefer [Ray-marched Participating Media](https://texelatlas.vercel.app/t/volume-ray-marching.md) per pixel for a few hero volumes where froxel resolution is insufficient.

## Cost

medium — Cost scales with grid size and number of shadowed lights; the paper's grid is small and tuned for console budgets.
Measured GPU Weight: 335.86× baseline (extreme) — 11.0497 ms median / 11.169 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 349.35× baseline (extreme) — 5.5547 ms median (1.99× faster on L4).
Ampere A100 scaling: 201× baseline (extreme) — 5.7887 ms median (1.91× faster on A100).

## Failure modes

- 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

## Engine support

- blender: builtin — `EEVEE Volumetrics evaluates participating media on a frustum-aligned 3D froxel grid in eevee_volume.cc` (evidence: https://github.com/blender/blender/blob/main/source/blender/draw/engines/eevee/eevee_volume.cc, checked 2026-12-01)
- godot: builtin — `Environment.volumetric_fog_enabled = true (plus FogVolume nodes)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Environment.xml, checked 2026-12-01) — Forward+ only.
- unity: builtin — `Volume > Add Override > Fog > Enable Volumetric Fog; Local Volumetric Fog` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/Volumetric-Lighting.md, checked 2026-12-01) — HDRP only (froxel-based). URP volumetric fog is not in Unity 6.3.
- unreal: builtin — `Exponential Height Fog actor > Volumetric Fog checkbox` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/volumetric-fog-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: depth, volume-density, visibility-mask
- Outputs: radiance, volume-density
- Platforms: desktop-gpu, webgpu, unreal, unity

## Presets

### Froxel volumetric fog — exponential depth-slice in-scattering with Henyey-Greenstein shafts (glsl-fragment; rendered 2026-11-30)

```json
{
  "DENSITY": 0.18,
  "ANISOTROPY": 0.72,
  "FROXEL_SLICES": 36,
  "SCATTER_GAIN": 3.2
}
```

```glsl
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

## Lineage

- extends [Ray-marched Participating Media](https://texelatlas.vercel.app/t/volume-ray-marching.md)

## Combines with

- [Scalable Production Sky and Atmosphere (Hillaire)](https://texelatlas.vercel.app/t/hillaire-sky-atmosphere.md): Aerial perspective volume and fog froxels can share one front-to-back integration.
- [Henyey-Greenstein Phase Function](https://texelatlas.vercel.app/t/henyey-greenstein-phase-function.md): Phase function applied when each light is scattered into a froxel.

## Combination ideas

- [Fog that flows through generated caves](https://texelatlas.vercel.app/ideas/drafts-through-generated-dungeons/)
- [Scale-consistent volumetric fog shafts through Mip-Splatting scenes](https://texelatlas.vercel.app/ideas/mip-splat-froxel-fog-occlusion/)
- [Fog shafts that do not flicker](https://texelatlas.vercel.app/ideas/prefiltered-shadows-in-fog/)

## Sources

1. [primary] Bartlomiej Wronski Volumetric Fog: Unified compute shader based solution to atmospheric scattering. SIGGRAPH 2014. https://advances.realtimerendering.com/s2014/wronski/bwronski_volumetric_fog_siggraph2014.pdf (verified via http on 2026-11-29)

## Cite this entry

Texel. "Froxel Volumetric Fog." https://texelatlas.vercel.app/t/froxel-volumetric-fog/ (accessed 2026-12-01).
