Nodes/ComfyUI-DAELab-Custom-Nodes-Library/Badge Local Edit Prompt Builder (DAELab)
ComfyUI Node

Badge Local Edit Prompt Builder (DAELab)

One node, four mutually exclusive kinds of edit

By TeutonicMepheles·Created 4 months ago·Updated 6 days ago· 0
Badge Local Edit Prompt Builder (DAELab)
    • prompt
    • apply_height_patch
    • target_layer_value
    • operation_summary
    ◄operation_type▾►
    ◄user_prompt►
    ◄target_color#c9a86a►
    ◄target_layer▾►
    ◄height_enabledtrue►
    ◄material_semantics—►

    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:

    • prompt drops your user_prompt in as free text, with a default of "Refine the selected content" and a standing instruction to preserve colour, material and height unless asked.
    • color replaces the selected object's intrinsic base colour with target_color, explicitly preserving material, texture, shape, relief and text.
    • material applies material_semantics to the selection using target_color as the intrinsic colour, preserving outline, dimensions, height, graphics and text.
    • height declares that the deterministic height reference already replaced the selection with target_layer, and asks the model to render only that absolute layer change. If height_enabled is false this raises Height 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 - with prompt and an empty user_prompt you're sending "Refine the selected content", which is exactly as vague as it sounds.
    • Height edit rejected. height_enabled is 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_color is 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_patch reads 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.
    CategoryDAELab/Badge/Prompt

    Inputs (6)

    NameTypeDefaultDescription
    operation_typeCOMBO4 options: prompt, color, material, height
    user_promptSTRING—
    target_colorSTRING#c9a86a—
    target_layerCOMBO6 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_enabledBOOLEANtrue—
    material_semanticsoptSTRING—

    Outputs (4)

    NameTypeDescription
    promptSTRING—
    apply_height_patchBOOLEAN—
    target_layer_valueBADGE_HEIGHT_LAYER—
    operation_summarySTRING—