Studio Yotsuba
Back to Node List

Region Distance

region_distance

Turns distance from region borders into a grayscale gradient - darken near the borders for mortar shadows, or brighten centers to fake volume

Reviewed
Guide available

Input Ports

NameTypeDescription
Regions
regions
RegionMap
Required
RegionMap to measure

Output Ports

NameTypeDescription
Distance
distance
Image
Grayscale distance map
Mask
mask
Image
White mask for pixels within max distance
Preview
preview
Image
Stacked preview: regions on top, distance on bottom
Labels
labels
Map
UI overlay label positions for the inspector

Parameters

NameTypeDefaultRangeDescription / Options
Source
source
Enum
Boundary—

Pixels used as distance sources

  • BoundaryBoundary
    Measure from boundaries between different ids
  • OutsideOutside
    Measure from OUTSIDE pixels
  • RegionIdRegionId
    Measure from one region id
  • IdRangeIdRange
    Measure from region ids inside a range
Region ID
region_id
Int
00–2147483647

Region ID

Min ID
min_id
Int
00–2147483647

Min ID

Max ID
max_id
Int
2550–2147483647

Max ID

Metric
metric
Enum
Manhattan—

Distance metric

  • ManhattanManhattan
    4-neighbor pixel distance
  • ChebyshevChebyshev
    8-neighbor block distance
  • EuclideanEuclidean
    8-neighbor weighted distance
Max Distance
max_distance
Float
160–512 / step 1

Distance mapped to white

Falloff
falloff
Enum
Linear—

Distance value curve

  • LinearLinear
    Linear ramp
  • SmoothSmooth
    Smoothstep ramp
  • StepStep
    Hard white/black mask
Invert
invert
Bool
false—

Invert output brightness

Inside Only
inside_only
Bool
true—

Keep outside pixels transparent

Preview Seed
seed
Int
10–99999

Changes preview colors only; distance and mask outputs are unchanged

Show IDs
show_ids
Bool
false—

Show region id labels on the inspector preview

Overview

Turns the number of pixels from a RegionMap boundary or specified region into a grayscale image. It creates helper maps for distance-based effects from a boundary, such as a bright shoreline edge, shadows along rock outlines, or an inward gradient.

Usage tips

  • The go-to edge effect uses source=Boundary, stepped falloff, and max_distance=1–3 to make a mask covering a band N pixels from the boundary. Pass it to downstream color adjustment or compositing for effects such as a bright strip along a shoreline.
  • For gradual shading, use linear or smooth falloff with a larger max_distance. Multiplying by the distance image directly creates shading that darkens toward the boundary.
  • Enable inside_only when the effect should remain inside the material, preventing it from leaking beyond the silhouette.
  • Pass distance or mask downstream. Do not use preview, which is a combined image for inspection.

Related nodes

  • region_border — produce the line itself instead of distance
  • region_fill — combine with the base fill
  • region_mask — turn a particular region into a mask
  • blend — composite shading using the distance map

Outputs the distance from RegionMap boundaries, the outside, or specified IDs as a grayscale image. It is suited to helper maps for shorelines, rock edges, shading near boundaries, and inward gradients.

Key parameters

ID Description
source Distance origin: region boundary, outside, specified ID, or ID range
region_id / min_id / max_id Target for a specified ID or ID range
metric Distance metric: Manhattan, Chebyshev, or standard distance
max_distance Maximum distance used for the grayscale conversion
falloff Linear, smooth, or stepped
invert Invert light and dark
inside_only Keep OUTSIDE pixels transparent
show_ids Show ID labels in the Inspector preview

Enabling inside_only prevents the distance image from leaking outside the silhouette, making it convenient for processing edges inside an asset.

The distance output is not a numeric value; it is an Image that visualizes distance in grayscale. Hovering over the pin shows only metadata such as image size. To inspect the actual distances, connect distance to a Preview node or view this node's input/output port display.

This node's own preview combines two images vertically for inspection. The top half color-codes the input RegionMap, and the bottom half is the same distance image as distance. Downstream nodes should use distance or mask, not the combined preview.

Preview Seed changes only the region colors in the top half. It does not affect distance, mask, or the calculated distances.

How to use

To add a uniform shadow or edge color near boundaries, set source = Boundary, falloff = Step, and max_distance = 1–3, then pass mask or distance to a downstream composition or color-adjustment node. Use linear or smooth falloff when the effect should weaken with distance from the boundary.

Use source = ID or ID Range to calculate how many pixels lie from particular regions. This produces helper maps for effects such as shorelines, rock edges, or darkening only around a particular material.

Back to Node List