Nodes/Advanced Mask Nodes/Directional Mask Blur
ComfyUI Node

Directional Mask Blur

The mask blur that picks a direction

By evanscho·Created 6 months ago·Updated 6 months ago· 0
Directional Mask Blur
  • mask
  • MASK
angle_deg180
radius10
blend_modebbox
falloff1.0
single_passfalse
edge_paddingreplicate
sdf_iterations30

A normal mask blur is a blunt instrument. Run a Gaussian over a mask and it eats into the edge evenly on every side, which is fine for hiding a seam and wrong for almost everything directional. Directional Mask Blur is the version that knows which way the light comes from: one side of the mask gets fully blurred while the opposite side stays sharp, with a smooth gradient between. It's the difference between feathering a mask and aiming the feather.

The realistic use case is compositing and inpainting prep. When you're pasting a masked subject back onto a background, you usually want the transition softened - but not uniformly. If the light in the scene comes from the left, a mask edge that fades out on the left reads as soft shadow while a hard edge on the right reads as silhouette. Same mask, one treatment, completely different result. The same logic applies to one-sided feathering on an inpaint region so the regenerated content blends into the original where a shadow or gradient would naturally land.

How it works

The mechanism is clean and worth understanding, because it explains every input. The node first computes a full omnidirectional Gaussian blur of the mask - the same thing MaskGrow and PIL's GaussianBlur give you, with sigma equal to radius. Then it builds a per-pixel weight map along the direction you picked and blends: weight 1 → fully blurred, weight 0 → the original mask, everything in between a lerp. One side of the mask ends up feathered, the other untouched.

That weight map is where the two blend_mode options differ. bbox (the default) projects every pixel onto the angle axis relative to the mask's bounding-box center and normalizes by the box's extent along that axis. It's a straight line across the whole bounding box - fast and predictable. sdf instead computes a signed-distance field from the mask boundary and propagates directional weights inward from boundary pixels, then smooths the result. It adapts to the actual shape of the mask, so it handles irregular blobs (hands, hair, non-convex shapes) much better - at the cost of running a propagation loop over the whole image.

The inputs that matter

  • angle_deg - compass-style: 0° = up, 90° = right, 180° = down (the default), clockwise. This is the trap. Most people reaching for this node assume math-style angles; get this backwards and you blur the wrong side of your mask and wonder why it looks worse than a plain blur.
  • radius - the Gaussian sigma in pixels. 0 returns the mask unchanged, so it's safe to start at 0 and push it up until the leading edge is as soft as you want.
  • blend_mode - start with bbox. Switch to sdf only when you have an irregular mask and the bbox gradient clearly misplaces the falloff.
  • falloff - a power curve on the weight (default 1.0). Below 1 spreads the blur further toward the trailing edge; above 1 concentrates it near the leading edge. This is the "how snappy is the gradient" dial.
  • single_pass, edge_padding, sdf_iterations - leave them alone until something looks wrong. single_pass uses one giant kernel instead of splitting big radii into multiple passes; edge_padding is replicate/reflect/zero for convolution edges; sdf_iterations only matters in sdf mode.

The single MASK output slots straight into the usual chain: feed it to Set Mask and then into a KSampler for inpainting, or wire it into any compositing step where you need a mask whose edge behaves like the scene.

Install

It ships in the Advanced Mask Nodes pack (author evanscho), which is dependency-free - no pip requirements, no model downloads, pure PyTorch that rides on ComfyUI's own torch. ComfyUI Manager: search "Advanced Mask Nodes". Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/evanscho/ComfyUI-advanced-mask-nodes
# restart ComfyUI

One genuine gotcha: the pack's README tells you to clone evanscho/advanced_mask_nodes (underscores). That repo 404s - the real one is hyphenated, above. Use the Manager or the hyphenated URL and you're fine.

Notes

The pack is young (a single commit as of early 2026) and GPL-3.0 licensed, so there's little community lore to lean on and it's not one for shipping inside a closed product. But the math here is simple, tested, and it does one thing no stock mask node does. If you've ever spent ten minutes fighting a blur that wouldn't fade the way the light in your image demanded, this is the fix.

Categorymask

Inputs (8)

NameTypeDefaultDescription
maskMASK
angle_degFLOAT1800–360
radiusINT100–256
blend_modeCOMBObbox2 options: bbox, sdf
falloffFLOAT1.00.1–5
single_passBOOLEANfalse
edge_paddingCOMBOreplicate3 options: replicate, reflect, zero
sdf_iterationsINT305–200

Outputs (1)

NameTypeDescription
MASKMASK