add arc raiders animation

This commit is contained in:
Schrottkatze 2026-01-30 02:38:54 +01:00
commit c91ed9d0b6
No known key found for this signature in database
3 changed files with 130 additions and 1 deletions

View file

@ -24,6 +24,7 @@
other = [
"include \"live.kdl\""
"output \"eDP-1\" { scale 1.1; }"
"animations { window-open { duration-ms 3000; curve \"linear\"; custom-shader r\"\n${builtins.readFile ./shaders/arc.frag}\";};}"
];
in
{

View file

@ -47,7 +47,6 @@ window-rule {
color "#bab9e5af"
inactive-color "#fa9d99af"
}
baba-is-float true
}
window-rule {

View file

@ -0,0 +1,129 @@
#define PI 3.14159
#define TAU 6.28319
#define WIDTH 3.
#define RADIUS 1.
#define WIPE_DURATION .2
#define BORDER_LOOPS 3.
#define FADE_ITS 2.
vec4 gradi(float pos, vec4 bg, vec4 fg, float fac, float mask) {
if (mask < 0.2) {
return bg;
}
vec4 trans = vec4(0.);
vec4 purple = vec4(0.45, 0.13, 0.49, 1.0) * vec4(mask);
vec4 blue = vec4(0.25, 0.74, 0.81, 1.0) * vec4(mask);
vec4 white = vec4(mask);
float mult = 4. * fac;
if (pos <= 0.125) {
return mix(bg, purple, max(0., pos * mult));
} else if (pos <= 0.25) {
return mix(purple, blue, (pos * mult) - 1.);
} else if (pos <= 0.5) {
return mix(blue, white, (pos * mult) - 2.);
} else {
return fg;
}
}
// from niri source code: https://github.com/YaLTeR/niri/blob/f30db163b5748e8cf95c05aba77d0d3736f40543/src/render_helpers/shaders/border.frag#L211-L234
float rounding_alpha(vec2 coords, vec2 size, vec4 corner_radius) {
vec2 center;
float radius;
if (coords.x < corner_radius.x && coords.y < corner_radius.x) {
radius = corner_radius.x;
center = vec2(radius, radius);
} else if (size.x - corner_radius.y < coords.x && coords.y < corner_radius.y) {
radius = corner_radius.y;
center = vec2(size.x - radius, radius);
} else if (size.x - corner_radius.z < coords.x && size.y - corner_radius.z < coords.y) {
radius = corner_radius.z;
center = vec2(size.x - radius, size.y - radius);
} else if (coords.x < corner_radius.w && size.y - corner_radius.w < coords.y) {
radius = corner_radius.w;
center = vec2(radius, size.y - radius);
} else {
return 1.0;//
}
float dist = distance(coords, center);
float half_px = 0.5;
return 1.0 - smoothstep(radius - half_px, radius + half_px, dist);
}
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
vec4 bg1 = vec4(.1, .1, .18, 1.0);
vec4 bg2 = vec4(.09, .05, .11, 1.0);
vec3 coords_tex = niri_geo_to_tex * coords_geo;
vec4 color = texture2D(niri_tex, coords_tex.st);
float pi = radians(180.);
if (0.0 <= coords_geo.x && coords_geo.x <= 1.0
&& 0.0 <= coords_geo.y && coords_geo.y <= 1.0)
{
float pos = (coords_tex.x - ((1. / WIPE_DURATION) * niri_clamped_progress) * 2.) + 1.;
vec2 coords = (coords_geo.xy - vec2(0.5, 0.5)) * size_geo.xy * 2.0;
vec2 coords_abs = coords_geo.xy * size_geo.xy;
float border_a = 1.;
border_a *= rounding_alpha(
coords_abs.xy,
size_geo.xy,
vec4(RADIUS + WIDTH)
);
vec4 bg = mix(bg1, bg2, length(coords_tex.xy - vec2(1., 0.))) * border_a;
color = gradi(pos, color, bg, 2.0, border_a);
float angle = (atan(coords.y, coords.x) + PI) / TAU;
float spinny_angle = mod((angle + niri_clamped_progress * BORDER_LOOPS), 1.0) / 2.;
vec2 border = WIDTH / size_geo.xy;
float temp = border_a;
float round_a = 1. - rounding_alpha(
coords_abs.xy - WIDTH,
size_geo.xy - WIDTH * 2.,
vec4(RADIUS)
);
if (coords_geo.x <= border.x || coords_geo.x >= (1. - border.x) ||
coords_geo.y <= border.y || coords_geo.y >= (1. - border.y)) {
border_a *= round_a;
}
float rest = 0.;
if (border_a + temp == 1.) {
rest = 1.;
}
border_a *= round_a;
border_a += rest;
vec4 grad = gradi(
spinny_angle,
vec4(.48, .37, .5, 1.),
vec4(1., 0., 0., 1.),
2.0, // DO NOT TOUCH
border_a
);
if ((1. - niri_clamped_progress) < FADE_ITS / BORDER_LOOPS) {
border_a *= (1. - niri_clamped_progress) / (FADE_ITS / BORDER_LOOPS);
}
color = mix(color, grad, border_a);
}
return color;
}