DOGMA Union Macro Crops — Few Large Crops
How to feed 2K-4K tiles instead of a hundred little boxes
- image
- masks
- crops
- crop_masks
- stitch
- info
Most detailer automation crops per detection: one box per face, per car, per mask blob. That's the right answer when you're re-rendering faces. It's the wrong answer when you're doing a 4-step restoration pass on a 5K scan, because every crop costs you a full model load-and-sample round trip, and a hundred thumbnail-sized crops is a hundred chances for the model to invent something.
This node takes the opposite bet. Union everything into one region, then cut the minimum number of large crops needed to cover it.
How it decides
The union of your mask batch (anything above mask_threshold) gives a bounding box. The box is expanded by context_px for model context, then divided into windows of at most max_crop_side with a stride of max_crop_side - overlap, snapped to a 16px grid. That's the "divide and conquer" idea, and the KB's upscaling doc is the background here: overlapping tiles keep the model from losing context, which is why tile-ControlNet workflows beat naive tiling.
Two details are where the code earns its keep.
Ownership partitioning. Each crop contains the contextual overlap so the model has enough to look at, but the mask that comes out of the node is multiplied by an ownership rectangle, so any given pixel belongs to exactly one crop. You never paste the same pixels twice and average two generations into mush.
Split placement. Where two windows overlap, it picks the cut through the emptiest column or row of the mask - the argument of minimum mask density. So the seam lands in sky, not through the middle of a bus.
It will also refuse rather than lie: if the union needs more crops than max_crops allows, it raises and tells you exactly what it needed. Nothing gets silently dropped.
Inputs you actually set
image,masks- the master and the (already SAM'd or painted) mask batch.context_px(160) - padding around the union, purely for the model's benefit.min_crop_side(2048) /max_crop_side(4096) - the two numbers that define this node. Big native crops are the point; if you setmax_crop_sideto 1024 you've built a worse instance-crop node.overlap(768) - context shared between windows, not ownership.max_crops(8) - the guardrail. Raise it or raisemax_crop_sidewhen it complains.mask_threshold(0.5) - soft edges from SAM get hard-thresholded here.
Outputs crops, crop_masks, stitch, info - the first three are lists, so downstream restore and stitch nodes need list inputs. stitch carries the geometry (x, y, width, height, group_id) the stitch node needs to put each result back. info reports union area, bbox, crop count and overlap; it's your only diagnostics channel.
Install
ComfyUI Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes && git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Restart. Zero dependencies - requirements.txt is # No external dependencies. - and no model files. Be aware the pack's README documents the WAN VACE and sampler nodes only; the whole semantic-detailer suite, this node included, ships undocumented in dogma_semantic_v5641.py and registers itself into the menu on import. There is essentially no community documentation for it (a Reddit phrase search for the pack name returns nothing usable), so the source is the manual.
Where it bites
Mask thresholding a soft SAM mask at 0.5 can leave you with an empty union, and the node will say so rather than guess. Check the mask preview.
overlap and min_crop_side interact. If your union is only slightly larger than max_crop_side, the windowing adds a second crop for a sliver. Either widen max_crop_side or accept two crops - don't shrink overlap to nothing to avoid it, or your seam has no context to blend across.
These are native-resolution crops, so the VAE encode is your wall. 4K crops want tiled VAE encoding; this pack ships the node for it. Also remember that a 4-step distilled Klein pass at CFG 1 is the intended sampler, not something you should "strengthen" by pushing CFG.
If you actually wanted per-object passes - one crop per car so each gets its own prompt and denoise - you've got the wrong node. Union macro crops are for wholesale regional restoration: fewer, larger, same treatment for everything inside.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| masks | MASK | — | |
| context_px | INT | 1600–2048 | — |
| min_crop_side | INT | 2048256–8192 | — |
| max_crop_side | INT | 4096512–8192 | — |
| overlap | INT | 7680–2048 | — |
| max_crops | INT | 81–64 | — |
| mask_threshold | FLOAT | 0.500.01–0.99 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| crops | IMAGE | — |
| crop_masks | MASK | — |
| stitch | DOGMA_STITCH | — |
| info | STRING | — |