{
 "id": "hosek-wilkie-sky",
 "title": "Hosek-Wilkie Sky Model",
 "aliases": [
  "Hosek sky",
  "analytic full-spectral sky-dome radiance"
 ],
 "domain": "volumes",
 "subdomain": "atmosphere",
 "stage": "volume",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu"
 ],
 "year_introduced": 2012,
 "inputs": [
  "material-params"
 ],
 "outputs": [
  "radiance",
  "hdr-image"
 ],
 "style": "photoreal",
 "dynamic": "dynamic",
 "summary": "Analytic sky-dome radiance fitted to brute-force atmospheric simulations, with turbidity, ground albedo and solar elevation controls and a correct sun-disc and horizon behaviour.",
 "how_it_works": "Like the Perez-style approach, the sky radiance is a closed-form expression in the view direction and sun angle, but the fit is far more accurate. A nine-parameter formula adds terms for the circumsolar brightening (a Mie-like lobe), for horizon darkening, and for multiple scattering, with a ground-albedo dependence. The nine coefficients and a zenith radiance are not computed analytically: they are interpolated from tables obtained by fitting simulation data over turbidity, albedo, solar elevation and wavelength. The RGB variant uses tables for three wavelength bands, and a spectral version covers many bands. At run time you fetch the coefficients once per frame on the CPU (sun elevation and turbidity change slowly) and evaluate one formula per pixel on the GPU.",
 "when_to_use": "Choose it for ground-based skies when you want accurate color from dawn to dusk, including a visible solar aureole, and when the table-lookup coefficients can be baked into uniforms.\n\nPrefer `preetham-sky` when a smaller code footprint is more important than accuracy. Prefer `hillaire-sky-atmosphere` when you need aerial perspective, camera altitude changes or a sun below the horizon. Prefer `precomputed-atmospheric-scattering` for planet-scale views.",
 "cost": {
  "class": "cheap",
  "notes": "One formula evaluation per pixel; coefficient interpolation is done on the CPU once per frame."
 },
 "failure_modes": [
  "Coefficient tables are large and embedded as data, which makes porting error-prone",
  "Valid only for sun above or near the horizon; twilight needs another model",
  "No aerial perspective: distant objects are not tinted",
  "Ground albedo only changes the sky radiance, not the ground itself",
  "RGB fit can show a slight hue shift versus the spectral version"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/2185520.2185591",
   "type": "paper",
   "title": "An analytic model for full spectral sky-dome radiance",
   "authors": [
    "Lukas Hosek",
    "Alexander Wilkie"
   ],
   "year": 2012,
   "venue": "ACM Transactions on Graphics",
   "url": "https://doi.org/10.1145/2185520.2185591",
   "ids": {
    "doi": "10.1145/2185520.2185591"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2185520.2185591",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2185520.2185591",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2185520.2185591",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2185520.2185591",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2185520.2185591",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "hosek2012analytic"
  }
 ],
 "presets": [
  {
   "id": "hosek-wilkie-sky-live",
   "title": "Hosek-Wilkie analytic sky dome with circumsolar aureole, turbidity and ocean reflection",
   "runtime": "glsl-fragment",
   "params": {
    "TURBIDITY": 3,
    "SUN_ELEV": 0.24,
    "ALBEDO": 0.35,
    "EXPOSURE": 1.1
   },
   "basis": "original",
   "license_note": "MIT — written for this index",
   "code": "const float TURBIDITY = 3.0; // P\nconst float SUN_ELEV = 0.24; // P\nconst float ALBEDO = 0.35; // P\nconst float EXPOSURE = 1.1; // P\n\nfloat chi(float g, float cosG) {\n  float d = max(1.0 + g * g - 2.0 * g * cosG, 1e-4);\n  return (1.0 + cosG * cosG) / pow(d, 1.5);\n}\n\nvec3 hosekSky(vec3 dir, vec3 sunDir, float turb, float elev, float alb) {\n  float cosT = max(dir.y, 0.002);\n  float cosG = clamp(dot(dir, sunDir), -1.0, 1.0);\n  float gamma = acos(cosG);\n  float t = clamp((turb - 1.0) / 9.0, 0.0, 1.0);\n  float s = clamp(elev / 1.4, 0.0, 1.0);\n\n  // Hosek-Wilkie 9-parameter structure fitted across turbidity, elevation & ground albedo\n  vec3 A = mix(vec3(-1.12, -1.08, -0.98), vec3(-0.78, -0.82, -0.88), t);\n  vec3 B = mix(vec3(-0.34, -0.38, -0.44), vec3(-0.18, -0.22, -0.26), t);\n  vec3 C = mix(vec3(0.28, 0.42, 0.68), vec3(0.82, 0.72, 0.60), t) * (1.0 + 0.35 * alb);\n  vec3 D = mix(vec3(3.8, 2.4, 1.2), vec3(1.5, 1.25, 0.95), s) * mix(1.0, 1.5, t);\n  vec3 E = vec3(-2.6, -2.85, -3.2);\n  vec3 F = mix(vec3(0.24, 0.30, 0.42), vec3(0.18, 0.20, 0.22), t);\n  vec3 G = mix(vec3(0.05, 0.065, 0.08), vec3(0.14, 0.13, 0.11), t);\n  vec3 H = mix(vec3(0.22, 0.48, 1.05), vec3(0.65, 0.62, 0.58), t) * (0.65 + 0.5 * alb);\n  float gMie = mix(0.74, 0.88, t);\n\n  vec3 expM = exp(E * gamma);\n  vec3 rayM = vec3(cosG * cosG);\n  vec3 mieM = vec3(chi(gMie, cosG));\n  vec3 zenith = mix(vec3(0.26, 0.20, 0.34), vec3(0.12, 0.38, 0.95), pow(s, 0.55));\n  zenith = mix(zenith, vec3(0.45, 0.44, 0.46), t * 0.45) * (0.45 + 0.85 * s);\n\n  vec3 Fval = (1.0 + A * exp(B / (cosT + 0.01))) * (C + D * expM + F * rayM + G * mieM + H * sqrt(cosT));\n  vec3 sky = max(Fval * zenith, 0.0);\n\n  // Limb-darkened solar disk + aureole\n  float sunRad = 0.028;\n  float ang = gamma;\n  float disk = smoothstep(sunRad, sunRad * 0.55, ang);\n  float limb = sqrt(max(1.0 - (ang / sunRad) * (ang / sunRad), 0.0));\n  vec3 sunCol = mix(vec3(1.0, 0.36, 0.10), vec3(1.0, 0.94, 0.84), pow(s, 0.45)) * mix(1.0, 0.72, t);\n  sky += sunCol * (disk * (14.0 + 22.0 * limb) + 0.38 * exp(-ang * 7.0) * (1.0 + t));\n  return sky;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float elev = clamp(SUN_ELEV + 0.06 * sin(iTime * 0.35), 0.03, 1.35);\n  float azim = 0.25 * sin(iTime * 0.22);\n  if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {\n    vec2 m = iMouse.xy / iResolution.xy;\n    elev = clamp(m.y * 1.15 + 0.03, 0.03, 1.35);\n    azim = (m.x - 0.5) * 1.8;\n  }\n  vec3 sunDir = normalize(vec3(sin(azim) * cos(elev), sin(elev), -cos(azim) * cos(elev)));\n  vec3 rd = normalize(vec3(uv.x, uv.y + 0.14, -1.05));\n\n  float turb = max(TURBIDITY, 1.0);\n  float alb = clamp(ALBEDO, 0.0, 1.0);\n  vec3 col;\n  if (rd.y >= 0.0) {\n    col = hosekSky(rd, sunDir, turb, elev, alb);\n  } else {\n    float t = -1.2 / min(rd.y, -0.002);\n    vec2 p = rd.xz * t;\n    float w1 = sin(p.x * 1.4 + iTime * 1.6 + sin(p.y * 0.8)) * 0.015;\n    float w2 = cos(p.y * 2.1 - iTime * 1.2 + p.x * 0.7) * 0.012;\n    vec3 n = normalize(vec3(w1, 1.0, w2));\n    vec3 refl = reflect(rd, n);\n    refl.y = max(refl.y, 0.004);\n    float fres = 0.04 + 0.96 * pow(1.0 - max(dot(-rd, n), 0.0), 5.0);\n    vec3 skyR = hosekSky(normalize(refl), sunDir, turb, elev, alb);\n    vec3 sea = vec3(0.012, 0.032, 0.065) * (0.25 + 0.65 * sin(elev));\n    col = mix(sea, skyR, fres * 0.85);\n    vec3 horiz = hosekSky(normalize(vec3(rd.x, 0.005, rd.z)), sunDir, turb, elev, alb);\n    col = mix(horiz, col, exp(-0.018 * t));\n  }\n  col *= max(EXPOSURE, 0.1);\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "hosek-wilkie-sky",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T16:15:34.232Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.8386,
      "std": 0.1046,
      "unique_colors": 82
     },
     "image": "/specimens/hosek-wilkie-sky-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "preetham-sky",
  "hillaire-sky-atmosphere",
  "precomputed-atmospheric-scattering"
 ],
 "extends": [
  "preetham-sky"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "exponential-height-fog",
   "why": "Sky horizon radiance gives a matching fog color."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/volumes/hosek-wilkie-sky.json"
 },
 "solves": [
  "need accurate daytime sky colour from dawn to dusk",
  "sun halo and horizon look wrong in my analytic sky",
  "sky dome with turbidity and ground albedo controls",
  "want a visible solar aureole cheaply",
  "realistic sky without a full atmosphere simulation"
 ],
 "authority": "Hosek & Wilkie, 2012",
 "url": "https://texelatlas.vercel.app/t/hosek-wilkie-sky/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 4.79,
  "tier": "light",
  "p50_ms": 0.1577,
  "p95_ms": 0.1591,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "hosek-wilkie-sky-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 4.2,
   "tier": "light",
   "p50_ms": 0.0668,
   "p95_ms": 0.0668,
   "speedup_x": 2.36,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 2.89,
   "tier": "light",
   "p50_ms": 0.0833,
   "p95_ms": 0.0835,
   "speedup_x": 1.89,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}