Skip to content
ExtendedSource checked

Sphere Tracing

Ray marches signed distance fields using safe distance steps.

Quick Facts

Compact metadata for implementation and discovery.

Category
Rendering
Difficulty
Advanced
Family
Signed Distance Rendering
Tier
Extended
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
4
Code example
Not ready
Visualization
Ready
Aliases
SDF Ray Marching

Overview

Sphere Tracing advances each ray by the distance reported by a signed distance field, avoiding many tiny fixed steps.

Core Concepts

rendered imageray stepgeometric calculationsigned distance renderingscene representationvisibility testpixel output

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(p)

Average

O(p s)

Worst

O(p s)

Space

O(1)

When to Use

  • Use Sphere Tracing when you need to query a signed distance field.
  • Use it for implicit surface rendering with inputs like signed distance function.
  • Use it when the scene representation and quality target match the rendering tradeoff.
  • Use it when the Signed Distance Rendering tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when the cost per pixel or sample is too high for the desired frame rate.
  • Avoid it when the required output is not surface hits.

What It Does

  • Queries a signed distance field
  • Steps by the safe distance to the nearest surface

Use Cases

  • Implicit surface rendering
  • Procedural modeling
  • Shader demos

Inputs

  • Signed distance function
  • Camera rays

Outputs

  • Surface hits
  • Rendered image

Key Formulas (1)

Distance step

pointnext = point + distanceto surface(point) · raydirection
point_next = point + distance_to_surface(point) * ray_direction

Advances along a ray by the signed distance field value.

Pseudocode

  1. 1.Start at the ray origin
  2. 2.Evaluate distance to the nearest surface
  3. 3.Advance along the ray by that distance
  4. 4.Stop when distance is below a threshold
  5. 5.Shade the hit point or return background

Canonical Example

Input
scene = one triangle, one camera, one light
Output
image pixels showing the visible triangle
Explanation
Sphere Tracing: The algorithm converts scene data into visible pixel results.

Implementation Notes

  • Keep the input contract explicit: Signed distance function; Camera rays.
  • Use this step as the implementation spine: Start at the ray origin.
  • Then preserve the next state change: Evaluate distance to the nearest surface.
  • Build tiny scenes with known geometry before testing complex materials or lighting.

Common Pitfalls

  • Distance functions must be conservative for sphere tracing to avoid stepping through surfaces.
  • Ignoring coordinate spaces, depth precision, or sampling noise while debugging image artifacts.
  • Returning surface hits without handling empty, invalid, or boundary inputs.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show large safe ray steps shrinking near a surface.

Sphere Tracing mechanism walkthrough step 1 of 5
Step 1 of 5: Start at the ray origin
distance-field-steps

Notes

Sphere Tracing operates in O(p s) time and O(1) space within the Signed Distance Rendering family. Key governing relation: point_next = point + distance_to_surface(point) * ray_direction. Often compared with Ray Marching and Ray Tracing.

Sources (1)

What each reference supports for this entry.

Hart 1996

Paper

Original sphere tracing paper for rendering implicit surfaces using distance bounds.

Open source

Explore Next

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

Variant ofRay Marching

Sphere tracing advances by a signed-distance bound along the ray.

Sphere tracing relies on signed distance estimates.

Related Algorithms

Tags

GraphicsRay MarchingGeometry