From 8f5547acc938795555ed86219c0175d38b7f0dba Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Wed, 16 Apr 2025 12:57:21 +0200 Subject: [PATCH] animation fuckery --- flake.nix | 1 + .../home/niri/shaders/glitch-open.frag | 39 +++++++++++++++++++ modules/desktop/home/niri/style.nix | 6 +++ 3 files changed, 46 insertions(+) create mode 100644 modules/desktop/home/niri/shaders/glitch-open.frag diff --git a/flake.nix b/flake.nix index 1dd871f..c9ca4dd 100644 --- a/flake.nix +++ b/flake.nix @@ -65,6 +65,7 @@ buildInputs = [ rs-toolchain pkgs.pkg-config + pkgs.glsl_analyzer pkgs.openssl ]; }; diff --git a/modules/desktop/home/niri/shaders/glitch-open.frag b/modules/desktop/home/niri/shaders/glitch-open.frag new file mode 100644 index 0000000..4682dd1 --- /dev/null +++ b/modules/desktop/home/niri/shaders/glitch-open.frag @@ -0,0 +1,39 @@ +float random(vec2 st) { + return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); +} + +float grid(vec2 c) { + if (mod((c.s * 512.) + random(c * niri_clamped_progress), 8.) >= 7.|| mod((c.t * 512.) + random(c * niri_clamped_progress), 8.) >= 7.) return 0.; + else return 1.; +} + +vec3 grid_colored(vec2 coords, vec3 col1, vec3 col2) { + return mix(col1, col2, grid(coords)); +} + +vec4 gen_px_squares(vec2 coords, vec4 color) { + vec2 coords_ = coords.xy; + coords = ceil(coords * 32.) / 32.; + float p = niri_clamped_progress; + + float mix_alpha = + 1. - clamp((p - length(coords)) * 3.0, 0.0, 1.0); + // vec4 blue = vec4(0.3568, 0.8078, 0.9803, color.a); + vec3 blue = vec3(0.552, 0.631, 1.); + vec3 dblue = vec3(0.419, 0.482, 0.839); + + if (color.a != 0. && p * p >= dot(coords, coords)) + return mix(color, vec4(grid_colored(coords_, dblue, blue), color.a), mix_alpha * 0.5); + else return vec4(0.); +} + +vec4 open_color(vec3 coords_geo, vec3 size_geo) { + vec3 coords_tex = niri_geo_to_tex * coords_geo; + vec4 color = texture2D(niri_tex, coords_tex.st); + + vec2 coords = (coords_geo.xy - vec2(0.5, 0.5)) * size_geo.xy * 2.0; + coords = coords / length(size_geo.xy); + + return gen_px_squares(coords, color); + // return vec4(vec3(grid(coords)),1.); +} diff --git a/modules/desktop/home/niri/style.nix b/modules/desktop/home/niri/style.nix index 2cee326..93731f0 100644 --- a/modules/desktop/home/niri/style.nix +++ b/modules/desktop/home/niri/style.nix @@ -10,6 +10,12 @@ hide-after-inactive-ms = 10000; }; + animations.window-open.easing = { + curve = "linear"; + duration-ms = 350; + }; + animations.shaders.window-open = builtins.readFile ./shaders/glitch-open.frag; + layout = { gaps = 15; focus-ring.enable = false;