Nodes/DOGMA Nodes/DOGMA v40 Masked Source Latent
ComfyUI Node

DOGMA v40 Masked Source Latent

The soft version, and when soft is what you want

By axior·Created 4 months ago·Updated 3 days ago· 1
DOGMA v40 Masked Source Latent
  • latent
  • mask
  • latent
  • info

A mask isn't a mask until it's inside the latent. DOGMAMaskedLatentV40 is the simplest node in this pack and one of the most consequential: it takes a LATENT and a MASK and writes a noise_mask into a copy of the latent, so the sampler only re-renders inside your selection. The interesting part is how it writes it - with a wide, soft feather rather than a hard edge.

What goes in the latent

The node builds the diffusion mask like this: a 13-pixel max-pool dilation, then a 31-pixel average-pool, then another 15-pixel average-pool, clamped to 0–1. The dilate grows the selection slightly; the two averaging passes then turn that growth into a gradient, so the mask runs from full strength in the middle out to nothing over a broad skirt of pixels. The result is stored as noise_mask in a copy of your latent, shaped to the latent's own resolution - which is why you write it into the latent rather than compositing at pixel level: the sampler needs it at latent scale, and this node does that conversion for you.

The reason for the feather is the classic one. A hard-edged generation mask produces a hard-edged result, and at latent resolution that edge isn't a line of pixels, it's a line of 8-pixel blocks - the "visible cut line" the pack's own notes cite. Softening it out is what keeps a repaired region from looking like a sticker, and it's the same reasoning behind raising mask blur when a detection-based crop leaves a seam.

Worth noting how far past the usual guidance that goes: the conventional starting range for mask blur is roughly 4–12 pixels, and this node's skirt is effectively much wider than that. Which is either exactly what your grassy region needed or the reason your car came back vague - see below.

When you actually want this one

The soft, wide skirt is a surfaces tool. Grass, asphalt, water, foliage, walls - regions where you want the repair to fade into what's around it, with no discernible boundary, and where the exact selection matters less than the transition. Pushing the mask well past the object and letting the sampler blend outward is a feature there.

It is the wrong tool for a discrete object. If the mask is translucent across the whole car, the sampler treats the whole car as partially re-renderable, and the "partially" shows up as soft, half-regenerated detail - body panels that look slightly mushy rather than rebuilt. Same family of problem as any under-strong inpaint mask: the model does a little work everywhere and none of it lands.

If you catch yourself reading this and thinking "so for cars I want something else" - yes. That's DOGMAMaskedLatentV542. Same two inputs, opposite philosophy, hard opaque core. If you're in a mixed graph with both categories, you can run one of each on the appropriate branch.

Inputs and outputs

latent and mask in; latent and info out. The info string reports coverage as a percentage, which is the number to check first when a pass did nothing.

Install

ComfyUI Manager → search DOGMA Nodes, or:

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

Restart. No pip dependencies at all - this is torch.nn.functional pooling over a tensor you already have. No models involved: the node sits between your VAE encode and your sampler.

Where it bites

It copies the latent and sets noise_mask, so it doesn't mutate anything upstream - re-running the graph with a different mask won't half-apply an old one. That part is safe.

The pooling constants are fixed. There's no dilation or softness widget, so if your mask edges are already very soft (SAM output sometimes is, after downsampling and re-upsampling), the extra smoothing compresses the whole gradient and you get a very weak mask. Watch the reported coverage: if it's much lower than the fraction of the image your object occupies, that's the mask having been feathered into near-nothing, and the pass will barely do anything.

And remember the mask is written at latent scale. If your mask came in at a different aspect than the latent, the reshape will do what it can but you're better off resizing the mask to the image before it reaches this node - that's what the pack's dedicated resize nodes are for.

CategoryDOGMA/v40

Inputs (2)

NameTypeDefaultDescription
latentLATENT
maskMASK

Outputs (2)

NameTypeDescription
latentLATENT
infoSTRING