The primitives tour
Purpose
See the handful of mathematical building blocks that compose virtually every shader — eight tiny demos, one per primitive, so you recognize them on sight.
edge, 0. Above, 1.t.dot(normal, light).Key insight
About a dozen operations cover 90% of what real shaders do. Every effect later in the lab is some combination of these. They're not algebra — they're verbs.
step is "is x past this line?" smoothstep is the same question with a soft answer. mix is "blend two things." dot is "how aligned are two directions?" length is "how far from origin?" fract is "tile everything." sin is "make it wave." noise is "controlled randomness."
Once each of these has a face, reading shaders stops being decoding and becomes recognition.
Break it
1. Put the step and smoothstep demos side-by-side. Pull smoothstep's softness to 0. They look identical. Teaches: smoothstep is step when softness is zero — they're the same tool in different modes.
2. In the dot demo, rotate the angle past 90° (slider past ±1.5). The sphere goes dark on the back. Internally, dot is going negative — we clamp it to zero, which is why surfaces facing away from a light are black in Lambert shading (Lesson 17).
3. In the fract demo, set repeat to a non-integer like 3.7. The last tile looks crooked — a partial repeat. Teaches: tiling cleanly requires integer multiples.
Direct Claude
Each primitive now has a name you can use directly in a brief. Some common requests: