From 880bbba4914f3675b92d3c9bf36123360e8a39ce Mon Sep 17 00:00:00 2001 From: lisyarus Date: Thu, 3 Sep 2026 12:14:54 +0300 Subject: [PATCH] Add 3-argument smoothstep and smootherstep --- libs/math/include/psemek/math/math.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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) {