ComfyUI Node

Simple LERP

Remap any number to any range without a calculator

By baslack·Created 3 months ago·Updated 3 months ago· 0
Simple LERP
    • value
    value0.00
    in_min0.00
    in_max1.00
    out_min0.00
    out_max1.00
    clampfalse

    Every ComfyUI workflow eventually hits the same wall: the widget you have outputs a number in one range, and the node you're feeding needs a number in another. Your AnimateDiff-style schedule spits out a 0–1 strength, but the KSampler wants denoise on a 0–1.4 scale, or your ControlNet strength slider tops out at 10 and the conditioning node expects 0–1. Core ComfyUI gives you plenty of math operators and Primitive widgets, but no one-liner for "map this number from one range to another." That's exactly what Simple LERP is: a tiny scaler that takes a value in, translates it from an input range onto an output range, and hands you the result. Nothing more.

    The math is the boring, dependable kind of interpolation. For your inputs it computes t = (value - in_min) / (in_max - in_min), then output = out_min + t * (out_max - out_min). If that looks like a high-school algebra problem, good - that's the whole node. It's in the math category in the node browser, displays as Simple LERP, and lives in the baslack/comfyui-lerp-node pack.

    The inputs that matter

    Six inputs, but you only really set three of them most of the time:

    • value - the number you're mapping. Wire it to whatever widget or output feeds you.
    • in_min / in_max - the range your value actually lives in. If your source gives you 0–1, set these to 0 and 1.
    • out_min / out_max - the range you want out. Feeding the result into a KSampler denoise at 0–1.4? That's your out range.
    • clamp - a boolean. Off by default. With it off, values outside the input range extrapolate past the output range, which is sometimes exactly what you want for easing curves and sometimes a silent bug. Flip it on and the result gets pinned inside the output range.

    It handles the gotchas you'd expect: inverted output ranges (say, out_min 1.0 and out_max 0.0, for a reversed strength curve) work fine, and if in_min == in_max it returns out_min instead of exploding into a division-by-zero NaN. That last one is worth knowing because a lot of value nodes just crash there.

    Output

    One output, named value, type FLOAT. Wire it into whatever downstream widget accepts a float - KSampler denoise, conditioning strengths, an img2img blend, a custom scheduling chain. Because it's pure scalar-to-scalar, it slots into almost any graph.

    Installing it

    This is one of the friendliest installs you'll find, because there's nothing else to it. The pack has no requirements.txt, downloads no models, and imports nothing but Python's standard library - the whole thing is one node.py file. Via ComfyUI Manager, search for comfyui-lerp-node and hit install. Or, if you're command-line inclined:

    cd ComfyUI/custom_nodes
    git clone https://github.com/baslack/comfyui-lerp-node
    

    Then restart ComfyUI. There's no heavy dependency to babysit, which is refreshing in an ecosystem where most installs are an exercise in dependency whack-a-mole.

    Honest troubleshooting

    The honest truth is there's not much to break here. The two things people actually hit: forgetting clamp is off and watching values drift past the range they expected (if a denoise value quietly exceeds 1.0, that's your culprit), and feeding it an INT where it wants a FLOAT - it expects float inputs, so wire a Primitive float or an output that's typed FLOAT, not an integer widget. Also be aware this is a brand-new, single-commit pack from one author, so it's not battle-tested the way a WAS Node Suite utility is - read the code if you're the paranoid type; at ~60 lines there's not much to hide. For a node this small, that's not a risk, it's a feature.

    It won't change your life. But the next time you're staring at a slider that outputs 0–100 and a node that demands 0–1, you'll be glad it's installed.

    Categorymath

    Inputs (6)

    NameTypeDefaultDescription
    valueFLOAT0.00-1000000000–1000000000
    in_minFLOAT0.00-1000000000–1000000000
    in_maxFLOAT1.00-1000000000–1000000000
    out_minFLOAT0.00-1000000000–1000000000
    out_maxFLOAT1.00-1000000000–1000000000
    clampBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    valueFLOAT