Region Mask Generator
Draw up to three prompt regions for Flux spatial control
- colored_regions_image
- bbox_preview
- mask1
- mask2
- mask3
- number_of_regions
- bbox1
- bbox2
- bbox3
This is the front door to ControlAltAI's Flux Region pipeline - the pack's answer to regional prompting on Flux. If you've ever tried to describe two people in one prompt and watched their hair colors and outfits bleed into each other, that's the problem this whole chain solves: give the left half of the canvas one prompt and the right half another, and hold them apart. The Region Mask Generator is where you define those areas.
Regional prompting is a genuinely old, genuinely unsolved need - people have been reaching for it since the Latent Couple / Regional Prompter days on SD 1.5, and every new architecture breaks the old tools and needs a fresh implementation. Flux is no exception, and this pipeline is one of the purpose-built answers for it.
How it works
You set a canvas width and height, pick number_of_regions (1 to 3), and then define each region as a rectangle using normalized coordinates - region1_x1, region1_y1 for the top-left corner and region1_x2, region1_y2 for the bottom-right, each from 0 to 1. So the left half of the image is x1=0, x2=0.5; the right half is x1=0.5, x2=1. The defaults already carve the canvas into sensible splits, so you can start from those and nudge.
Out of that, the node produces both a mask and a bounding box for each region, which is exactly what the rest of the pipeline consumes downstream.
The inputs and outputs that matter
number_of_regions- 1, 2, or 3. This is the count everything downstream keys off, so set it deliberately.region{n}_x1/y1/x2/y2- the rectangle for each region, in 0-1 canvas fractions.
Outputs are a lot, but they pair up: mask1/mask2/mask3 (MASK), bbox1/bbox2/bbox3 (BBOX), a passthrough number_of_regions (INT), plus two preview images - colored_regions_image and bbox_preview - that let you see your layout before you commit. The masks and bboxes are what you actually wire forward.
The full chain, per the author, is: Region Mask Generator → Region Mask Processor → Region Mask Validator → Region Mask Conditioning → Flux Attention Control → (Region Overlay Visualizer, optional) → Flux Attention Cleanup. This node is step one; the Processor node it feeds handles the Gaussian blur and feathering.
How to install it
ComfyUI Manager → search ControlAltAI Nodes → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/gseth/ControlAltAI-Nodes
This node itself is plain Python, but be warned: the Flux Attention Control node further down this same pipeline requires XFormers matched to your PyTorch version. If you plan to run the full region chain, sort that out now (the repo ships an xformers_instructions.txt) rather than discovering it three nodes later.
Common issues
The author is blunt that this pipeline has a steep learning curve and that watching their video tutorial is basically mandatory - this isn't a plug-and-play node, it's the input stage of a multi-node system. Practically, the thing to get right here is region layout: overlapping rectangles cause validation warnings downstream (the Validator node flags overlap percentage), and while a little overlap is fine because feathering smooths it, excessive overlap past ~40-50% is where it breaks. Keep your regions mostly disjoint, and lean on the two preview outputs to check your boxes before you run a full generation.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 1024 | — |
| height | INT | 1024 | — |
| number_of_regions | INT | 11–3 | — |
| region1_x1 | FLOAT | 0.000–1 | — |
| region1_y1 | FLOAT | 0.000–1 | — |
| region1_x2 | FLOAT | 0.500–1 | — |
| region1_y2 | FLOAT | 0.500–1 | — |
| region2_x1 | FLOAT | 0.500–1 | — |
| region2_y1 | FLOAT | 0.000–1 | — |
| region2_x2 | FLOAT | 1.000–1 | — |
| region2_y2 | FLOAT | 0.500–1 | — |
| region3_x1 | FLOAT | 0.000–1 | — |
| region3_y1 | FLOAT | 0.500–1 | — |
| region3_x2 | FLOAT | 0.500–1 | — |
| region3_y2 | FLOAT | 1.000–1 | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| colored_regions_image | IMAGE | — |
| bbox_preview | IMAGE | — |
| mask1 | MASK | — |
| mask2 | MASK | — |
| mask3 | MASK | — |
| number_of_regions | INT | — |
| bbox1 | BBOX | — |
| bbox2 | BBOX | — |
| bbox3 | BBOX | — |