Contour Extract
Extract contour lines (iso-curves) from a ScalarField at a given threshold, using marching squares. Turns any scalar field into a shape at a level set.
Category: Shapes Menu path: Shapes > Contour Extract
Ports
| Port | Type | Direction | Description |
|---|---|---|---|
field_in | scalarField | input | Scalar field to extract contours from |
out | shape | output | Extracted contour(s) as a shape |
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
threshold | scalar | 0.5 | Level-set value. Contour traces where field == threshold. Keyframeable. |
resolution | scalar | 128 | Grid samples along the longer axis. Higher = smoother, quadratically more work. Clamped [4, 512]. |
output | enum | Bezier | Bezier fits Catmull-Rom cubic beziers through the contour for smooth curves. Polyline emits straight-line segments (faceted, fastest). |
Expose Channels
When enabled (E button on node header), adds input ports that override params via edge connections:
| Port | Type | Overrides |
|---|---|---|
threshold_in | scalar | threshold |
resolution_in | scalar | resolution |
Useful for chaining a Time or Math node into threshold_in to sweep through level sets (animated topo reveal), or feeding an adaptive scalar into resolution_in to dynamically trade quality for speed.
How It Works
Contour Extract samples the input ScalarField on a regular grid covering the composition bounds, then runs marching squares to trace the iso-curve at threshold:
- For each cell in the grid, the four corners are classified as "inside" (≥ threshold) or "outside" (< threshold) — 16 possible configurations.
- Each configuration emits 0, 1, or 2 line segments crossing the cell. Endpoints are linearly interpolated along cell edges where the threshold is crossed.
- Saddle configurations (two diagonally-opposite inside corners) are disambiguated by sampling the cell center.
- Adjacent cells share edges by construction, so segments chain into continuous polylines.
- Closed loops (interior contours) produce closed paths; chains reaching the grid boundary produce open paths.
With output = Bezier, the final polyline is re-fit to cubic beziers via Catmull-Rom interpolation, so smooth fields produce smooth output without needing a downstream ResampleShape.
Output caveats
- No PointId stability. As the field animates, contours can merge, split, appear, or disappear. Output PointIds regenerate every frame.
- Sampling bounds are the composition's base resolution, origin-centered. Fields whose interesting features fall outside the comp bounds will get clipped at the edges.
- Fill rule is always
NonZeroon output. Multiple nested contours (a contour with holes) will render correctly when winding is preserved.
Usage Examples
Metaballs
Circle A ──► DistanceField ──► ScalarField.out ─┐
├──► FieldMath (SmoothMin, t=0.3) ──► ContourExtract (threshold: 0.5) ──► DrawShape
Circle B ──► DistanceField ──► ScalarField.out ─┘Two circles that attract and merge when they get close (SmoothMin blends their distance fields smoothly). Animate the circle positions for classic metaball motion.
Topo lines
Noise (scalarField) ──► ContourExtract (threshold: 0.3) ──► DrawShape
Noise (scalarField) ──► ContourExtract (threshold: 0.5) ──► DrawShape
Noise (scalarField) ──► ContourExtract (threshold: 0.7) ──► DrawShapeThree contour nodes at different thresholds on the same noise field → stack of topo lines like a contour map.
Blob text
Text("HI") ──► TextToShape ──► DistanceField ──► FieldMath (SmoothMin, k=10) ←── DistanceField ←── Text("HI")
│
└──► ContourExtract ──► DrawShapeRough equivalent — fatten letterforms into blob silhouettes via SDF blending. Great for animated title reveals.
Voronoi region edges
Voronoi (scalarField, mode: F2-F1) ──► ContourExtract (threshold: 0.02) ──► DrawShapeExtract cell boundaries as vector paths — Voronoi diagrams rendered as strokable shapes instead of textures.
Noise-driven organic silhouette
Noise ──► Remap (curve: wave) ──► ContourExtract (threshold: 0.5) ──► DrawShapeOrganic, noise-driven closed shapes for marker blobs, paint splats, or abstract motion-graphics fills.
Tips
- Start at 128 resolution — good balance of smoothness and speed at 1080p. Crank to 256 or 512 for extreme closeup; drop to 64 for previewing complex field chains.
- Animate
thresholdfor "reveal from inside out" effects on SDFs. ForDistanceFieldoutput, threshold 0 is at the shape boundary; lower values are outside, higher are inside. - Pair with
OffsetPathdownstream to grow/shrink the contour by a fixed amount after extraction. - Multi-threshold passes need separate nodes in v1 — connect one scalar field to N ContourExtract nodes, each with a different threshold. (A multi-output variant may come later.)
- Topology changes are silent. If the field evolves through a merge or split, the output path count jumps — downstream PointId-keyed nodes will desync on that frame. This is unavoidable for contour extraction, same limitation as ShapeBoolean.
Related Nodes
- DistanceField — produces SDFs, the most common input for ContourExtract
- Noise — scalar noise → topo lines
- Voronoi — F2-F1 mode produces cell-boundary scalar fields
- FieldMath —
SmoothMin/SmoothMax/Add/Multiplyto blend multiple fields before contouring - ShapeBoolean — alternative for hard-edged shape combining (no smoothness); contouring blended SDFs gives soft metaball-style merging
- ResampleShape — resample the extracted contour for even vertex spacing