Nodes/ComfyUI-CustomNodePacks/Number Lerp (C2C)
ComfyUI Node

Number Lerp (C2C)

The smallest node in the pack, and the one you'll actually reuse

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Number Lerp (C2C)
    • float
    • int
    a0.0000
    b1.0000
    t0.500
    curvelinear

    Number Lerp (C2C) is three float inputs and a dropdown, and somehow it ends up in more of my workflows than half the "smart" nodes in this pack. It interpolates between two numbers with a choice of easing curve, and that's it. You'd think you could just type a number, but ComfyUI's canvas makes animating a value across a graph surprisingly fiddly - which is exactly what this solves.

    The whole mechanism

    The mechanism is trivial and transparent: a and b are the endpoints, t is the position between them, clamped to [0,1]. curve picks the easing - linear is the straight a + (b-a)*t, smoothstep applies t²(3−2t) for that gentle ease-in-out everyone reaches for, and cosine does (1−cos(t·π))/2, a slightly different ease that stays smoother at the ends. Two outputs: float (the exact interpolated value) and int (rounded), so you can drive both a precision float and a stepped integer from one computation. Nothing hidden, nothing loaded, no GPU involved.

    Where it earns its keep

    Where does it earn its keep? The killer use is wiring t to a number you're already animating - a frame counter, a KSampler step from a counter node, a slider you're dragging to preview. Drive t with time and suddenly a/b become your keyframe values: you can ease a denoise strength from 0.8 down to 0.2 across a video batch, or ramp a LoRA weight over a range, or crossfade a strength parameter for a multi-pass workflow. The int output is what makes it a poor man's animation controller - feed it into a node that wants an integer (steps, batch counts, iteration counts) and you get clean stepped easing instead of a raw ramp.

    Pairing and install

    Pair it with the pack's Parameter History node if you're tuning an animation and want to see what you changed between runs, or with a FrameRangeRouter for time-based switching. It's also a fine sanity-check node: when you're not sure whether a downstream node wants 0–1 or something else, slap a Number Lerp in front and set a/b to the range you need.

    Install is just the pack - clone Code2Collapse/ComfyUI-CustomNodePacks into ComfyUI/custom_nodes or search "CustomNodePacks" in ComfyUI Manager, restart, and it lives under C2C/Helpers. It's part of the same 12-node helper family as the image batch slice and split utilities, so if you're already running any C2C node you've got this one too.

    The one trap (which isn't)

    The one trap is really a non-trap: because t is clamped, you can't use it for extrapolation (values past b), and there's no looping or per-frame automatic evaluation - it interpolates per graph execution, so if you want frame-by-frame easing you need to feed it a frame-indexed t yourself. That's not a bug, it's the design: a small, composable, dead-predictable node you can build bigger things on. For a two-minute setup cost, it's the kind of utility you'll forget is "just" a lerp.

    CategoryC2C/Helpers

    Inputs (4)

    NameTypeDefaultDescription
    aFLOAT0.0000-1000000000–1000000000
    bFLOAT1.0000-1000000000–1000000000
    tFLOAT0.5000–1
    curveCOMBOlinear3 options: linear, smoothstep, cosine

    Outputs (2)

    NameTypeDescription
    floatFLOAT
    intINT