Precomputed Atmospheric Scattering
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.
Also known as Bruneton sky
In the family Atmosphere, water & volumes, atmosphere
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Plugin | npm i @takram/three-atmosphere docs |
| Babylon.js 9.38.0 | Official add-on | @babylonjs/addons Atmosphere (LUT-based physically based atmospheric scattering) docs |
| Godot 4.7 | None found | |
| Unity | Built in | Volume > Add Override > Sky > Visual Environment > Sky Type = Physically Based Sky docs HDRP only. |
| Unreal 5.7 | Built in | Place Actors > Visual Effects > Sky Atmosphere (SkyAtmosphereComponent precomputed Rayleigh/Mie transmittance and multi-scattering LUTs) docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
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 choose it
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
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) 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 or Hosek-Wilkie Sky Model for a ground-only sky with a handful of turbidity sliders and no precompute. Prefer Ray-marched Rayleigh/Mie Single Scattering for a cheap ray-marched gradient.
Field marks
- 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
Presets
Precomputed Atmospheric Scattering — single-scatter limb (left) vs multi-scatter Rayleigh/Mie orbital twilight (right)
{
"P_SUN_ELEV": 0.1,
"P_ALTITUDE": 0.42,
"P_MIE_HAZE": 0.85,
"P_SPLIT": 0.48
}Show GLSL (141 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| precomputed-atmospheric-scattering-live | Tesla T4 1920x1080 | 19.1× baseline (moderate) · 0.628 ms / 0.650 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| precomputed-atmospheric-scattering-live | NVIDIA L4 1920x1080 | 18.6× baseline (moderate) · 0.295 ms / 0.298 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| precomputed-atmospheric-scattering-live | NVIDIA A100-SXM4-40GB 1920x1080 | 13.6× baseline (moderate) · 0.390 ms / 0.391 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Nubis-style Ray-marched Volumetric Clouds: Provides sky radiance and sun transmittance that tint and light the cloud layer.
- Froxel Volumetric Fog: Aerial perspective table supplies the far-field haze that the froxel grid hands over to.
Sources
- primaryEric Bruneton, Fabrice Neyret (2008). Precomputed Atmospheric Scattering. Computer Graphics Forum.Verified via doi.org · 2026-11-29doi:10.1111/j.1467-8659.2008.01245.x
- implementationebruneton (2017). ebruneton/precomputed_atmospheric_scattering. This project provides a new implementation of our EGSR 2008 paper "Precomputed Atmospheric Scattering".GitHub API · license BSD-3-Clause · 2026-11-29
- tutorialEric Bruneton. Precomputed Atmospheric Scattering: a New Implementation. ebruneton.github.io.Verified via live page · 2026-11-29
- implementationtakram-design-engineering (2024). takram-design-engineering/three-geospatial. Geospatial Rendering in Three.jsGitHub API · license MIT · 2026-11-29