DOGMA MaskedDenoiseLatent v56.6
Encode the crop with the mask already attached
- positive
- negative
- vae
- pixels
- mask
- positive
- negative
- latent
This is the node that turns a verified crop into something a sampler can denoise in place. It's a VAE-encode with a noise mask on it, plus a bit of graph tidiness - conditioning in, conditioning out, so a crop pass doesn't need three parallel wires crossing the canvas.
What it's for
The DOGMA phase-3 loop crops an instance, re-renders that crop at a resolution the model can spend pixels on, and stitches it back. That re-render is a masked img2img - exactly the operation the KB's inpainting doc describes: the model gets convinced that the unmasked region is fixed context and only the masked region is denoised from noise (or partially from existing pixels, depending on the mask and the sampler's behaviour).
The DOGMA-specific part is which mask arrives. Not a hand-painted one, not the exact ownership mask, but the dilated support mask from DOGMADualMaskV566 - the verified pixels plus a small margin so the generated region isn't fighting the boundary. And the shape discipline: the crop has to be VAE-friendly, or the whole exercise is off by half a latent cell.
How it works
Three things, in order:
- A hard padding check. If either side of the crop isn't a multiple of 16, it raises:
DOGMA denoise crops must be padded to multiples of 16; refusing a shifted VAE crop.A VAE downsamples by 8 and diffusion latent packing takes it to 16, so anything else means the crop and the latent don't line up - and a shifted crop produces a seam that looks like a rendering bug but is really an arithmetic one. The author refuses rather than rounding silently, which is the correct call and also means your crop node upstream has to do the padding. - Tiled encode.
vae.encode_tiled(pixels, tile_x=tile_size, tile_y=tile_size, overlap=overlap)- ComfyUI's built-in tiled VAE encode, so a big crop doesn't blow VRAM in the encoder even if the diffusion pass fits. - The noise mask. If
noise_maskis on (default), the mask is reshaped, bilinearly interpolated to the pixel dimensions, clamped to 0–1 and stored aslatent['noise_mask']. Same resolution as the image, not the latent - ComfyUI handles the mapping. Turn it off and you get a plain latent: the whole crop gets denoised with the pixels as the starting point, which is what you want for a soft refinement of a good tile and not what you want for a surgical mask repair.
Inputs and outputs
- positive, negative - CONDITIONING. Passed straight through to the outputs, so you can chain this node inline instead of routing conditioning around it.
- vae - the encoder. Obviously must be the VAE that matches your checkpoint; a mismatched VAE here shows up as colour mush in the crop, which is the "grey box around face" failure the KB's inpainting doc attributes to VAE round-trips.
- pixels - the padded crop IMAGE.
- mask - the sampling mask, i.e.
DOGMADualMaskV566'sinpaint_mask. - noise_mask - BOOLEAN, default true. On: only the mask region is denoised. Off: the whole crop, mask ignored.
- tile_size - 512 to 4096, default 3136, step 64. Tiled encode tile size in pixels.
- overlap - 64 to 512, default 128, step 32. Encode tile overlap.
Outputs: positive, negative, latent. Conditioning goes into your sampler as usual; the latent goes into the sampler's latent input (the DOGMA graphs use custom sampling with the pack's Klein-tuned samplers, and the latent carries the noise mask for you).
Install
comfy node install comfyui-dogma-nodes
# or
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
pip install -r ComfyUI-DOGMA-Nodes/requirements.txt
Restart afterwards. The README claims the pack is PyTorch-only; requirements.txt ships scipy>=1.10 and this module imports it, so install properly rather than copying files around. Nothing to download for this node specifically - but a mismatched or missing VAE is the most common reason it misbehaves.
Gotchas
The multiple-of-16 error is the one you'll hit. It comes from the crop you fed it, so the fix is upstream: pad the crop (and remember the stitcher has pad_right/pad_bottom in its own metadata, which exist precisely because the pipeline pads crops and then has to undo it on paste).
noise_mask off is not "no masking". It means the mask isn't supplied to the sampler at all - the entire crop is fair game. For a tile you've already verified, that's often what you want; for a repaired object in a busy street, it's how you get the whole crop re-invented around a correct subject.
Heavy VAE tiling is slower, not faster. Lowering tile_size trades speed for VRAM monotonically - worth knowing when a 2K crop plus a 9B model refuses to fit and you're wondering whether to shave the tile or the overlap. Shave the tile.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| vae | VAE | — | |
| pixels | IMAGE | — | |
| mask | MASK | — | |
| noise_mask | BOOLEAN | true | — |
| tile_size | INT | 3136512–4096 | — |
| overlap | INT | 12864–512 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| latent | LATENT | — |