From d823adda57baffeb0e693e96721e3b3b3f45c1d5 Mon Sep 17 00:00:00 2001 From: Solar Punch Games <115359724+SolarPunchGames@users.noreply.github.com> Date: Sun, 1 Mar 2026 08:48:38 +0200 Subject: [PATCH 1/2] Added option to choose start corner for open animation --- animations/swipe-window.kdl | 87 ++++++++++++++++++++++--------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/animations/swipe-window.kdl b/animations/swipe-window.kdl index 7b09ab3..c8a1947 100644 --- a/animations/swipe-window.kdl +++ b/animations/swipe-window.kdl @@ -4,44 +4,59 @@ animations { workspace-switch { spring damping-ratio=0.80 stiffness=523 epsilon=0.0001 } -window-open { - duration-ms 1400 - curve "ease-out-expo" - custom-shader r" - float ease_curve(float x) { - return x < 0.5 ? 4.0*x*x*x : 1.0 - pow(-2.0*x + 2.0, 3.0)/2.0; - } - - vec4 open_color(vec3 coords_geo, vec3 size_geo) { - float t = niri_clamped_progress; - float prog = ease_curve(t); - - // bottom-right corner - vec2 start = vec2(1.0, 1.0); - - // compute distance along diagonal from corner - vec2 p = coords_geo.xy; - vec2 dir = vec2(-1.0, -1.0); // vector toward top-left - float dist = dot(p - start, dir); - - // normalize distance to max diagonal (from corner to opposite) - float max_diag = 2.0; - float norm_dist = dist / max_diag; - - // pixels not yet reached by sweep are invisible - if (norm_dist > prog) { - return vec4(0.0); - } - - // sample normally - vec3 coords_tex = niri_geo_to_tex * coords_geo; - vec4 col = texture2D(niri_tex, coords_tex.xy); + window-open { + duration-ms 1400 + curve "ease-out-expo" + custom-shader r" + float ease_curve(float x) { + return x < 0.5 ? 4.0*x*x*x : 1.0 - pow(-2.0*x + 2.0, 3.0)/2.0; + } - return col; - }" -} + vec4 open_color(vec3 coords_geo, vec3 size_geo) { + float t = niri_clamped_progress; + float prog = ease_curve(t); + + // choose corner: 0=top-left,1=top-right,2=bottom-left,3=bottom-right + + int corner = 3; + vec2 start; + vec2 dir; + if (corner == 0) { + start = vec2(0.0,0.0); + dir = vec2(1.0,1.0); + } else if (corner == 1) { + start = vec2(1.0,0.0); + dir = vec2(-1.0,1.0); + } else if (corner == 2) { + start = vec2(0.0,1.0); + dir = vec2(1.0,-1.0); + } else { + start = vec2(1.0,1.0); + dir = vec2(-1.0,-1.0); + } + + // compute distance along diagonal from corner + vec2 p = coords_geo.xy; + float dist = dot(p - start, dir); + + // normalize distance to max diagonal (from corner to opposite) + float max_diag = 2.0; + float norm_dist = dist / max_diag; + + // pixels not yet reached by sweep are invisible + if (norm_dist > prog) { + return vec4(0.0); + } + + // sample normally + vec3 coords_tex = niri_geo_to_tex * coords_geo; + vec4 col = texture2D(niri_tex, coords_tex.xy); + + return col; + } + " + } - window-close { duration-ms 1400 curve "ease-out-expo" From 5916cab2ca5ffe682c5ef3e91d87f70adfee157f Mon Sep 17 00:00:00 2001 From: Solar Punch Games <115359724+SolarPunchGames@users.noreply.github.com> Date: Sun, 1 Mar 2026 08:50:39 +0200 Subject: [PATCH 2/2] Made option to choose close animation start corner actually work. Added tweak to fix animation stopping before shadows. --- animations/swipe-window.kdl | 80 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/animations/swipe-window.kdl b/animations/swipe-window.kdl index c8a1947..997fa16 100644 --- a/animations/swipe-window.kdl +++ b/animations/swipe-window.kdl @@ -58,55 +58,67 @@ animations { } window-close { - duration-ms 1400 - curve "ease-out-expo" - custom-shader r" - // ease-in-out cubic curve helper - float ease_curve(float x) { - return x < 0.5 ? 4.0*x*x*x : 1.0 - pow(-2.0*x + 2.0, 3.0)/2.0; - } + duration-ms 1400 + curve "ease-out-expo" + custom-shader r" + // ease-in-out cubic curve helper + float ease_curve(float x) { + return x < 0.5 ? 4.0*x*x*x : 1.0 - pow(-2.0*x + 2.0, 3.0)/2.0; + } - vec4 close_color(vec3 coords_geo, vec3 size_geo) { - float t = niri_clamped_progress; + vec4 close_color(vec3 coords_geo, vec3 size_geo) { + float t = niri_clamped_progress; - float prog = ease_curve(t); + float prog = ease_curve(t); - // choose corner: 0=top-left,1=top-right,2=bottom-left,3=bottom-right + // choose corner: 0=top-left,1=top-right,2=bottom-left,3=bottom-right - int corner = 0; - vec2 start; - if (corner == 0) start = vec2(0.0,0.0); - else if (corner == 1) start = vec2(1.0,0.0); - else if (corner == 2) start = vec2(0.0,1.0); - else start = vec2(1.0,1.0); + int corner = 0; + vec2 start; + vec2 dir; + if (corner == 0) { + start = vec2(0.0,0.0); + dir = vec2(1.0,1.0); + } else if (corner == 1) { + start = vec2(1.0,0.0); + dir = vec2(-1.0,1.0); + } else if (corner == 2) { + start = vec2(0.0,1.0); + dir = vec2(1.0,-1.0); + } else { + start = vec2(1.0,1.0); + dir = vec2(-1.0,-1.0); + } + float shadow_fix = 0.01; // otherwise the animation may stop before + // it hides the shadow, since it's outside the window bounds - // compute distance along diagonal from corner + // compute distance along diagonal from corner - vec2 p = coords_geo.xy; - float dist = dot(p - start, vec2(1.0,1.0)); + vec2 p = coords_geo.xy; + float dist = dot(p - start, dir) - shadow_fix; - // normalize distance to max diagonal - float max_diag = 2.0; // max of vec2(1,1) - float norm_dist = dist / max_diag; + // normalize distance to max diagonal + float max_diag = 2.0; // max of vec2(1,1) + float norm_dist = dist / max_diag; - // If pixel is behind the sweeping line, make it invisible + // If pixel is behind the sweeping line, make it invisible - if (norm_dist <= prog) { - return vec4(0.0); - } + if (norm_dist <= prog) { + return vec4(0.0); + } - // sample normally - vec3 coords_tex = niri_geo_to_tex * coords_geo; - vec4 col = texture2D(niri_tex, coords_tex.xy); + // sample normally + vec3 coords_tex = niri_geo_to_tex * coords_geo; + vec4 col = texture2D(niri_tex, coords_tex.xy); - return col; - }" -} + return col; + } + " + } - horizontal-view-movement { spring damping-ratio=0.85 stiffness=423 epsilon=0.0001 }