Nodes/MKRShift_Nodes/Texture Edge Pad
ComfyUI Node

Texture Edge Pad

The anti-burn fix for texture islands — pad the edges before you paint

By criskb·Created 7 months ago·Updated 5 months ago· 0
Texture Edge Pad
  • image
  • source_mask
  • image
  • mask
  • edge_pad_info
settings_json{"source_mode":"alpha","pad_pixels":16,"alpha_threshold":0.01,"expand_alpha":false}

If you've ever baked a texture or done an inpaint pass on a masked region, you know the plague: bleeding - where color from the unmasked area smears into your work because the operation didn't know where the real edge was. Texture Edge Pad fixes the precondition: it expands the valid region of a masked texture outward with clean edge-padded color, so downstream paint, blur, and bake operations have proper data to sample at the boundary. It's one of those unglamorous prep nodes that quietly prevents hours of cleanup.

How it works

The node takes an image and figures out where it's "valid" - that's what source_mode controls. With alpha (the default) it reads the image's alpha channel; with mask it uses the optional source_mask input; with luma_nonzero it treats any non-black luma as valid. Pixels below alpha_threshold count as outside. Then _edge_pad_rgb expands the valid region by pad_pixels using edge padding - each invalid pixel inherits the color of the nearest valid pixel on the boundary. No smearing, no transparency gradient, just a clean skirt of edge color around your island.

expand_alpha is the subtle toggle: when on, it also pads the alpha channel itself so the mask extends with the pad. When off, the pad is color-only and the mask stays put - which matters if you want the pad region to be transparent afterward. Either way you get a fill mask output showing exactly what got padded.

The inputs that matter

Inputs: an image, one settings_json box, and an optional source_mask (used when source_mode is mask). The knobs:

  • source_mode - alpha / mask / luma_nonzero
  • pad_pixels - how far to extend the edge (16 default)
  • alpha_threshold - the cutoff for what counts as valid (0.01 default)
  • expand_alpha - whether the alpha gets padded too

Outputs: image (the padded result), mask (the fill mask - which pixels got padded), and edge_pad_info with resolved settings.

Installing it

Ships in MKRShift Nodes from criskb. ComfyUI Manager → "MKRShift Nodes", or:

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart ComfyUI; it's under MKRShift Nodes → Surface → Texture. No models or extra deps - numpy/Pillow/torch.

Common gotchas

The pack is too new for community lore, so trust the source. Standard MKRShift traps: broken settings_json silently reverts to defaults; out-of-range values clamp. One gotcha specific to this node: the mask source mode only works if you actually feed a source_mask - if you select it without wiring one, the node silently falls back to luma-based detection, which will confuse you. And if your alpha channel is antialiased with soft edges, a threshold of 0.01 might treat wispy semi-transparent pixels as valid; nudge it up for cleaner islands. Set pad_pixels generously relative to your filter sizes - padding that's too small for your blur radius is the classic cause of residual bleeding.

CategoryMKRShift Nodes/Surface/Texture

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
settings_jsonSTRING{"source_mode":"alpha","pad_pixels":16,"alpha_threshold":0.01,"expand_alpha":false}
source_maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
edge_pad_infoSTRING