---
id: "preetham-sky"
title: "Preetham Analytic Daylight Model"
aliases: [Perez sky, A Practical Analytic Model for Daylight]
domain: "volumes"
stage: "volume"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu]
year_introduced: 1999
inputs: [material-params]
outputs: [radiance, hdr-image]
style: "photoreal"
dynamic: "dynamic"
cost: "cheap"
authority: "Preetham et al., 1999"
url: "https://texelatlas.vercel.app/t/preetham-sky/"
sources_verified_at: "2026-11-29"
---
# Preetham Analytic Daylight Model (Preetham et al., 1999)

> 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.

## 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

## 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 use it

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](https://texelatlas.vercel.app/t/hosek-wilkie-sky.md) for better accuracy near the horizon and in the circumsolar region, and for ground-albedo control. Prefer [Scalable Production Sky and Atmosphere (Hillaire)](https://texelatlas.vercel.app/t/hillaire-sky-atmosphere.md) or [Precomputed Atmospheric Scattering](https://texelatlas.vercel.app/t/precomputed-atmospheric-scattering.md) when the camera leaves the ground, you need sunsets below the horizon, or you need atmosphere on geometry.

## Cost

cheap — A few dozen ALU operations per pixel, no textures.
Measured GPU Weight: 3.71× baseline (light) — 0.122 ms median / 0.1285 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 3.22× baseline (light) — 0.0512 ms median (2.38× faster on L4).
Ampere A100 scaling: 2.18× baseline (light) — 0.0627 ms median (1.95× faster on A100).

## Failure modes

- 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

## Engine support

- babylonjs: official — `@babylonjs/materials SkyMaterial (Preetham atmospheric scattering)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/materials/src/sky/skyMaterial.ts, checked 2026-12-01)
- blender: builtin — `Sky Texture node > Sky Type = Preetham` (evidence: https://docs.blender.org/manual/en/5.2/render/shader_nodes/textures/sky.html, checked 2026-12-01) — Marked legacy and slated for removal.
- threejs: official — `import { Sky } from 'three/addons/objects/Sky.js'` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/objects/Sky.js, checked 2026-12-01)

## Dataflow

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

## Presets

### Preetham analytic sky: turbidity 2 (left) vs 8 (right) (glsl-fragment; rendered 2026-11-29)

```json
{
  "turbidity_left": 2,
  "turbidity_right": 8
}
```

```glsl
// 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

## Lineage

- extended by [Hosek-Wilkie Sky Model](https://texelatlas.vercel.app/t/hosek-wilkie-sky.md)

## Combines with

- [Exponential Height Fog](https://texelatlas.vercel.app/t/exponential-height-fog.md): Fog color is taken from the sky model's horizon radiance so distant geometry fades into the sky.

## Sources

1. [primary] A. 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. https://doi.org/10.1145/311535.311545 (verified via crossref on 2026-11-29)
2. [implementation] mrdoob (2010) mrdoob/three.js. https://github.com/mrdoob/three.js License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Preetham Analytic Daylight Model." https://texelatlas.vercel.app/t/preetham-sky/ (accessed 2026-12-01).
