Skip to content

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 ​

PortTypeDirectionDescription
shape_inshapeinputSource shape to compute distance from
outimageRgba16foutputGPU texture visualization (grayscale, only computed if connected)
scalarFieldscalarFieldoutputNormalized [0, 1] distance field with falloff
vectorFieldvectorFieldoutputUnit vector pointing toward the nearest boundary
colorFieldcolorFieldoutputGrayscale RGBA representation of the scalar field

Parameters ​

ParamTypeDefaultDescription
falloffscalar100Distance in pixels from the shape boundary to zero
falloffTypeenumSmoothFalloff curve: Linear, Smooth, Exponential, Quadratic, or Step
invertbooleanfalseSwap 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:

PortTypeOverrides
falloff_inscalarfalloff

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 falloff distance from the boundary.
  • Inverted: 0.0 at the boundary, rising to 1.0 at falloff distance.

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 out texture 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
  • 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