Nodes/ComfyUI-Regional-Mask-Prompt/Regional Mask Prompt Encode
ComfyUI Node

Regional Mask Prompt Encode

Regional conditioning from a color mask

By dr1610·Created 2 months ago·Updated 2 months ago· 0
Regional Mask Prompt Encode
  • 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
base_prompt
region_1_prompt
region_2_prompt
region_3_prompt
region_4_prompt
region_count4
region_strength1.00
base_strength1.00
mask_tolerance48
mask_feather3
min_mask_alpha0.05
set_cond_areadefault
region_5_prompt
region_6_prompt
region_7_prompt
region_8_prompt

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:

  1. You feed it a color mask image - a white canvas with each intended region painted a specific color.
  2. For each region it computes a deterministic palette color (the same HSV walk Regional Prompter's mask mode uses, pinned at 50% saturation/value).
  3. It compares every pixel to that target color. mask_tolerance sets the color-distance radius for the match - it's a soft fuzzy match, not an exact-color check.
  4. Each region's prompt is CLIP-encoded and attached to the conditioning as mask metadata - the same mechanism core ConditioningSetMask uses. 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_prompt through region_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_maskregion_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.

Categoryconditioning/regional

Inputs (18)

NameTypeDefaultDescription
clipCLIP
mask_imageIMAGE
base_promptSTRING
region_1_promptSTRING
region_2_promptSTRING
region_3_promptSTRING
region_4_promptSTRING
region_countINT41–8
region_strengthFLOAT1.000–10
base_strengthFLOAT1.000–10
mask_toleranceINT480–255
mask_featherINT30–64
min_mask_alphaFLOAT0.050–1
set_cond_areaCOMBOdefault2 options: default, mask bounds
region_5_promptoptSTRING
region_6_promptoptSTRING
region_7_promptoptSTRING
region_8_promptoptSTRING

Outputs (10)

NameTypeDescription
conditioningCONDITIONING
region_1_maskMASK
region_2_maskMASK
region_3_maskMASK
region_4_maskMASK
region_5_maskMASK
region_6_maskMASK
region_7_maskMASK
region_8_maskMASK
region_infoSTRING