Regional Rect Masks (Nukun)
Three rectangles, previewed before you queue
- mask_1
- mask_2
- mask_3
Every regional-conditioning workflow needs a mask, and most of the time the mask you need is "a rectangle here, a rectangle there." This node makes those rectangles - two or three of them, positioned by percentage coordinates, with optional edge blur - and hands you the masks so you can preview them before anything gets generated. It's the mask-only sibling of Native Regional Rect Conditioning (Nukun): that node builds masks and applies conditioning in one step; this one just builds masks, for when you want to wire the masks into something else (native ConditioningSetMask, RES4LYF regional conditioning, or a workflow that already has its own mask-handling).
That separation is more useful than it sounds. Masks are the part you want to see; conditioning is the part you want to trust. Having the raw mask outputs means you can check your geometry without burning a generation on a typo'd coordinate.
How it works
width and height define the canvas. Each of the up to three regions has x, y, w, h in the 0.0–1.0 range - percentages, not pixels. x/y are the top-left corner, w/h the size. The defaults are three full-height columns (0.35 / 0.30 / 0.35), which is the right starting shape for a triptych.
soft_edge (0–256 px) blurs the rectangle edges. Start at 0 to see the hard rectangle in preview, then raise it until seams disappear in the output - the value that works depends on your resolution, and since you can see the mask, you can judge directly.
region_count is 2 or 3. At 2, region 3's controls are ignored and mask_3 comes back as an empty mask, so you don't need to clean up phantom inputs.
Inputs and outputs
Inputs: width, height, region_count, twelve rect coordinates (three × x/y/w/h), soft_edge. Outputs: mask_1, mask_2, mask_3. Wire the masks to a preview node (or the built-in rect editor) to see them, then to whatever consumes masks in your workflow.
One genuinely nice detail: this node (like its rect-conditioning sibling and the DenseDiffusion rect variant) ships a browser-side rectangle editor - a draggable canvas where you position the boxes by mouse instead of typing coordinates. Right-click and look for the rectangle editor option. For the fiddly part of regional work - "slightly more to the right, a touch wider" - that's a big quality-of-life win.
Installing it
Same pack install as the rest:
cd ComfyUI/custom_nodes
git clone https://github.com/OnekoSL/Nukun_ComfyUI_Nodes.git
Restart ComfyUI, or install via Manager (search "Nukun"). No dependencies beyond the pack's own - this is pure tensor math.
Common issues
Coordinates are top-left anchored percentages, so y = 1.0 puts the top edge at the bottom of the canvas and the rectangle disappears below it - the most common "where did my mask go" moment. If a rectangle vanishes, check you're not placing it off-canvas. Overlapping rectangles are allowed and the later region draws on top when masks combine downstream - fine if intentional, confusing if not. And don't forget masks are single-channel geometry: they don't know which prompt goes with which rectangle. That wiring is the conditioning node's job, or yours if you're doing it by hand.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10248–16384 | — |
| height | INT | 10248–16384 | — |
| region_count | INT | 32–3 | — |
| x_1 | FLOAT | 0.000–1 | — |
| y_1 | FLOAT | 0.000–1 | — |
| w_1 | FLOAT | 0.350–1 | — |
| h_1 | FLOAT | 1.000–1 | — |
| x_2 | FLOAT | 0.350–1 | — |
| y_2 | FLOAT | 0.000–1 | — |
| w_2 | FLOAT | 0.300–1 | — |
| h_2 | FLOAT | 1.000–1 | — |
| x_3 | FLOAT | 0.650–1 | — |
| y_3 | FLOAT | 0.000–1 | — |
| w_3 | FLOAT | 0.350–1 | — |
| h_3 | FLOAT | 1.000–1 | — |
| soft_edge | INT | 00–256 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask_1 | MASK | — |
| mask_2 | MASK | — |
| mask_3 | MASK | — |