---
id: "precomputed-atmospheric-scattering"
title: "Precomputed Atmospheric Scattering"
aliases: [Bruneton sky]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu]
year_introduced: 2008
inputs: [material-params]
outputs: [radiance, hdr-image]
style: "photoreal"
dynamic: "dynamic"
cost: "cheap"
authority: "Bruneton & Neyret, 2008"
url: "https://texelatlas.vercel.app/t/precomputed-atmospheric-scattering/"
sources_verified_at: "2026-11-29"
---
# Precomputed Atmospheric Scattering (Bruneton & Neyret, 2008)

> Tabulates single and multiple Rayleigh/Mie scattering of a planetary atmosphere into 3D textures, so sky color and aerial perspective cost a few texture fetches per pixel from any altitude.

## Reach for it when

- realistic sky and distant haze from space to ground
- multiple scattering makes the sunset look right
- atmosphere ray marching per pixel is too slow
- need accurate planet atmosphere rendering via lookup

## How it works

The atmosphere is a spherically symmetric medium with density profiles for air molecules, aerosols and ozone. Because the geometry is symmetric, in-scattered light depends only on four things: altitude, view zenith angle, sun zenith angle and the view-sun azimuth. A precompute pass fills transmittance (2D), single-scattering (a 4D function packed into a 3D texture) and then iterates over scattering orders, feeding each order's result into the next as a source term. A separate irradiance table gives ground ambient light. At run time the sky is one 4D lookup with manual interpolation across the packed axes, and aerial perspective is the difference of two lookups at the camera and at the surface point. Mie scattering is stored separately and recombined with its phase function to save memory.

## When to use it

Choose it when you need a physically plausible planet-scale atmosphere with real multiple scattering, a sun that can sit anywhere from noon to below the horizon, and a camera that can fly from the ground to orbit, and you can afford a precompute step on parameter changes.

Prefer [Scalable Production Sky and Atmosphere (Hillaire)](https://texelatlas.vercel.app/t/hillaire-sky-atmosphere.md) when parameters (density, albedo, sun) must change every frame without a recompute, or when you want one unified path with volumetric fog. Prefer [Preetham Analytic Daylight Model](https://texelatlas.vercel.app/t/preetham-sky.md) or [Hosek-Wilkie Sky Model](https://texelatlas.vercel.app/t/hosek-wilkie-sky.md) for a ground-only sky with a handful of turbidity sliders and no precompute. Prefer [Ray-marched Rayleigh/Mie Single Scattering](https://texelatlas.vercel.app/t/rayleigh-mie-single-scattering.md) for a cheap ray-marched gradient.

## Cost

cheap — Per-pixel cost is a handful of 3D texture fetches; the precompute is a one-off cost that is noticeable (tens to hundreds of ms on a desktop GPU) if parameters change.
Measured GPU Weight: 19.08× baseline (moderate) — 0.6278 ms median / 0.65 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 18.56× baseline (moderate) — 0.2951 ms median (2.13× faster on L4).
Ampere A100 scaling: 13.55× baseline (moderate) — 0.3901 ms median (1.61× faster on A100).

## Failure modes

- Seams or banding in the sky near the horizon where the packed 4D table is interpolated across slice boundaries
- Visible discontinuity at the terminator or when the sun is slightly below the horizon if the table parametrization is too coarse
- Changing atmosphere parameters at run time forces a full table rebuild, causing hitches
- Planet shadow on aerial perspective and clouds is not captured unless added separately
- Assumes a smooth sphere, so terrain shadows (crepuscular rays through mountains) are missing

## Engine support

- babylonjs: official — `@babylonjs/addons Atmosphere (LUT-based physically based atmospheric scattering)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/addons/src/atmosphere/atmosphere.ts, checked 2026-12-01)
- threejs: plugin — `npm i @takram/three-atmosphere` (evidence: https://github.com/takram-design-engineering/three-geospatial, checked 2026-12-01)
- unity: builtin — `Volume > Add Override > Sky > Visual Environment > Sky Type = Physically Based Sky` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.high-definition/Documentation~/physically-based-sky-volume-override-reference.md, checked 2026-12-01) — HDRP only.
- unreal: builtin — `Place Actors > Visual Effects > Sky Atmosphere (SkyAtmosphereComponent precomputed Rayleigh/Mie transmittance and multi-scattering LUTs)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/sky-atmosphere-component-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: material-params
- Outputs: radiance, hdr-image
- Platforms: webgl2, webgpu, desktop-gpu

## Presets

### Precomputed Atmospheric Scattering — single-scatter limb (left) vs multi-scatter Rayleigh/Mie orbital twilight (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_SUN_ELEV": 0.1,
  "P_ALTITUDE": 0.42,
  "P_MIE_HAZE": 0.85,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_SUN_ELEV = 0.10; // P Sun Limb Angle [-0.15, 0.45, 0.02]
const float P_ALTITUDE = 0.42; // P Orbital Altitude [0.15, 0.95, 0.05]
const float P_MIE_HAZE = 0.85; // P Mie Aerosol [0.2, 2.0, 0.05]
const float P_SPLIT = 0.48; // P Single / Multi Split [0.0, 1.0, 0.02]

vec2 raySphere(vec3 ro, vec3 rd, float R) {
  float b = dot(ro, rd);
  float c = dot(ro, ro) - R * R;
  float h = b * b - c;
  if (h < 0.0) return vec2(-1.0);
  h = sqrt(h);
  return vec2(-b - h, -b + h);
}

// Physical Rayleigh + Mie atmospheric optical depth integration (Bruneton 2008 planetary geometry)
vec3 integrateAtmosphere(vec3 ro, vec3 rd, vec3 sunDir, float mieScale, bool includeMulti) {
  float Rg = 6.36;
  float Rt = 6.48;
  float HR = 0.018;
  float HM = 0.0045;
  vec3 betaR = vec3(5.8, 13.5, 33.1) * 0.92;
  vec3 betaM = vec3(21.0) * 0.42 * mieScale;

  vec2 hitAtm = raySphere(ro, rd, Rt);
  if (hitAtm.y < 0.0) return vec3(0.0);
  vec2 hitGnd = raySphere(ro, rd, Rg);
  bool hitsPlanet = (hitGnd.x > 0.0);

  float t0 = max(hitAtm.x, 0.0);
  float t1 = hitsPlanet ? hitGnd.x : hitAtm.y;

  const int STEPS = 18;
  float dt = (t1 - t0) / float(STEPS);
  float optR = 0.0;
  float optM = 0.0;
  vec3 sumR = vec3(0.0);
  vec3 sumM = vec3(0.0);
  vec3 sumMulti = vec3(0.0);

  float mu = dot(rd, sunDir);
  float phaseR = 0.059683 * (1.0 + mu * mu);
  float g = 0.78;
  float phaseM = 0.079577 * ((1.0 - g * g) / pow(max(1.0 + g * g - 2.0 * g * mu, 0.02), 1.5));

  for (int i = 0; i < STEPS; i++) {
    vec3 p = ro + rd * (t0 + (float(i) + 0.5) * dt);
    float h = max(length(p) - Rg, 0.0);
    float dR = exp(-h / HR) * dt;
    float dM = exp(-h / HM) * dt;
    optR += dR;
    optM += dM;

    // Light transmittance from sample point p to space along sunDir (4-step Chapman/optical depth)
    vec2 sunAtm = raySphere(p, sunDir, Rt);
    vec2 sunGnd = raySphere(p, sunDir, Rg);
    float sunVis = (sunGnd.x > 0.0 && sunGnd.x < sunAtm.y) ? 0.0 : 1.0;

    float sOptR = 0.0;
    float sOptM = 0.0;
    if (sunVis > 0.5) {
      float sDt = sunAtm.y * 0.25;
      for (int j = 0; j < 4; j++) {
        vec3 sp = p + sunDir * ((float(j) + 0.5) * sDt);
        float sh = max(length(sp) - Rg, 0.0);
        sOptR += exp(-sh / HR) * sDt;
        sOptM += exp(-sh / HM) * sDt;
      }
      vec3 tau = betaR * (optR + sOptR) + betaM * 1.15 * (optM + sOptM);
      vec3 atten = exp(-tau);
      sumR += atten * dR;
      sumM += atten * dM;
    }

    if (includeMulti) {
      // Precomputed multi-scattering isotropic approximation (2nd+ orders fill deep twilight & luminous horizon limb!)
      vec3 up = normalize(p);
      float sunCosZ = dot(up, sunDir);
      float twilight = smoothstep(-0.34, 0.35, sunCosZ);
      vec3 viewAtten = exp(-(betaR * optR + betaM * optM) * 0.62);
      vec3 warmMulti = mix(vec3(0.45, 0.16, 0.38), vec3(0.98, 0.52, 0.24), smoothstep(-0.22, 0.12, sunCosZ));
      vec3 dayMulti = vec3(0.32, 0.56, 0.96);
      vec3 msCol = mix(warmMulti, dayMulti, smoothstep(0.05, 0.42, sunCosZ));
      sumMulti += viewAtten * msCol * (dR * 12.0 + dM * 4.0) * twilight * 0.42;
    }
  }

  vec3 sky = (sumR * betaR * phaseR + sumM * betaM * phaseM) * 18.0 + sumMulti;

  // Planet surface & ocean specular + aerial perspective transmittance
  if (hitsPlanet) {
    vec3 gp = ro + rd * hitGnd.x;
    vec3 gn = normalize(gp);
    vec3 viewTrans = exp(-(betaR * optR + betaM * optM));
    float ndl = max(dot(gn, sunDir), 0.0);
    // Subtle continental silhouettes & clouds on planetary limb
    float landMask = smoothstep(0.05, 0.32, sin(gn.x * 14.0 + gn.z * 9.0) * cos(gn.y * 12.0 - gn.x * 6.0));
    vec3 surfAlb = mix(vec3(0.04, 0.11, 0.24), vec3(0.18, 0.24, 0.14), landMask);
    float oceanSpec = (1.0 - landMask) * pow(max(dot(reflect(-sunDir, gn), -rd), 0.0), 42.0) * 1.4;
    vec3 surfLit = (surfAlb * (ndl * 1.2 + (includeMulti ? 0.06 : 0.0)) + vec3(1.0, 0.84, 0.62) * oceanSpec * ndl);
    sky += surfLit * viewTrans;
  } else {
    // Crisp solar disc + subtle starfield in deep space
    float sunDisc = smoothstep(0.9985, 0.9996, mu);
    vec3 viewTrans = exp(-(betaR * optR + betaM * optM));
    sky += vec3(12.0, 10.5, 8.2) * sunDisc * viewTrans;
  }

  return sky;
}

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;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool useMulti = sx >= split;

  float sunElev = clamp(P_SUN_ELEV, -0.22, 0.55) + 0.05 * sin(iTime * 0.4);
  float alt = clamp(P_ALTITUDE, 0.1, 1.0);
  float mie = clamp(P_MIE_HAZE, 0.1, 2.5);

  // Orbital view skimming the curved planetary horizon
  float camR = 6.36 + mix(0.14, 0.72, alt);
  vec3 ro = vec3(0.0, camR, 0.0);
  vec3 ta = vec3(0.0, 6.26, -2.25);
  vec3 fw = normalize(ta - ro);
  vec3 ri = normalize(cross(fw, vec3(0.0, 1.0, 0.0)));
  vec3 up = cross(ri, fw);
  vec3 rd = normalize(fw * 1.55 + ri * uv.x + up * uv.y);

  vec3 sunDir = normalize(vec3(0.28 * cos(iTime * 0.25), sunElev, -0.94));
  vec3 col = integrateAtmosphere(ro, rd, sunDir, mie, useMulti);

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  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 Rayleigh/Mie Single Scattering](https://texelatlas.vercel.app/t/rayleigh-mie-single-scattering.md)
- extended by [Scalable Production Sky and Atmosphere (Hillaire)](https://texelatlas.vercel.app/t/hillaire-sky-atmosphere.md)

## Combines with

- [Nubis-style Ray-marched Volumetric Clouds](https://texelatlas.vercel.app/t/nubis-volumetric-clouds.md): Provides sky radiance and sun transmittance that tint and light the cloud layer.
- [Froxel Volumetric Fog](https://texelatlas.vercel.app/t/froxel-volumetric-fog.md): Aerial perspective table supplies the far-field haze that the froxel grid hands over to.

## Sources

1. [primary] Eric Bruneton, Fabrice Neyret (2008) Precomputed Atmospheric Scattering. Computer Graphics Forum. https://doi.org/10.1111/j.1467-8659.2008.01245.x (verified via doi.org on 2026-11-29)
2. [implementation] ebruneton (2017) ebruneton/precomputed_atmospheric_scattering. https://github.com/ebruneton/precomputed_atmospheric_scattering License: BSD-3-Clause. (verified via github on 2026-11-29)
3. [tutorial] Eric Bruneton Precomputed Atmospheric Scattering: a New Implementation. ebruneton.github.io. https://ebruneton.github.io/precomputed_atmospheric_scattering (verified via http on 2026-11-29)
4. [implementation] takram-design-engineering (2024) takram-design-engineering/three-geospatial. https://github.com/takram-design-engineering/three-geospatial License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Precomputed Atmospheric Scattering." https://texelatlas.vercel.app/t/precomputed-atmospheric-scattering/ (accessed 2026-12-01).
