From 69ae86f606cd95eeadcc976d03d07606d7cd1941 Mon Sep 17 00:00:00 2001 From: Simon Schneegans Date: Mon, 19 Dec 2022 20:14:17 +0100 Subject: [PATCH] :tada: Add more easing functions --- resources/shaders/common.glsl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/resources/shaders/common.glsl b/resources/shaders/common.glsl index 62a5d54..17f454f 100644 --- a/resources/shaders/common.glsl +++ b/resources/shaders/common.glsl @@ -143,8 +143,29 @@ vec3 tritone(float val, vec3 shadows, vec3 midtones, vec3 highlights) { // https://gitlab.gnome.org/GNOME/mutter/-/blob/main/clutter/clutter/clutter-easing.c float easeOutQuad(float x) { return -1.0 * x * (x - 2.0); } + float easeInQuad(float x) { return x * x; } +float easeInBack(float x) { return x * x * ((1.70158 + 1) * x - 1.70158); } + +float easeOutBack(float x) { + float p = x - 1; + return p * p * ((1.70158 + 1) * p + 1.70158) + 1; +} + +float easeInOutBack(float x) { + float p = x * 2.0; + float s = 1.70158 * 1.525; + + if (p < 1.0) { + return 0.5 * (p * p * ((s + 1) * p - s)); + } + + p -= 2; + + return 0.5 * (p * p * ((s + 1) * p + s) + 2); +} + // --------------------------------------------------------------------- edge mask helpers // This method returns a mask which smoothly transitions towards zero when approaching