Signed distance fields and ray marching

Level AdvancedDifficulty ★★★★★Application⌖ Open in the map

What is it?

Represent a shape by the signed distance d(x)d(x) to its surface. Rays march forward by d(x)d(x) (it is always safe), the surface is d=0d = 0, and the normal is ∇d\nabla d. Neural SDFs learn dd with a network.

Formulas

∥∇d∥=1,n(x)=∇d(x)≈12h(d(x+hei)−d(x−hei))i=13\norm{\nabla d} = 1, \qquad n(x) = \nabla d(x) \approx \frac{1}{2h}\big(d(x + h e_i) - d(x - h e_i)\big)_{i=1}^{3}
eikonal property; normal by central differences

The mathematics behind it

  • Surfaces and level sets★★★★★fundamental

    An SDF represents a shape as the zero level set of a distance function.

  • Gradient★★★★★fundamental

    For a signed distance dd, ∥∇d∥=1\norm{\nabla d} = 1 and ∇d\nabla d is the surface normal; ray marchers estimate it by finite differences.

  • Scalar fields★★★★★frequent

    An SDF is a scalar field whose value is the signed distance to a shape.

This page has the essentials. A fuller treatment (intuition, formal definition, worked example) is on the way.

↑ ↓ to navigate · ↵ · Esc