[added] mathx.bilerp which does a bilinear interpolation from 4 samples

This commit is contained in:
Max Cahill 2020-07-27 21:47:06 +10:00
parent 84197b5216
commit b4e2cff498

View File

@ -67,6 +67,15 @@ function mathx.lerp_eps(a, b, t, eps)
return v return v
end end
--bilinear interpolation between 4 samples
function mathx.bilerp(a, b, c, d, u, v)
return math.lerp(
math.lerp(a, b, u),
math.lerp(c, d, u),
v
)
end
--classic smoothstep --classic smoothstep
--(only "safe" for 0-1 range) --(only "safe" for 0-1 range)
function mathx.smoothstep(v) function mathx.smoothstep(v)