Back to Blog

What is a signed distance field?

The scalar function that quietly underpins most modern 3D ML. Interactive intuition, minimal math.

April 13, 2026
mlcomputer-graphicssdfthree.js

The function

Think of a 3D scene as a function. You pass in a point in space, it tells you something about that point.

For a signed distance field (SDF), the function tells you:

How far is this point from the nearest surface, and am I inside or outside?

More precisely: the value it returns is literally the Euclidean distance from p to the nearest surface point, in world units, with a sign indicating side:

  • sdf(p) > 0 → outside the shape; value = distance to surface
  • sdf(p) = 0on the surface
  • sdf(p) < 0 → inside the shape; value = -(distance to surface)

The "signed" part is the sign bit. The "distance" part is a real distance, not a proxy. This seemingly small commitment ("the number is literally a metric distance") is what makes everything else about SDFs work.

Why the literal-distance property matters

Three consequences fall out for free:

1. Rendering is cheap. You can march rays from a camera pixel into the scene, stepping forward by sdf(p) at each step. Guaranteed the largest step you can take without hitting anything. Every raymarch function on Shadertoy uses this.

2. Geometry is composable. Union: min(sdfA(p), sdfB(p)). Intersection: max(sdfA, sdfB). Subtraction: max(sdfA, -sdfB). Smooth blends are similarly closed-form. Clean, differentiable, no mesh booleans required.

3. ML loves it. Instead of learning a mesh (topology annoying) or voxels (memory expensive), a neural network can learn the scalar function itself. DeepSDF, NeRF, and their descendants all lean on this.

Visualizing the full field

Same idea in 3D. Remember: an SDF is a function defined everywhere in space, not just on the surface. Below is a uniform 3D grid of points where each point shows the SDF value sampled at its position. Color encodes signed distance via a diverging ramp: deep red far inside, orange/yellow as you approach the surface from inside, near-white right at the surface (sdf = 0), then cyan/blue moving outward, deep blue at the far edges. The solid mesh in the center is the actual surface.

Drag to orbit. Use the slice slider to bisect the volume and see the interior structure. Turn on iso-shells to overlay concentric surfaces of constant distance. Switch shapes to see how the field changes.

/ FAQ

What is a signed distance function (SDF)?

An SDF is a scalar function f(p) that returns the Euclidean distance from a point p to the nearest surface in a scene, with a sign that's negative inside the shape and positive outside. The level set where f(p) = 0 is the surface itself.

Is it called signed distance function or signed distance field?

Both, interchangeably. Signed distance function emphasizes the math object (a function from 3D space to a scalar) and is more common in ML papers like DeepSDF. Signed distance field emphasizes that it's a value at every point in space (like a vector field) and is more common in real-time graphics. Either abbreviates to SDF.

How is sphere tracing different from regular ray tracing?

Traditional ray tracing tests each ray against geometric primitives (typically triangles) in the scene to find the nearest hit. Sphere tracing exploits the fact that an SDF tells you the distance to the nearest surface from any point, so each ray can step forward by exactly that distance and is guaranteed not to overshoot. The whole renderer is about five lines of code with no acceleration structures.

Why do ML researchers care about signed distance functions?

Three big reasons: (1) SDFs are differentiable everywhere, so they plug into gradient-based losses cleanly. (2) They're a compact representation: a small neural network can encode a high-fidelity shape that would need megabytes of voxels. (3) They're topology-agnostic, sidestepping the headaches of mesh-based representations. Models like DeepSDF and NeRF are built on this foundation.

Are SDFs better than polygon meshes?

Different tools for different jobs. SDFs win for procedural and analytic scenes (Shadertoy, fractals, generative art) and as ML representations. Polygon meshes plus GPU rasterization still dominate real-time rendering of complex scenes. SDFs aren't replacing meshes; they're an alternative for specific use cases.

Is this FAQ for SEO?

Yes. Also genuinely useful, hopefully. Search engines reward FAQ schema, which means questions like the ones above can show up directly in Google results. So this section is a small gift to both you and the algorithm.