Regional Mask Prompt Encode
Regional conditioning from a color mask
- clip
- mask_image
- conditioning
- region_1_mask
- region_2_mask
- region_3_mask
- region_4_mask
- region_5_mask
- region_6_mask
- region_7_mask
- region_8_mask
- region_info
If you've ever generated two characters in one frame and watched their hair colors, jackets, and expressions swap places between generations, you know exactly why this node exists. A single prompt has to describe the whole canvas, and when that canvas holds two people the model smears their attributes together - that's the classic attribute-bleeding problem. Regional conditioning fixes it by giving each part of the image its own prompt, and this node is the paint-on-mask flavor of that idea: you paint each region a color, type a prompt per region, and it hands back conditioning ready for your sampler.
It's the ComfyUI sibling of the A1111 Regional Prompter's mask mode, but it skips BREAK parsing entirely. Instead of splitting the canvas into a grid, you literally paint the regions you want.
How it works
The pipeline is simple once you see it:
- You feed it a color mask image - a white canvas with each intended region painted a specific color.
- For each region it computes a deterministic palette color (the same HSV walk Regional Prompter's mask mode uses, pinned at 50% saturation/value).
- It compares every pixel to that target color.
mask_tolerancesets the color-distance radius for the match - it's a soft fuzzy match, not an exact-color check. - Each region's prompt is CLIP-encoded and attached to the conditioning as mask metadata - the same mechanism core
ConditioningSetMaskuses. The sampler does the rest.
That's the whole trick: per-region conditioning with a mask riding along, in a single node, instead of a pile of ConditioningSetArea + ConditioningSetMask spaghetti.
The inputs that matter
Four of these matter on a first run:
mask_image- your color mask, painted on white.base_prompt- shared tags: style, quality, common subjects.region_1_promptthroughregion_8_prompt- the per-region tags.mask_tolerance(default 48) - how close a pixel must be to the palette color to count as "in" the region. If your imported mask colors aren't being detected, raise this.
The ones you'll touch later: mask_feather (default 3) blurs mask edges so boundaries don't look harsh, region_strength and base_strength (default 1, range 0–10) control how strongly each part conditions, min_mask_alpha (0.05) drops stray noise pixels below a threshold, and set_cond_area toggles between the default conditioning area and "mask bounds". region_count (default 4, max 8) just tells it how many regions you painted - empty prompts and regions with zero coverage are skipped automatically.
Outputs
conditioning goes straight into your sampler's positive input; keep your normal negative path separate. The region_1_mask–region_8_mask outputs are great for previewing what the node thinks it found, and region_info is a text readout of each region's coverage and whether it has a prompt - your first stop when a region silently disappears.
Install
ComfyUI Manager, searching for "ComfyUI-Regional-Mask-Prompt", or the manual way:
cd ComfyUI/custom_nodes
git clone https://github.com/dr1610/ComfyUI-Regional-Mask-Prompt.git
Restart ComfyUI. That's the whole install - no requirements to pip, no model downloads, no API keys. It's pure torch.
Gotchas worth knowing
The big one: use the exact palette colors. Grab them from the RegionalMaskPromptPalette node before you open your paint program. Paint "your favorite red" instead of the region-1 red and the tolerance match comes back empty or fuzzy, and you'll chase it in the region_info readout instead of your first render.
Set expectations too. This is regional prompt guidance, not inpainting - it's great for rough person/area separation, clothing, hair color, large objects, and scene zones. Exact poses or small body parts still need ControlNet or a proper inpaint pass. The README also suggests keeping region prompts short and compatible with the base prompt on SDXL/Illustrious models. And remember the eternal regional-conditioning trade-off: strong masks can leave a collaged look with visible seams, so if that happens, feather harder or drop region_strength a little and let the base conditioning blend regions together.
One honest word on the pack itself: it's early days. Single commit, MIT-licensed, no real community footprint yet. The code is clean and readable, but treat it as an experiment - preview those mask outputs before you trust a batch of fifty images to them.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| clip | CLIP | — | |
| mask_image | IMAGE | — | |
| base_prompt | STRING | — | |
| region_1_prompt | STRING | — | |
| region_2_prompt | STRING | — | |
| region_3_prompt | STRING | — | |
| region_4_prompt | STRING | — | |
| region_count | INT | 41–8 | — |
| region_strength | FLOAT | 1.000–10 | — |
| base_strength | FLOAT | 1.000–10 | — |
| mask_tolerance | INT | 480–255 | — |
| mask_feather | INT | 30–64 | — |
| min_mask_alpha | FLOAT | 0.050–1 | — |
| set_cond_area | COMBO | default | 2 options: default, mask bounds |
| region_5_promptopt | STRING | — | |
| region_6_promptopt | STRING | — | |
| region_7_promptopt | STRING | — | |
| region_8_promptopt | STRING | — |
Outputs (10)
| Name | Type | Description |
|---|---|---|
| conditioning | CONDITIONING | — |
| region_1_mask | MASK | — |
| region_2_mask | MASK | — |
| region_3_mask | MASK | — |
| region_4_mask | MASK | — |
| region_5_mask | MASK | — |
| region_6_mask | MASK | — |
| region_7_mask | MASK | — |
| region_8_mask | MASK | — |
| region_info | STRING | — |