Preetham Analytic Daylight Model
Closed-form sky luminance and chromaticity as a function of sun position and turbidity, using Perez distribution coefficients fitted to simulations; trivial to run per pixel.
Also known as Perez sky, A Practical Analytic Model for Daylight
In the family Atmosphere, water & volumes, atmosphere
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { Sky } from 'three/addons/objects/Sky.js' docs |
| Babylon.js 9.38.0 | Official add-on | @babylonjs/materials SkyMaterial (Preetham atmospheric scattering) docs |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | Built in | Sky Texture node > Sky Type = Preetham docs Marked legacy and slated for removal. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The model computes the xyY color of any sky direction. Luminance and the two chromaticities each follow a Perez formula: a product of a gradient term over zenith angle and a scattering-indicatrix term over the angle to the sun, normalized by the same expression evaluated at the zenith. The five Perez coefficients for each channel are linear functions of turbidity, and the zenith values are polynomial fits of turbidity and sun elevation. Aerial perspective is a separate approximate analytic extinction and in-scatter along the ray. Everything is evaluated in a fragment shader from a handful of constants, then converted xyY to RGB and tonemapped. Turbidity (roughly clear to hazy) is the main art control.
When to choose it
Reach for it when
- need a quick sky dome with a sun angle slider
- cheap daylight sky for a demo
- sky lighting for image-based lighting without textures
- turbidity-controlled haze on a procedural sky
- small shader that gives a plausible sky
Choose it for a quick, cheap sky dome with turbidity and sun-angle sliders, for background skies in demos, and for feeding a plausible environment light into image-based lighting.
Prefer Hosek-Wilkie Sky Model for better accuracy near the horizon and in the circumsolar region, and for ground-albedo control. Prefer Scalable Production Sky and Atmosphere (Hillaire) or Precomputed Atmospheric Scattering when the camera leaves the ground, you need sunsets below the horizon, or you need atmosphere on geometry.
Field marks
- Sky below the horizon and around sunset is unreliable; the fit was made for sun elevations above the horizon
- Overly dark or saturated zenith at low turbidity and low sun
- Perez term overestimates glow near the horizon, producing a flat white band
- Only valid from ground level: no altitude, no planet curvature, no space view
- Circumsolar region is smooth, so there is no realistic sun disc, only an added blob
Presets
Preetham analytic sky: turbidity 2 (left) vs 8 (right)
{
"turbidity_left": 2,
"turbidity_right": 8
}Show GLSL (35 lines)
// Preetham analytic daylight sky (Perez luminance distribution in xyY, turbidity-driven coefficients).
// Same view and sun in both halves; only turbidity changes: left T=2 (clear), right T=8 (hazy).
vec3 preetham(vec3 rd, vec3 sd, float T) {
float ts = acos(clamp(sd.y, -1.0, 1.0));
float ct = max(rd.y, 0.02);
float gam = acos(clamp(dot(rd, sd), -1.0, 1.0));
vec3 cA = vec3(0.1787 * T - 1.4630, -0.0193 * T - 0.2592, -0.0167 * T - 0.2608);
vec3 cB = vec3(-0.3554 * T + 0.4275, -0.0665 * T + 0.0008, -0.0950 * T + 0.0092);
vec3 cC = vec3(-0.0227 * T + 5.3251, -0.0004 * T + 0.2125, -0.0079 * T + 0.2102);
vec3 cD = vec3(0.1206 * T - 2.5771, -0.0641 * T - 0.8989, -0.0441 * T - 1.6537);
vec3 cE = vec3(-0.0670 * T + 0.3703, -0.0033 * T + 0.0452, -0.0109 * T + 0.0529);
float chi = (4.0 / 9.0 - T / 120.0) * (3.14159 - 2.0 * ts);
float Yz = (4.0453 * T - 4.9710) * tan(chi) - 0.2155 * T + 2.4192;
float t2 = ts * ts, t3 = t2 * ts;
float xz = T * T * (0.00166 * t3 - 0.00375 * t2 + 0.00209 * ts) + T * (-0.02903 * t3 + 0.06377 * t2 - 0.03202 * ts + 0.00394) + (0.11693 * t3 - 0.21196 * t2 + 0.06052 * ts + 0.25886);
float yz = T * T * (0.00275 * t3 - 0.00610 * t2 + 0.00317 * ts) + T * (-0.04214 * t3 + 0.08970 * t2 - 0.04153 * ts + 0.00516) + (0.15346 * t3 - 0.26756 * t2 + 0.06669 * ts + 0.26688);
vec3 zen = vec3(Yz, xz, yz);
vec3 F = (1.0 + cA * exp(cB / ct)) * (1.0 + cC * exp(cD * gam) + cE * cos(gam) * cos(gam));
vec3 F0 = (1.0 + cA * exp(cB)) * (1.0 + cC * exp(cD * ts) + cE * cos(ts) * cos(ts));
vec3 xyY = zen * F / F0;
float X = xyY.y / xyY.z * xyY.x, Z = (1.0 - xyY.y - xyY.z) / xyY.z * xyY.x;
return vec3(3.2406 * X - 1.5372 * xyY.x - 0.4986 * Z, -0.9689 * X + 1.8758 * xyY.x + 0.0415 * Z, 0.0557 * X - 0.2040 * xyY.x + 1.0570 * Z);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 rd = normalize(vec3(uv.x * 1.4, uv.y * 1.4 + 0.5, -1.0));
vec3 sd = normalize(vec3(0.35, 0.55, -0.75));
float T = fragCoord.x < 0.5 * iResolution.x ? 2.0 : 8.0;
vec3 col = max(preetham(rd, sd, T), 0.0) * 0.07;
if (rd.y < 0.0) col = mix(col, vec3(0.04, 0.045, 0.04) * (1.0 + 0.1 * T), smoothstep(0.0, -0.03, rd.y));
col = 1.0 - exp(-col * 1.4);
if (abs(fragCoord.x - 0.5 * iResolution.x) < 1.0) col = vec3(1.0);
fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| preetham-sky-specimen | Tesla T4 1920x1080 | 3.71× baseline (light) · 0.122 ms / 0.129 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| preetham-sky-specimen | NVIDIA L4 1920x1080 | 3.22× baseline (light) · 0.051 ms / 0.052 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| preetham-sky-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 2.18× baseline (light) · 0.063 ms / 0.063 ms · 1.9× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Scalable Production Sky and Atmosphere (Hillaire), Lightcuts.
Crosses
- Exponential Height Fog: Fog color is taken from the sky model's horizon radiance so distant geometry fades into the sky.
Sources
- primaryA. J. Preetham, Peter Shirley, Brian Smits (1999). A practical analytic model for daylight. Proceedings of the 26th annual conference on Computer graphics and interactive techniques - SIGGRAPH '99.Verified via crossref · 2026-11-29doi:10.1145/311535.311545
- implementationmrdoob (2010). mrdoob/three.js. JavaScript 3D Library.GitHub API · license MIT · 2026-11-29