---
title: Raymarching & SDFs
order: 3
---

If you haven't done it yet, start with [First Launch](first-launch.md) and carve your first shape. Come back here when you want to understand the math under the hood.

## What is a Signed Distance Field?

A Signed Distance Field (SDF) defines a shape as a function: for any point in space, return the *distance to the surface*. Outside the shape, distance is positive. Inside, it's negative. On the surface, it's zero.

Instead of storing vertices, edges, and faces, an SDF *is* a math expression. That gives you:

- **Infinite resolution** — surfaces are mathematically smooth at any zoom
- **Perfect booleans** — combining shapes is `min` / `max` on distances
- **Free fillets** — smooth blends fall out of the math, no extra geometry
- **No topology issues** — no n-gons, non-manifold edges, or bad normals

## What is raymarching?

Raymarching renders SDFs by stepping rays through space. For each pixel, a ray fires from the camera. At every step the SDF reports the distance to the nearest surface, so the ray can safely advance by exactly that distance. When the distance falls below the *hit threshold*, the ray stops and the pixel is shaded.

| | Rasterization (EEVEE) | Path tracing (Cycles) | Raymarching (Chisel) |
|---|---|---|---|
| **Input** | Triangles | Triangles | Distance functions |
| **Precision** | Mesh density | Mesh density | Mathematically exact |
| **Booleans** | Mesh ops | Mesh ops | Math ops |
| **Speed** | Very fast | Slow | Real-time for SDF |

## Why SDF modeling?

**Strengths**

- Iterate fast — add, subtract, blend without re-topologizing
- Smooth fillets on any boolean operation
- Per-primitive edge rounding with five profile shapes
- Convert to mesh only when you ship, with multiple algorithms

**Trade-offs**

- No UV painting until you convert to mesh
- GPU-bound — needs a reasonable graphics card
- Very dense scenes can slow the viewport
- External export requires conversion

## How Chisel uses SDFs

Every primitive is a distance function. Modifiers compose those functions:

- **Add a primitive** → register a new distance function
- **Add a boolean modifier** → take `min` / `max` of two distance functions
- **Adjust blend radius** → smoothly interpolate between them
- **Render** → ray-march the composed expression per pixel
- **Convert to mesh** → sample the field with Dual Contouring or Marching Cubes

You work with smooth, resolution-independent shapes throughout, and only commit to a polygon resolution at the very end.
