Studio Yotsuba
Back to Node List

Distance

distance_field

Turns a mask into a grayscale distance map — the base for glows and edge gradients

Reviewed
Guide available

Input Ports

NameTypeDescription
Image
input
Image
Required
Mask image (alpha or brightness decides the shape)

Output Ports

NameTypeDescription
Map
output
Image
Grayscale distance map

Parameters

NameTypeDefaultRangeDescription / Options
Source
source
Enum
Alpha—

Which value decides inside vs outside

  • OKLCH-LOKLCH-L
    Use perceived brightness. Good when you want the result to match how bright it looks.
  • OKLCH-COKLCH-C
    Use how colorful the pixel is.
  • HSV-SHSV-S
    Use HSV saturation.
  • HSV-VHSV-V
    Use HSV value.
  • RGB-RRGB-R
    Use the red channel.
  • RGB-GRGB-G
    Use the green channel.
  • RGB-BRGB-B
    Use the blue channel.
  • AlphaAlpha
    Use alpha.
  • LuminanceLuminance
    Use Rec.709 RGB luminance.
Region
region
Enum
Outside—

Which side of the edge to measure

  • OutsideOutside
    Shape stays white, fading outward — good for glows
  • InsideInside
    Bright at the center and exactly black on inside boundary pixels — good for inner shading
  • BothBoth
    Signed distance: exactly 0.5 on boundary pixels, white inside, black outside
Max Distance
max_distance
Float
161–256 / step 1

Distance in pixels that maps to full black (or white)

Overview

Turns the distance in pixels from a silhouette's outline into a grayscale gradient. It is a versatile foundation for effects driven by distance from an outline, including glows, inner shading, and contour patterns.

Usage tips

  • The golden pattern for a glow is: silhouette → Distance (Outside) → gradient_map (glow colors) → layer over the original with blend (Add).
  • max_distance controls the reach of the effect. Use 4–8 for a glow, or 16 and above for a broad aura.
  • Choose region by intent: Outside for outward light or shadow, Inside for inner edge shading, and Both for contours or effects centered on the outline.
  • Shape membership uses a fixed threshold of 0.5 on the selected source. An empty shape produces an opaque black distance map in every region mode.
  • For pixel-art-like steps, reduce the number of tones downstream (with a posterize-style node) to produce a contour-like glow.

Related nodes

  • gradient_map — convert distance into color (commonly paired with this node)
  • blend — layer the result over the original image
  • region_distance — the RegionMap version of a distance map
  • morphology — expand or shrink the shape itself instead of measuring distance

Reading the output

region Inside Outline Outside
Outside White (1.0) White Darkens with distance from the boundary
Inside Brighter toward the center Black (0.0) Black
Both Above 0.5 through white 0.5 Below 0.5 through black

Technical details

  • Uses an approximate Euclidean distance calculated with a two-pass chamfer method (1 / √2 weights).
  • Boundary pixels in the measured region have distance 0. Consequently, the Inside boundary is exactly 0 and the Both boundary is exactly 0.5.
  • Inside treats the canvas edges as outside, so it still produces distances for a fully opaque tile.

Examples

  1. Glow: silhouette → Distance(Outside) → Gradient Map (glow color ramp) → layer over the original with Blend(Add)
  2. Inner shading: Distance(Inside) → Gradient Map to create a fill that is dark at the edge and bright at the center
  3. Contours: Distance(Both) → Posterize to create stripes that follow the shape
Back to Node List