Rendering the Sky, Sunsets, and Planets

· devtools · Source ↗

TLDR

  • Step-by-step browser shader tutorial covering raymarching, Rayleigh/Mie scattering, and ozone absorption to render realistic skies and planetary atmospheres in real time.

Key Takeaways

  • Raymarching casts per-pixel rays through the atmosphere, accumulating optical depth via Rayleigh, Mie, and ozone density functions to compute transmittance.
  • Rayleigh scattering explains the blue sky: shorter wavelengths scatter more, redirecting blue light toward the viewer.
  • Mie scattering adds a sun halo and horizon haze from larger particles like dust; ozone absorption deepens and shifts sky color near the horizon.
  • Accurate sunsets require a nested light-march loop per sample point to account for sunlight lost traveling through atmosphere before reaching the camera ray.
  • The article culminates in Sebastian Hillaire’s LUT-based approach for performance, presented as the author’s most challenging implementation phase.

Hacker News Comment Review

  • No substantive HN discussion yet.

Original | Discuss on HN