Lerp Calculator

lerp(a, b, t), inverse lerp and color blending.

Formula

lerp(a, b, t) = a + (b − a) × t
invLerp(a, b, v) = (v − a) / (b − a)

Color lerp

Lerp in code

const lerp = (a, b, t) => a + (b - a) * t;
const invLerp = (a, b, v) => (v - a) / (b - a);

The form (1 − t)·a + t·b is numerically safer and returns exactly b at t = 1.

FAQ

What is inverse lerp?

Given a value between a and b, it returns t = (value − a)/(b − a).

How do I remap a value from one range to another?

Find t = invLerp(inMin, inMax, value), then compute lerp(outMin, outMax, t).

How does this map to Unity, Unreal and GLSL?

Mathf.Lerp (which clamps t to 0–1), FMath::Lerp and mix(a, b, t) all use the same formula.