Skip to content
ExtendedSource checked

Signed Distance Function Evaluation

Computes distance to a shape boundary with sign indicating inside or outside.

Quick Facts

Compact metadata for implementation and discovery.

Category
Geometry
Difficulty
Intermediate
Family
Implicit Geometry
Tier
Extended
Status
Verified
Review
Source Checked
Sources
2
Formulas
1
Relationships
2
Code example
Ready
Visualization
Ready

Overview

Signed Distance Function Evaluation returns negative, zero, or positive values depending on whether a point is inside, on, or outside a shape.

Core Concepts

implicit surfacesigned distanceinside-outside testfield composition

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(1)

Average

O(shape complexity)

Worst

O(shape complexity)

Space

O(1)

When to Use

  • Use when implicit shapes or distance-aware queries are easier than mesh operations.
  • Use when ray marching is a central requirement.

When Not to Use

  • Avoid when exact surface topology or mesh connectivity is required.
  • Avoid when floating-point precision or degenerate geometry cannot be handled robustly.

What It Does

  • Measures distance to a boundary
  • Assigns inside or outside sign
  • Combines primitive distances for complex shapes

Use Cases

  • Ray marching
  • Collision queries
  • Procedural shape modeling

Inputs

  • Point position
  • Shape parameters

Outputs

  • Signed distance value

Key Formulas (1)

Sphere SDF

distance = length(point − center) − radius
distance = length(point - center) - radius

Computes signed distance from a point to a sphere.

Pseudocode

  1. 1.Choose the shape's distance function
  2. 2.Evaluate distance from the query point
  3. 3.Apply sign based on inside or outside
  4. 4.Combine with other fields if needed

Canonical Example

Input
sphere center = (0,0,0), radius = 2, point = (3,0,0)
Output
distance = 1
Explanation
The point is one unit outside the sphere surface.

Implementation Notes

  • Keep primitive distance functions small and test them at known inside, outside, and boundary points.
  • Use robust predicates or tolerances when near-degenerate inputs are expected.
  • Keep a tiny example with expected output beside the implementation.

Common Pitfalls

  • Combining fields with non-distance-preserving operations can break sphere tracing assumptions.
  • Collinear, overlapping, and duplicate points need explicit tie-breaking rules.
  • Not defining boundary, empty, or degenerate inputs before implementation.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show contour bands around a shape where zero marks the boundary.

Signed Distance Function Evaluation mechanism walkthrough step 1 of 4
Step 1 of 4: Choose the shape's distance function
geometry-diagram

Notes

Exact signed distances are not always preserved after arbitrary field operations.

Sources (2)

What each reference supports for this entry.

Sphere Tracing

Paper

Reference for using signed distance functions and distance bounds in implicit surface rendering.

Open source

Physically Based Rendering

Book

Rendering reference for Signed Distance Function Evaluation's ray queries, acceleration structures, or implicit-geometry use case.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Sphere tracing advances rays using signed-distance function evaluations.

Related Algorithms

Tags

GeometrySigned Distance FieldRay MarchingGraphics