diff --git a/libs/math/include/psemek/math/math.hpp b/libs/math/include/psemek/math/math.hpp index a84b7871..f734b6c4 100644 --- a/libs/math/include/psemek/math/math.hpp +++ b/libs/math/include/psemek/math/math.hpp @@ -230,6 +230,12 @@ namespace psemek::math return x * x * (T{3} - T{2} * x); } + template + T smoothstep(T edge0, T edge1, T x) + { + return smoothstep(clamp((x - edge0) / (edge1 - edge0), T{0}, T{1})); + } + template T smootherstep(T x) { @@ -237,6 +243,12 @@ namespace psemek::math return x * x2 * (T{10} - x * T{15} + x2 * T{6}); } + template + T smootherstep(T edge0, T edge1, T x) + { + return smootherstep(clamp((x - edge0) / (edge1 - edge0), T{0}, T{1})); + } + template T inverse_smoothstep(T x) {