Building a live golden-hour sky with WebGL
The sky at the top of this page isn’t an image or a video. It’s a shader, drawn fresh every frame.
The header of this blog is a single WebGL fragment shader. Every frame, each pixel asks the same question — what colour should I be right now? — and answers it with layered noise.
Four tones
The whole palette is four colours: cream, apricot, tangerine and terracotta. The shader blends them with burn and mix operations, so the sky always stays inside the golden-hour range.
Layers of noise
- Domain warping bends the coordinates so clouds swirl instead of scrolling.
- Fractal noise adds soft, cloud-like structure at several scales.
- Three horizon bands — low, middle and high — drift at different speeds for depth.
- Film grain keeps the gradients from banding on cheaper displays.
Being a good citizen
A beautiful background isn’t worth a hot laptop. The sky:
- pauses when it scrolls out of view or the tab is hidden,
- renders a single still frame when your system asks for reduced motion,
- caps its resolution on very large screens,
- and falls back to a static gradient when WebGL isn’t available.