---
id: "volume-ray-marching"
title: "Ray-marched Participating Media"
aliases: [volume ray marching, single-scattering volume rendering]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cpu]
year_introduced: 1984
inputs: [volume-density, camera-poses]
outputs: [radiance, ldr-image]
style: "both"
dynamic: "both"
cost: "medium"
authority: "Novák et al., 2018"
url: "https://texelatlas.vercel.app/t/volume-ray-marching/"
sources_verified_at: "2026-11-29"
---
# Ray-marched Participating Media (Novák et al., 2018)

> Step along each view ray through a density field, accumulating emitted and in-scattered light weighted by transmittance; the general-purpose way to draw smoke, fog, clouds and fire.

## Reach for it when

- need to draw smoke, fog or fire from a density field
- want procedural clouds in a shader
- visualise medical or simulation volume data
- light should scatter through participating media

## How it works

At each step of length dt the ray gains radiance equal to the in-scattered light times local density, attenuated by the transmittance accumulated so far; the transmittance then decays by exp(-sigma_t dt). The in-scattered light at a point is the light's radiance reduced by a secondary march toward the light (or a shadow map or cached shadow volume), times a phase function. Choose step size from density and distance, add per-pixel jitter (blue noise) to turn banding into noise, and stop early when transmittance falls under a threshold. For a density that comes from a 3D texture you can skip empty space with a coarse occupancy or min/max grid. Emission is added for fire. Because density is sampled along a ray this is a Riemann-sum solution of the radiative transfer equation and is biased by step size, unlike unbiased delta tracking.

## When to use it

Choose it for any dynamic volume you can sample cheaply: procedural clouds, smoke from a fluid sim, shadertoy-style fog, or volumetric medical data.

Prefer [Froxel Volumetric Fog](https://texelatlas.vercel.app/t/froxel-volumetric-fog.md) when the volume is a global fog with many lights. Prefer [Delta (Woodcock) Tracking](https://texelatlas.vercel.app/t/delta-tracking.md) when you need unbiased results and heterogeneous media offline. Prefer [Nubis-style Ray-marched Volumetric Clouds](https://texelatlas.vercel.app/t/nubis-volumetric-clouds.md) for sky-scale clouds with an authored pipeline. Prefer [OpenVDB](https://texelatlas.vercel.app/t/openvdb.md) or [NanoVDB](https://texelatlas.vercel.app/t/nanovdb.md) for sparse simulation data.

## Cost

medium — Scales with steps per pixel times light samples; empty-space skipping and early termination are the key savers.
Measured GPU Weight: 390.5× baseline (extreme) — 12.8474 ms median / 13.0307 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 328.42× baseline (extreme) — 5.2219 ms median (2.46× faster on L4).
Ampere A100 scaling: 273.19× baseline (extreme) — 7.8679 ms median (1.63× faster on A100).

## Failure modes

- Banding stripes from regular step spacing when jitter is missing
- Missed thin features when step size exceeds the feature width
- Lighting that is only single-scatter, so thick media look too dark
- Cost explosion in dense media because secondary light marches multiply the step count
- Inconsistent results when step size varies with distance and density is not integrated analytically per step

## Engine support

- blender: builtin — `Properties > Render > Volumes > Biased (enable), then Step Rate / Max Steps (Cycles)` (evidence: https://docs.blender.org/manual/en/5.2/render/cycles/render_settings/volumes.html, checked 2026-12-01)
- godot: builtin — `Environment.volumetric_fog_enabled = true with FogVolume and FogMaterial (density, density_texture, albedo)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/FogVolume.xml, checked 2026-12-01)
- threejs: official — `import { VolumeShader } from 'three/addons/shaders/VolumeShader.js'; TSL: RaymarchingBox from tsl/utils/Raymarching.js` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/shaders/VolumeShader.js, checked 2026-12-01)
- unity: builtin — `HDRP Volume > Add Override > Fog > Volumetric Fog (VolumetricLighting.compute integrates density and scattering along jittered view rays)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute, checked 2026-12-01) — HDRP only.
- unreal: builtin — `Heterogeneous Volume component (volumetric material ray marched); also Volumetric Cloud` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/heterogeneous-volumes-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: volume-density, camera-poses
- Outputs: radiance, ldr-image
- Platforms: webgl2, webgpu, desktop-gpu, cpu

## Presets

### Emission-absorption volume ray marching of a noisy fireball (glsl-fragment; rendered 2026-11-29)

```json
{
  "STEPS": 64,
  "SIGMA_T": 5
}
```

```glsl
// Emission-absorption volume ray marching: front-to-back accumulation with Beer-Lambert transmittance,
// 64 fixed steps through a noise-modulated density ball with a hot emissive core.
const int STEPS = 64;
const float SIGMA_T = 5.0;

float h31(vec3 p) { p = fract(p * 0.1031); p += dot(p, p.zyx + 31.32); return fract((p.x + p.y) * p.z); }
float vn(vec3 x) {
  vec3 i = floor(x), f = fract(x); f = f * f * (3.0 - 2.0 * f);
  return mix(mix(mix(h31(i), h31(i + vec3(1, 0, 0)), f.x), mix(h31(i + vec3(0, 1, 0)), h31(i + vec3(1, 1, 0)), f.x), f.y),
             mix(mix(h31(i + vec3(0, 0, 1)), h31(i + vec3(1, 0, 1)), f.x), mix(h31(i + vec3(0, 1, 1)), h31(i + vec3(1, 1, 1)), f.x), f.y), f.z);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  vec3 ro = vec3(0.0, 0.0, 3.5), rd = normalize(vec3(uv, -1.8));
  vec3 bg = mix(vec3(0.02, 0.02, 0.04), vec3(0.08, 0.1, 0.16), uv.y + 0.5);
  float b = dot(ro, rd); float hh = b * b - dot(ro, ro) + 1.44;
  vec3 col = bg;
  if (hh > 0.0) {
    float t0 = -b - sqrt(hh), t1 = -b + sqrt(hh); float ds = (t1 - t0) / float(STEPS);
    float T = 1.0; vec3 L = vec3(0.0);
    for (int i = 0; i < STEPS; i++) {
      vec3 p = ro + rd * (t0 + (float(i) + 0.5) * ds);
      float r = length(p);
      vec3 q = p * 2.2 + vec3(0.0, -iTime * 0.6, 0.0);
      float n = 0.55 * vn(q) + 0.3 * vn(q * 2.1) + 0.15 * vn(q * 4.3);
      float d = clamp((1.0 - r / 1.2) * 1.6 + (n - 0.5) * 1.2, 0.0, 1.0) * SIGMA_T;
      float heat = clamp(1.0 - r / 0.8, 0.0, 1.0) * n * 2.0;
      vec3 em = mix(vec3(0.15, 0.1, 0.09), vec3(2.2, 0.9, 0.25), heat) * d;
      L += T * em * ds;
      T *= exp(-d * ds);
    }
    col = bg * T + L;
  }
  col = 1.0 - exp(-col * 1.6);
  fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}

```

Attribution: written for this index

## Lineage

- extended by [Froxel Volumetric Fog](https://texelatlas.vercel.app/t/froxel-volumetric-fog.md)
- extended by [Nubis-style Ray-marched Volumetric Clouds](https://texelatlas.vercel.app/t/nubis-volumetric-clouds.md)
- extended by [Ray-marched Rayleigh/Mie Single Scattering](https://texelatlas.vercel.app/t/rayleigh-mie-single-scattering.md)
- extended by [Schwarzschild Null-Geodesic Gravitational Lensing and Relativistic Accretion Disk](https://texelatlas.vercel.app/t/schwarzschild-null-geodesic-lensing.md)

## Combines with

- [OpenVDB](https://texelatlas.vercel.app/t/openvdb.md): Reads density from sparse grids with ray-grid traversal that skips inactive space.
- [Henyey-Greenstein Phase Function](https://texelatlas.vercel.app/t/henyey-greenstein-phase-function.md): Weights the in-scattered light at each step.

## Sources

1. [primary] Jan Novák, Iliyan Georgiev, Johannes Hanika, Wojciech Jarosz (2018) Monte Carlo Methods for Volumetric Light Transport Simulation. Computer Graphics Forum. https://doi.org/10.1111/cgf.13383 (verified via crossref on 2026-11-29)
2. [tutorial] Matt Pharr, Wenzel Jakob, Greg Humphreys Media (Physically Based Rendering, 4th ed.). pbr-book.org. https://www.pbr-book.org/4ed/Volume_Scattering/Media (verified via http on 2026-11-29)
3. [implementation] Gökay Aydoğan (2026) gokayfem/glsl-studies. https://github.com/gokayfem/glsl-studies License: MIT. (verified via github on 2026-11-30)

## Cite this entry

Texel. "Ray-marched Participating Media." https://texelatlas.vercel.app/t/volume-ray-marching/ (accessed 2026-12-01).
