doc 3 of 4

Thinking in Fragments — the Book of Shaders Track

The Book of Shaders (Patricio Gonzalez Vivo & Jen Lowe) is the canonical fragment-shader introduction — a free book with live code editors in the page: change the GLSL, see the result instantly. It's famously half-finished, but the chapters that exist are precisely the ones a 2D game dev needs.

How to work it#

Read a chapter in the browser, play with its inline editors — then redo the exercise as a canvas_item shader in Godot using the official GLSL → Godot conversion guide (gl_FragCoordFRAGCOORD, main()fragment(), and friends). The translation step isn't overhead; it's the rep that makes the knowledge yours and Godot-shaped.

The chapters, in order#

ChapterWhat you get
Hello World → UniformsThe mental model: one program, every pixel, in parallel
Shaping functionsThe most important chapter in the book — smoothstep, curves, remapping. This is the vocabulary every effect is written in
ColorsMixing, HSB, gradients
ShapesDrawing circles/boxes with math — the road to SDFs
MatricesRotating and scaling UV space
PatternsTiling tricks — very pixel-art-adjacent
RandomNoise → FBMThe organic-motion toolkit: wind, water, fire all start here

Stop there. The unwritten chapters don't exist, and what exists past FBM isn't 2D-relevant.

Optional video companion#

Freya Holmér — Shaders for Game Devs (part 1, part 2) — brilliant conceptual lectures on what the GPU actually does, blending math, SDF thinking. Taught in Unity/HLSL: watch for the ideas, write your code in Godot. ~3 hours each; part 3 is 3D-focused, skip it for now.

Prove it stuck#

Recreate the farming game's needs from raw math, each in-engine: a vignette (shaping functions), animated grass-wind displacement (noise + TIME on VERTEX), water shimmer (noise on UV before sampling TEXTURE). Rough is fine — recipe-quality versions come in doc 03; this pass is about knowing why they work.