DenseDiffusion Rect Apply (Nukun)
Rectangular regional prompts with DenseDiffusion, in one node
- model
- conditioning_1
- conditioning_2
- conditioning_3
- model
- conditioning
- mask_1
- mask_2
- mask_3
Regional prompting - giving different parts of the canvas different prompts - is the standing answer to two characters whose attributes bleed into each other. It works, but it's fiddly: to get it going with DenseDiffusion you'd normally wire up mask creation, then a DenseDiffusion "Add Cond" node per region, then the DenseDiffusion Apply node, keeping every mask and every strength straight. NukunDenseDiffusionRectApply collapses that whole chain into one node with a draggable rectangle editor.
It's the "freely placed rectangles" flavor. The sibling DenseDiffusionSplitApply does full-width/full-height splits; this one lets each region be its own rectangle anywhere on the canvas.
What it wraps
Under the hood it builds 2 or 3 rectangular masks from percentage coordinates, adds one DenseDiffusion region conditioning per mask, and runs the DenseDiffusion Apply - all internally. You give it:
model- your patched/unpatched base model.conditioning_1,conditioning_2(and optionalconditioning_3) - the per-region prompts, already CLIP-encoded.width/height- the canvas size.region_count- 2 or 3. At 2,conditioning_3is ignored.x_n/y_n/w_n/h_n- each region's rectangle in 0.0–1.0 image coordinates. The defaults tile three vertical bands, which is a fine place to start.soft_edge- blur the rectangle edges so region boundaries aren't hard cuts.strength_1..3- per-region influence.
Outputs: the patched model (into your sampler), the combined conditioning (into the positive path), and mask_1 through mask_3 so you can preview exactly what each region covers.
The draggable editor
The pack ships a browser-side rectangle editor that attaches to this node (and its split/rect siblings) - you drag the region rectangles directly on a canvas in the node UI instead of typing coordinates. That's the feature that makes this usable: you can see where region 2 ends before you burn a run.
The safety detail worth knowing
DenseDiffusion has a known failure mode: pixels not covered by any region can end up with empty attention and produce black or NaN images. This node handles that internally - uncovered pixels are assigned to all active region masks so every pixel has attention. That's the kind of gotcha that eats an hour when you wire DenseDiffusion by hand, and it's handled for you here.
Installing it - the one extra step
This node needs the actual DenseDiffusion package, which is not bundled:
cd ComfyUI/custom_nodes
git clone https://github.com/OnekoSL/Nukun_ComfyUI_Nodes.git
cd ComfyUI/custom_nodes
git clone https://github.com/huchenlei/ComfyUI_densediffusion.git
Restart ComfyUI (or use ComfyUI Manager for both - search "Nukun" and "densediffusion"). The import is lazy, so the rest of the Nukun pack works fine even without it; only these two DenseDiffusion nodes need the companion.
The honest take
This is the node to reach for when your regional layout is genuinely rectangular - a subject left, a companion right, a background band. If your regions are actually full-height or full-width strips, the Split variant is simpler. And if you don't need DenseDiffusion's model patching at all (it's the heavier hammer), the pack's Native Regional Rect Conditioning gives you core-only regional conditioning without the extra package. Rect-apply is the right tool when you want DenseDiffusion's per-region strength control with rectangles - and the editor makes placement painless.
Inputs (23)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| conditioning_1 | CONDITIONING | — | |
| conditioning_2 | CONDITIONING | — | |
| 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 | — |
| strength_1 | FLOAT | 1.000–2 | — |
| strength_2 | FLOAT | 1.000–2 | — |
| strength_3 | FLOAT | 1.000–2 | — |
| conditioning_3opt | CONDITIONING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| model | MODEL | — |
| conditioning | CONDITIONING | — |
| mask_1 | MASK | — |
| mask_2 | MASK | — |
| mask_3 | MASK | — |