Badge Local Edit Prompt Builder (DAELab)
One node, four mutually exclusive kinds of edit
- prompt
- apply_height_patch
- target_layer_value
- operation_summary
What it is and why you'd reach for it
The single most common way a masked edit goes wrong is prompt bleed. You ask for a colour change on one field and the model also re-renders the gloss, nudges the type, and slightly re-carves the border - because your prompt described what you wanted, not what you forbade. This node's approach is to make the operation type a dropdown rather than a paragraph, so the forbidden list is generated for you.
There are exactly four operations: prompt, color, material, height. Pick one, and you get a prompt that states the shared invariants and then one narrow instruction for that operation only. It also emits the branch flag and the layer value the deterministic side of the graph needs, so one widget choice drives both the generative call and the mask/height maths. That's the nicest idea in the node.
How it works
Every output starts with the same common block, and it's a good one: Image 1 is the current registered front-view master and the only image being edited; Image 2 is the normalized flat design as the authority for graphics, colours, visible text and layout; Image 3, when present, is a grayscale height reference that never defines colour or material. Then: edit only the white-masked region, keep camera, perspective, framing, position, size, outline, text and typography, and don't expand the boundary or add a background, lighting, depth of field or decoration.
The operation-specific paragraph is where the four paths diverge:
promptdrops youruser_promptin as free text, with a default of "Refine the selected content" and a standing instruction to preserve colour, material and height unless asked.colorreplaces the selected object's intrinsic base colour withtarget_color, explicitly preserving material, texture, shape, relief and text.materialappliesmaterial_semanticsto the selection usingtarget_coloras the intrinsic colour, preserving outline, dimensions, height, graphics and text.heightdeclares that the deterministic height reference already replaced the selection withtarget_layer, and asks the model to render only that absolute layer change. Ifheight_enabledis false this raisesHeight editing requires the height branch to be enabled.
target_layer is a six-value enum - Cut Out (0.0) through Layer 5 (1.0) - and it goes out as a typed BADGE_HEIGHT_LAYER value, which is the same type Badge Height Patch wants. So the layer you told the prompt about is mechanically the layer the patcher writes. No chance of drift between what you said and what the mask does.
Inputs and outputs that matter
operation_type is the switch. user_prompt only matters on the prompt path (it's ignored by the other three, though it sits there looking important). target_color is a hex string, default #c9a86a - a warm gold, obviously chosen by someone rendering badges. target_layer plus height_enabled control the height path. material_semantics is optional and only consumed on material.
Outputs: prompt into the GPT node. apply_height_patch is a boolean that is true only for the height operation - wire it to the patcher's apply_patch and non-height edits pass the height map through untouched. target_layer_value into the patcher's target_layer. operation_summary is a JSON line with operation, colour and layer, which is the thing you paste into a report when a client asks what changed.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library
Restart. Manager by pack title also works. The badge module imports OpenCV, which the pack's requirements.txt doesn't declare (pip install opencv-python-headless if the node is missing). Text output only, so nothing else is required.
Common issues
- The edit didn't happen. Check
operation_type- withpromptand an emptyuser_promptyou're sending "Refine the selected content", which is exactly as vague as it sounds. - Height edit rejected.
height_enabledis false. The flag exists so you can't ask for a height change in a graph that has no height branch. - The colour came out as a plausible-but-not-my-gold.
target_coloris a hex string and gets injected verbatim; the model still approximates. This prompt preserves material, so a glossy surface will lighten your hex considerably - expect to iterate once. apply_height_patchreads false on a height edit - impossible in the current source, but if you see it, you're looking at a stale frontend cache. Restart ComfyUI; this pack's scripts are version-queried and cached aggressively.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| operation_type | COMBO | 4 options: prompt, color, material, height | |
| user_prompt | STRING | — | |
| target_color | STRING | #c9a86a | — |
| target_layer | COMBO | 6 options: Cut Out (0.0), Layer 1 (0.2), Layer 2 (0.4), Layer 3 (0.6), Layer 4 (0.8), Layer 5 (1.0) | |
| height_enabled | BOOLEAN | true | — |
| material_semanticsopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| prompt | STRING | — |
| apply_height_patch | BOOLEAN | — |
| target_layer_value | BADGE_HEIGHT_LAYER | — |
| operation_summary | STRING | — |