Nodes/kubakub nodes/kubakub region plan
ComfyUI Node

kubakub region plan

One prompt per window, written as a text file, not forty nodes

By kubakubkub·Created about a month ago·Updated 2 days ago· 10
kubakub region plan
  • regions
  • image
  • plan
  • plan_json
  • report
  • preview
◄rules[plan] order = largest_first [default] prompt = weathered sandstone facade at night denoise = 0.55 [group:Windows] prompt = dark glass, faint reflections [W_F1_*] strategy = frame_in_frame prompt = an underwater room with {jellyfish|a sunken piano|koi} ►
◄seed0►
◄rules_file►

Regional prompting has been rebuilt for every architecture since 2023, and the reason is boring: prompt adherence is global, so if you want the windows to be one thing and the wall to be another, you need to attach a prompt to those pixels. The usual ComfyUI answer is a graph full of conditioning crops and masks. The kubakub answer is a text box.

kubakub region plan takes the regions output of any regions node and a chunk of rules text, and produces a plan: for every region, a prompt, a strategy, a denoise, a seed, a few other settings. Its plan output goes into kubakub region sampler and kubakub seam pass. That's it. You get per-object control over a whole facade from something you can paste into a file and diff.

The rule syntax, in eight lines

[plan]
order = largest_first

[default]
prompt = weathered sandstone palace facade at night
denoise = 0.55

[group:M_Pilasters]
prompt += carved vines climbing the stone

[W_F1_*]
strategy = frame_in_frame
prompt = an underwater room with {jellyfish|a sunken piano|koi}

[tag:M_FLOOR_F3 group:Windows]
prompt = candle lit attic room behind old glass

Selectors: default, a bare region name (wildcards * and ?), name:, group:, tag:, and region:<id> or region:3-7 for ranges. Case-insensitive. space between terms is AND, a comma is OR, ! is NOT. Priority runs region > name > group > tag > default, an AND of several terms beats a single term of the same kind, and among equals the later rule wins.

Two things make it pleasant rather than just powerful. Settings merge key by key, so the pilaster rule above appends a prompt and inherits the denoise - you can override exactly what you mean to override. And {a|b|c} picks one option per region from seed, which is how you get forty windows that are all underwater rooms and all slightly different, without writing forty rules.

prompt += text appends to the inherited prompt; plain = replaces it. The values you can set per region include strategy, denoise, steps, cfg, seed, order, context_px, dilate_px, feather_px, color_match, blend, reference, lora, region_mp and the frame-in-frame settings - see the pack's docs/generate.md for the table, and docs/rules_example.txt for a full starting point.

Strategy is the big fork

Three values, and they're genuinely different jobs:

  • inpaint (default) - repaint the region in place. Materials, weathering, vines, replacing a wall's surface.
  • frame_in_frame - generate an entirely new scene from scratch and place it through the region's mask. This is the "there's a room behind this window" mode, and the reason it's a separate strategy is that the model is not being asked to preserve anything.
  • keep - untouched. Worth using explicitly on the regions you don't want touched, because it also removes them from the work list.

The outputs, and why the report matters

plan goes to the sampler. plan_json is every region's resolved settings as text - the truth, after all your rule merging. And report is the one that pays for itself: a table of every region with its strategy, denoise and prompt, plus notes. Typos are caught by line number (line 7: unknown setting 'denoize'; did you mean 'denoise'?), and rules that matched nothing are listed. If a rule isn't doing anything, this is where you find out, and it's always because the region name doesn't match - a mask folder's names, a cryptomatte's real object names and an Illustrator layer's cell names have literally nothing in common.

preview is a nice touch: same colour = same strategy and prompt. Connect your matrix to the optional image input and it's a visual map of which regions are about to get the same treatment.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/kubakubkub/ComfyUI_KubaNodes
python -m pip install -r ComfyUI_KubaNodes/requirements.txt

Manager → kubakub nodes. ComfyUI 0.37.0+, OpenCV is the only package added. No models needed for this node itself - it's pure text processing, and tests/test_plan.py runs it with no model at all.

Notes from using it

rules_file is read-only and applied first. rules on the node is applied after it and can override everything. That's the right order: keep the stable rules in a .txt in the project folder, and use the node's text box for the two lines you're currently fiddling with.

The samplers need the image at the exact size of the regions. The image input here is for the preview only and gets scaled to fit - don't read that as permission elsewhere in the chain.

Categorykubakub/2d/generate

Inputs (5)

NameTypeDefaultDescription
regionsKUBA_REGIONSFrom kubakub regions from matrix / masks (regions output).
rulesSTRING[plan] order = largest_first [default] prompt = weathered sandstone facade at night denoise = 0.55 [group:Windows] prompt = dark glass, faint reflections [W_F1_*] strategy = frame_in_frame prompt = an underwater room with {jellyfish|a sunken piano|koi} The plan. See docs/generate.md (region plan) for all settings. Applied after rules_file, so it can override it.
seedINT00–18446744073709550000Plan seed: region seeds (seed + region id) and {a|b} choices.
rules_fileoptSTRINGOptional .txt with rules, e.g. kept in the project folder. Read only.
imageoptIMAGEBackground for the preview (the matrix). Another size than the regions is scaled to fit, for the preview only.

Outputs (4)

NameTypeDescription
planKUBA_PLANConnect to kubakub region sampler and seam pass.
plan_jsonSTRINGThe resolved settings of every region as text.
reportSTRINGA table of every region with its strategy, denoise and prompt, plus notes.
previewIMAGESame colour = same strategy and prompt.