Never overshoot, never miss

Sphere tracing, one step at a time

The marcher has no idea where the surface is. All it can ask is “how far is the nearest surface from here?” — and then it may safely travel exactly that far, because nothing can be closer. Press Step to advance the ray one iteration; each circle is the empty space the SDF just guaranteed. Drag the two handles to re-aim, then push the step multiplier above 1.0 and watch the guarantee break.

The march step 0
Drag the camera dot or the aim dot
camera / ray origin aim distance travelled hit
Loop parameters the four knobs
0.010
64
9.0
1.00

A multiplier of 1.0 is the sphere tracing guarantee: step exactly the distance returned, and the ray can never pass through anything.

The loop live values

      
What the camera sees one ray per column
Cost — iterations needed per ray
few → many iterations worst column:
Why the silhouettes glow the cost of grazing

A ray heading straight at the middle of a sphere converges in a handful of steps — each answer is large, so each stride is long. A ray that just grazes the edge is a different story: it spends its whole journey close to the surface, so the SDF keeps returning small numbers and the ray keeps taking tiny steps, often exhausting the iteration budget without ever hitting anything.

That is why the cost strip lights up along every silhouette. Sphere tracing is cheap in open space and expensive near surfaces — the exact opposite of the cost profile you get from intersecting triangles, and the reason a raymarched scene can be fast to write and slow to render.

Drop max steps until the far geometry starts to dissolve, and you are watching the iteration budget run out mid‑flight. Raise ε instead and the surfaces stay, but they thicken and soften — the ray now calls it a hit while it is still short of the real surface.

Steps taken
Distance returned d
Travelled t
Average stride
Result
The multiplier is the whole argument. At 1.0 the circles are tangent to the path — each one touches the next, and the chain of empty circles tiles the ray without a gap, which is the geometric proof that nothing was skipped. Push it to 1.4 and the circles start to overlap the geometry: the ray lands inside a surface and the loop happily calls it a hit, so the recorded depth is wrong and the shaded strip above dents and tears. Push it further and thin features vanish entirely as the ray steps clean over them. Below 1.0 nothing breaks — it is simply slower, more steps for the same journey, which is occasionally worth it for fields that are not true distance functions.