← blog

Ray marching with signed distance fields: my annotated notes

2026-04-25 · Lex Morin

Signed distance functions clicked for me about six months ago when I stopped thinking of them as a rendering technique and started thinking of them as a geometry algebra.

The shift

Before that, I was cargo-culting SDF sphere-tracing code from Shadertoy without really understanding what I was manipulating. The distance field is just a function that tells you how far any point in space is from the surface of your shape. That's it. Everything else — union, intersection, subtraction, smooth blending — is arithmetic on that function.

Once that landed, I rewrote my ray marcher from scratch in a weekend and understood every line of it.

Annotated notes

I've been keeping a GLSL file with heavy comments as I work through more complex operations: elongation, revolution, extrusion, twist, bend. The logic isn't complicated but the notation in most references is terse enough that I kept forgetting why a particular sign flip was there.

The file is in the repository linked from the about page. It's not a tutorial, it's the notes I wish I'd had when I started. If it's useful to you, great; if something is wrong, tell me.


Also: 48-hour jam: what broke, what held, what I'd change