Nodes/DOGMA Nodes/DOGMADualMaskV545
ComfyUI Node

DOGMADualMaskV545

A wide mask to sample through, a tight one to paste with

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMADualMaskV545
  • mask
  • inpaint_mask
  • blend_mask
  • inpaint_preview
  • blend_preview
  • info
kind

The newest mask node in this pack, and the one with the cleanest statement of its own contract, lifted straight from its docstring: "The inpaint mask may extend outside the SAM mask to give diffusion context. The FINAL blend seed never grows outside the cleaned semantic mask."

Read that twice, because it's the whole design. A SAM mask is a tight polygon around an object. Sampling through it is a bad idea - the model can't see five pixels past the boundary, so it has nothing to reconcile the new content with, and you get a hard edge and sometimes a visible scale change. Sampling through a wide, dilated region is much better. But pasting the whole wide region back means you've overwritten a chunk of the image the model happily invented while it was "filling in context."

So you use two masks: wide for generation, tight for compositing. This node builds the pair with three extra pieces of thinking the older ones don't have.

What's different here

Morphological closing before anything else. Not just a threshold - a dilate followed by an erode, which welds small holes and gaps in a noisy mask without growing it. Tiny islands inside an object, or a mask that flickers on and off along an edge, get cleaned into one solid region. If the mask is longer than 896px on its long side, the closing runs at a downsampled resolution and gets upsampled back, because a full-resolution close on a 4K plate is slow for no visible benefit.

The blend mask is a hard binarization of the closed core with no outward growth at all. Not a feather, not a half-pixel of dilation: the exact cleaned semantic mask. That's the "FINAL blend seed" sentence being literally true rather than aspirational.

The kind string changes the numbers. kind is a string input, and the node branches on it. STRUCTURE gets a looser threshold (0.22), a bigger closing radius, and the widest inpaint growth. SURFACE tightens the threshold (0.28) and the growth. Anything else falls to the default branch - tighter still, minimal closing, moderate growth. Both branches scale their pixel values off the image's short side, so the same settings behave sanely at 1080p and at 4K, which is more than you can say for the v34 mask node.

Inputs and outputs

  • mask (MASK)
  • kind (STRING) - STRUCTURE or SURFACE; anything else takes the default path.

Five outputs: inpaint_mask (MASK, wide, for the sampler), blend_mask (MASK, tight, for the composite), inpaint_preview and blend_preview (both IMAGE), and info (STRING).

Those two preview images are the friendliest thing in the entire pack. You can look at exactly what each mask covers before you spend a single sampling step - no guessing whether the wide mask is eating the neighbour's car. Wire them to a Preview Image while you tune, then delete the previews. The info line backs it up with the numbers: threshold, closing radius, the growth applied, and the reminder that the blend seed doesn't grow.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes

ComfyUI Manager → DOGMA Nodes, or comfy node install comfyui-dogma-nodes. Zero external dependencies - requirements.txt in the repo is a comment, pyproject.toml declares dependencies = [], and the imports are torch, numpy and comfy.utils. No models. MIT licensed.

Where people get burned

Wiring the wide mask into the stitch. It's the natural mistake: one mask comes out first, and it's the one you see. If your composite boundary extends past the object, the model's invented context is landing in your image. The blend mask is the one that goes to the paste.

Expecting the blend mask to have a feather. It doesn't, by design - so if your mask was a hard SAM polygon, you'll get a hard edge on the composite and blame the stitch node. The fix is to feed a slightly soft or already-feathered mask in, or to check whether your stitch node applies its own feathering. The pack's DOGMAExactCoreStitchV35 won't invent one for you.

Using the wrong kind for what you're doing. STRUCTURE is for objects with real internal geometry (a building, a vehicle); SURFACE for broad material regions (ground, wall). Choosing STRUCTURE for a flat surface means a wider inpaint region for no reason, which is the most expensive kind of no reason - every extra pixel of mask is sampled.

Version drift. The category is DOGMA/v56.4, the class name says 545, and nothing in the README explains either. This is the newest generation of the mask step in a pack that also ships v34 and v35 versions of the same idea. If you're starting fresh, start here and use the previews; if you inherited a graph using the old ones, don't assume the strings and dials mean the same things.

CategoryDOGMA/v56.4

Inputs (2)

NameTypeDefaultDescription
maskMASK
kindSTRING

Outputs (5)

NameTypeDescription
inpaint_maskMASK
blend_maskMASK
inpaint_previewIMAGE
blend_previewIMAGE
infoSTRING