{
 "id": "froxel-volumetric-fog",
 "title": "Froxel Volumetric Fog",
 "aliases": [
  "frustum-aligned voxel fog",
  "volumetric fog"
 ],
 "domain": "volumes",
 "subdomain": "fog",
 "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",
 "summary": "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.",
 "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": "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.\n\nPrefer `exponential-height-fog` when only an analytic haze is needed. Prefer `volumetric-light-scattering-god-rays` for a single sun with a screen-space trick. Prefer `volume-ray-marching` per pixel for a few hero volumes where froxel resolution is insufficient.",
 "cost": {
  "class": "medium",
  "notes": "Cost scales with grid size and number of shadowed lights; the paper's grid is small and tuned for console budgets."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "url:https://advances.realtimerendering.com/s2014/wronski/bwronski_volumetric_fog_siggraph2014.pdf",
   "type": "talk",
   "title": "Volumetric Fog: Unified compute shader based solution to atmospheric scattering",
   "authors": [
    "Bartlomiej Wronski"
   ],
   "year": null,
   "venue": "SIGGRAPH 2014",
   "url": "https://advances.realtimerendering.com/s2014/wronski/bwronski_volumetric_fog_siggraph2014.pdf",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": null,
    "page_title": null,
    "host": "advances.realtimerendering.com",
    "title_confirmed_by_page": false,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://advances.realtimerendering.com/s2014/wronski/bwronski_volumetric_fog_siggraph2014.pdf → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "wronskivolumetric"
  }
 ],
 "presets": [
  {
   "id": "froxel-volumetric-fog-live",
   "title": "Froxel volumetric fog — exponential depth-slice in-scattering with Henyey-Greenstein shafts",
   "runtime": "glsl-fragment",
   "params": {
    "DENSITY": 0.18,
    "ANISOTROPY": 0.72,
    "FROXEL_SLICES": 36,
    "SCATTER_GAIN": 3.2
   },
   "basis": "original",
   "license_note": "MIT — written for this index",
   "code": "const float DENSITY = 0.18; // P\nconst float ANISOTROPY = 0.72; // P\nconst int FROXEL_SLICES = 36; // P\nconst float SCATTER_GAIN = 3.2; // P\n\nfloat sdBox(vec3 p, vec3 b) {\n  vec3 q = abs(p) - b;\n  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);\n}\n\n// Dark vaulted hall with tall right-side colonnade windows letting diagonal sunbeams enter\nfloat mapScene(vec3 p) {\n  float floorD = p.y + 1.3;\n  float leftWall = p.x + 2.4;\n  float backWall = p.z + 11.5;\n  vec3 q = p;\n  q.z = mod(q.z + 1.5, 3.0) - 1.5;\n  // Right colonnade wall with tall vertical window slits\n  float colWall = sdBox(vec3(p.x - 1.55, p.y - 0.35, q.z), vec3(0.28, 2.0, 0.58));\n  float lintel = sdBox(vec3(p.x - 1.55, p.y - 2.15, p.z + 5.0), vec3(0.32, 0.45, 9.0));\n  float roof = sdBox(vec3(p.x + 0.5, p.y - 2.35, p.z + 5.0), vec3(2.2, 0.25, 9.0));\n  float plinth = sdBox(p - vec3(-0.35, -0.82, -3.8), vec3(0.45, 0.48, 0.45));\n  float d = min(floorD, min(leftWall, backWall));\n  d = min(d, min(colWall, min(lintel, min(roof, plinth))));\n  return d;\n}\n\nvec3 calcNormal(vec3 p) {\n  vec2 e = vec2(0.004, 0.0);\n  return normalize(vec3(\n    mapScene(p + e.xyy) - mapScene(p - e.xyy),\n    mapScene(p + e.yxy) - mapScene(p - e.yxy),\n    mapScene(p + e.yyx) - mapScene(p - e.yyx)\n  ));\n}\n\nfloat shadowVisibility(vec3 ro, vec3 rd) {\n  float t = 0.06;\n  for (int i = 0; i < 22; i++) {\n    vec3 pos = ro + rd * t;\n    if (pos.x > 2.05) return 1.0;\n    float d = mapScene(pos);\n    if (d < 0.012) return 0.0;\n    t += max(d, 0.07);\n    if (t > 6.5) break;\n  }\n  return 1.0;\n}\n\nfloat hgPhase(float cosT, float g) {\n  float g2 = g * g;\n  return (1.0 - g2) / (12.56637 * pow(max(1.0 + g2 - 2.0 * g * cosT, 0.001), 1.5));\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  vec3 ro = vec3(-0.65, -0.1, 1.5);\n  vec3 rd = normalize(vec3(uv.x + 0.16, uv.y + 0.04, -1.18));\n\n  float sunSweep = 0.25 * sin(iTime * 0.45);\n  if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {\n    vec2 m = iMouse.xy / iResolution.xy * 2.0 - 1.0;\n    sunSweep = m.x * 0.85;\n  }\n  vec3 sunDir = normalize(vec3(0.84, 0.46, -0.45 + sunSweep));\n  vec3 sunCol = vec3(1.0, 0.78, 0.42);\n\n  float tHit = 0.1;\n  bool hit = false;\n  for (int i = 0; i < 64; i++) {\n    float d = mapScene(ro + rd * tHit);\n    if (d < 0.004) { hit = true; break; }\n    tHit += d;\n    if (tHit > 15.0) break;\n  }\n\n  vec3 surf = vec3(1.8, 1.45, 0.95) * (0.4 + 0.8 * pow(max(dot(rd, sunDir), 0.0), 3.0));\n  if (hit) {\n    vec3 p = ro + rd * tHit;\n    vec3 n = calcNormal(p);\n    float vis = shadowVisibility(p + n * 0.03, sunDir);\n    float nl = max(dot(n, sunDir), 0.0);\n    vec2 tile = floor(p.xz * 1.3);\n    float chk = mod(tile.x + tile.y, 2.0);\n    vec3 albedo = mix(vec3(0.11, 0.13, 0.17), vec3(0.24, 0.23, 0.22), 0.5 + 0.5 * chk);\n    surf = albedo * (vec3(0.03, 0.05, 0.09) + sunCol * nl * vis * 5.5);\n  }\n\n  // Frustum-aligned exponential depth-slice froxel integration\n  int slices = clamp(FROXEL_SLICES, 8, 64);\n  float zNear = 0.35, zFar = min(tHit, 13.5);\n  float ratio = max(zFar / zNear, 1.01);\n  float jitter = fract(sin(dot(fragCoord, vec2(12.9898, 78.233))) * 43758.5453);\n  float cosT = dot(rd, sunDir);\n  float phase = hgPhase(cosT, clamp(ANISOTROPY, -0.85, 0.90));\n  float densBase = max(DENSITY, 0.0);\n  float gain = max(SCATTER_GAIN, 0.0);\n\n  vec3 inScatter = vec3(0.0);\n  float transmittance = 1.0;\n  float prevZ = zNear;\n  for (int i = 0; i < 64; i++) {\n    if (i >= slices) break;\n    float f = (float(i) + 1.0) / float(slices);\n    float currZ = zNear * pow(ratio, f);\n    float dt = currZ - prevZ;\n    float zMid = mix(prevZ, currZ, jitter);\n    vec3 wp = ro + rd * zMid;\n\n    float hFog = exp(-max(wp.y + 1.2, 0.0) * 0.32);\n    float sigma = densBase * (0.35 + 0.9 * hFog);\n    float lit = shadowVisibility(wp, sunDir);\n    vec3 scatter = (sunCol * lit * (0.35 + phase * 18.0) + vec3(0.008, 0.016, 0.035)) * gain * sigma;\n\n    float stepTrans = exp(-sigma * dt * 0.45);\n    inScatter += transmittance * scatter * (1.0 - stepTrans) / max(sigma, 1e-4);\n    transmittance *= stepTrans;\n    prevZ = currZ;\n    if (transmittance < 0.02) break;\n  }\n\n  vec3 col = surf * transmittance + inScatter;\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "reduced-sandbox",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "froxel-volumetric-fog",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:15:34.232Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.6674,
      "std": 0.2586,
      "unique_colors": 125
     },
     "image": "/specimens/froxel-volumetric-fog-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "exponential-height-fog",
  "volume-ray-marching",
  "volumetric-light-scattering-god-rays",
  "hillaire-sky-atmosphere"
 ],
 "extends": [
  "volume-ray-marching"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "hillaire-sky-atmosphere",
   "why": "Aerial perspective volume and fog froxels can share one front-to-back integration."
  },
  {
   "id": "henyey-greenstein-phase-function",
   "why": "Phase function applied when each light is scattered into a froxel."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/volumes/froxel-volumetric-fog.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Wronski",
 "url": "https://texelatlas.vercel.app/t/froxel-volumetric-fog/",
 "execution_fidelity": "reduced-sandbox",
 "fidelity_label": "Analytic Sandbox",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 335.86,
  "tier": "extreme",
  "p50_ms": 11.0497,
  "p95_ms": 11.169,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "froxel-volumetric-fog-live",
  "execution_fidelity": "reduced-sandbox",
  "fidelity_label": "Analytic Sandbox",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 349.35,
   "tier": "extreme",
   "p50_ms": 5.5547,
   "p95_ms": 5.6069,
   "speedup_x": 1.99,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 201,
   "tier": "extreme",
   "p50_ms": 5.7887,
   "p95_ms": 5.7978,
   "speedup_x": 1.91,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}