Nodes/ComfyUI-latent-ops/LatentOperationAddBroadcast
ComfyUI Node

LatentOperationAddBroadcast

Nudge every latent value by a constant

By hnmr293·Created about a year ago·Updated about a year ago· 2
LatentOperationAddBroadcast
    • op
    value0.0000

    Adding a single number to every element of a latent is the latent-space equivalent of nudging exposure: it shifts the whole distribution up or down without touching the structure. LatentOperationAddBroadcast is that nudge, and it's the cheap, tunable cousin of LatentOperationAdd - instead of adding another latent (which you'd have to VAE-encode), you just type a number.

    It's from hnmr293's ComfyUI-latent-ops pack, and like every node in the pack with "Operation" in the name, it does not apply anything itself. It hands back a deferred recipe.

    How it works

    The value FLOAT you set is captured into a closure. When something finally applies the op to a latent, the closure returns latent + value, broadcast across every element - all channels, all positions. So a positive value lifts the latent's mean, a negative one sinks it. Because it's a plain scalar broadcast, it can't introduce shape problems the way latent-plus-latent can.

    The deferred-op trap

    Read this once and it applies to every LatentOperation* node in this pack: the op output is a LATENT_OPERATION - a Python callable that expects a latent and returns a transformed one - not a latent you can wire into VAE Decode. The pack ships no Apply node, so you need a consumer that accepts the LATENT_OPERATION type, or your own tiny apply node (op(latent["samples"])). Without one, the node does nothing visible.

    What matters

    • value - FLOAT, default 0, range -10000 to 10000 with a fine 0.0001 step. Start around ±0.1 and look, don't jump to ±1.
    • op - the only output. Deferred operation, not a result.

    Where it shines: offsetting the mean of a latent before you decode or re-sample it, subtle "lift" on img2img results, and as a building block in latent-math chains where you want to tune an offset live instead of re-encoding a latent every time.

    Installing it

    No deps, no models - ComfyUI Manager → search "ComfyUI-latent-ops" → install, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/hnmr293/ComfyUI-latent-ops
    

    Restart ComfyUI; the node lives under hnmr/latent_ops.

    Troubleshooting

    If you can't connect the op output anywhere, that's the missing Apply step, not a broken install. If the effect looks far too strong at value 1.0, remember SD-class latents have a small dynamic range - a constant of 1.0 is a big shove, and 0.1-0.3 is usually the meaningful zone. And if you genuinely need to add a latent, not a number, use LatentOperationAdd instead.

    Categoryhnmr/latent_ops

    Inputs (1)

    NameTypeDefaultDescription
    valueFLOAT0.0000-10000–10000

    Outputs (1)

    NameTypeDescription
    opLATENT_OPERATION