
Once upon a time, I stumbled across an image of a beautiful shape — the trefoil knot (wikipedia).
It immediately caught my attention and felt like a perfect subject for some shader writing exercise. I decided to use a basic ray marching technique to render it and create some visually appealing results. The first challenge was finding a signed distance function (SDF) for the trefoil knot. Unfortunately, I couldn’t find a ready-made formula.
That’s when I came across Inigo Quilez’s work, where he demonstrates SDFs for Bézier spline segments. Inspired by this approach, I chose to represent the trefoil knot using Bézier splines.
I added some simple texturing, animation, and lighting to bring the scene to life.