Distance Field
Generates a signed distance field from a shape input. Outputs scalar, vector, and color fields plus an optional GPU texture, with configurable falloff curves.
Category: Fields Menu path: Fields > Distance Field
Ports
| Port | Type | Direction | Description |
|---|---|---|---|
shape_in | shape | input | Source shape to compute distance from |
out | imageRgba16f | output | GPU texture visualization (grayscale, only computed if connected) |
scalarField | scalarField | output | Normalized [0, 1] distance field with falloff |
vectorField | vectorField | output | Unit vector pointing toward the nearest boundary |
colorField | colorField | output | Grayscale RGBA representation of the scalar field |
Parameters
| Param | Type | Default | Description |
|---|---|---|---|
falloff | scalar | 100 | Distance in pixels from the shape boundary to zero |
falloffType | enum | Smooth | Falloff curve: Linear, Smooth, Exponential, Quadratic, or Step |
invert | boolean | false | Swap inside/outside (inverted: 0 at boundary, 1 at falloff distance) |
Expose Channels
When enabled (E button on node header), adds input ports that override params via edge connections:
| Port | Type | Overrides |
|---|---|---|
falloff_in | scalar | falloff |
How It Works
DistanceField computes the shortest distance from every point in space to the nearest edge of the input shape. The result is normalized through the falloff curve:
- Default behavior: 1.0 at and inside the boundary, falling to 0.0 at
falloffdistance from the boundary. - Inverted: 0.0 at the boundary, rising to 1.0 at
falloffdistance.
Falloff types:
- Linear: Straight-line falloff
- Smooth: Smoothstep curve (default, gentle ease in/out)
- Exponential: Fast initial drop, slow tail
- Quadratic: Squared falloff
- Step: Binary -- 1 inside falloff range, 0 outside (hard edge)
SDF algorithm: Line segment projection for straight edges, cubic bezier sampling with Newton refinement for curves. Ray-cast winding number for inside/outside detection (even-odd, closed paths only). Per-segment AABB acceleration for performance.
Field outputs: All three field outputs share a single SdfEvaluator via Arc. The scalarField returns normalized [0, 1] values. The vectorField returns a unit vector pointing toward the nearest boundary segment. The colorField returns grayscale RGBA.
Lazy GPU texture: The out texture port is only computed if something is connected to it. The field outputs are always available at near-zero cost.
DistanceField is a terminal in chain walks -- it fills every pixel (like Noise and Gradient), so overscan does not pass through it.
Usage Examples
Basic: Proximity mask
Circle -> DistanceField (falloff: 200, Smooth) -> scalarField -> PointAttributes (target: Opacity). Points fade out as they move away from the circle.
Flow around geometry
Rectangle -> DistanceField -> vectorField -> PointAdvect. Points are pushed away from the rectangle along the nearest-boundary direction.
Shape glow
EditableShape -> DistanceField (falloff: 50, Exponential) -> out (texture) -> Colorize (ramp: transparent-to-white). A soft glow halo around the shape.
Composite field
DistanceField1.scalarField + DistanceField2.scalarField -> FieldMath (Screen). Combines two shape proximity fields into a soft union.
Animated falloff
Enable expose channels. Connect Time.seconds -> Math expression -> falloff_in. The glow radius pulses over time.
Tips
- The
outtexture is computed lazily -- if you only need the field outputs, leave it disconnected for better performance - DistanceField works with any shape node: Rectangle, Circle, Polygon, EditableShape, TextToShape, etc.
- Use Remap downstream to reshape the falloff curve with more control than the built-in falloff types
- The vectorField output is ideal for PointAdvect -- points flow toward or away from the shape boundary
- Invert is useful for effects that should be strongest near the shape and fade at distance
- Bezier accuracy at high falloff: Shapes with few bezier segments (like Circle's 4 quadrant arcs) can show subtle radial artifacts at high falloff values. Insert a ResampleShape node before the DistanceField to add more segments — this produces a clean, smooth field
Related Nodes
- Noise -- procedural field source (vs. geometry-based)
- Remap -- reshape the distance field's value distribution via curve
- FieldMath -- combine multiple distance fields
- PointAdvect -- advect points using the vectorField output
- PointAttributes -- set per-point attributes based on proximity
- ShapeAttributes -- set per-vertex attributes based on proximity
- Colorize -- map the scalar field through a color ramp