3D / WebGL2023-12 · 10 min

Shaders for Designers: A Gentle Intro to GLSL

You don't need to be a mathematician to write shaders — here's the designer's mental model.

A shader is a function per pixel

Strip away the jargon and a fragment shader is simple: it's a small program that runs once for every pixel and answers one question — 'what color should this pixel be?'. You get the pixel's position, some inputs you choose (time, mouse, textures), and you return a color.

Everything else is composition. Gradients, noise, glow — they're all just math that maps a position to a color.

The designer's toolkit

Start with the three moves that get you 90% of the way: `mix()` to blend colors, `smoothstep()` to shape transitions, and a noise function to add organic variation. A gradient plus noise plus a subtle time-based shift already looks alive.

Add fresnel — brightening edges based on viewing angle — and suddenly a flat shape looks dimensional. These four ideas power most of the 'expensive' WebGL you've ever admired.

Iterate like you're designing

Shaders reward play. Change a number, see what happens, keep what looks good. Use a live preview tool, save versions, and don't be precious — the best shader effects are usually a happy accident you noticed and kept.