The sphere is the simplest shape in signed distance field modeling. Its SDF formula is just one subtraction:
Take the distance from the query point to the center, then subtract the radius. That simplicity is exactly why the sphere shows up everywhere in ray marching and procedural modeling. Most SDFs are approximate, expensive, or both. The sphere is one of the rare shapes where the signed distance is exact for every point in space, computed with a single length operation and a subtraction. When a ray marcher steps through a sphere field, it never overshoots and never undershoots, because the distance bound is perfect.
The formula breaks into two parts:
- : the Euclidean distance from the sphere center to the query point
- Subtracting : shifts the zero crossing to the sphere surface
With this one-liner you can ray march a sphere, use it as a building block in constructive solid geometry, blend it with other shapes, or deform it into new forms. Many of the most impressive SDF scenes you have seen start with spheres composed together.
Sign Convention
Like all signed distance fields , the sphere SDF follows the same sign convention:
- Negative when is inside the sphere
- Zero when is on the surface
- Positive when is outside the sphere
Because the distance to center minus radius is always the true Euclidean distance to the surface, is never an approximation. That exactness makes the sphere a favorite for testing, debugging, and as a foundation for more complex shapes.
Worked Example
Take a sphere centered at with radius .
For a point directly above the center:
The result is positive 1, so the point is 1 unit outside the sphere surface.
For a point between the center and the surface:
The result is negative 3, so the point is 3 units inside the sphere, measured radially toward the surface.
Why the Sphere SDF Is a Building Block for Everything
The sphere is the closest thing SDF modeling has to a primitive. In ray marching , the renderer steps a ray forward by the signed distance at the current point. A sphere SDF guarantees that no surface exists closer than that distance, so the step is always safe. That guarantee makes sphere tracing fast and robust for spheres and for landscapes built from them.
The real power comes when you combine spheres. Union two spheres and you get a pill shape. Intersect them and you get a lens. Subtract one from another and you get a carved indentation. Every CSG operation preserves the signed distance property, so complex models built from spheres inherit the same exact distance behavior.
Most shapes in the SDF toolkit are compromises. A box SDF has edge rounding artifacts. A torus SDF needs a two-step distance calculation. A noise-based terrain has no closed-form SDF at all. The sphere is the one shape where the distance field is perfect everywhere. That is why it comes first in every introduction to the topic, and why it stays relevant long after you graduate to more complex forms.