aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/appearance/blinds.frag
blob: 49ee17bbc26cb50d2761d96408378b195cd1b5ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// Vertical slats turning edge-on in a wave from a random column, darkening as
// they turn, with the new wallpaper between them. Compiled with:
// qsb --qt6 -o blinds.frag.qsb blinds.frag
#version 440
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
    mat4 qt_Matrix;
    float qt_Opacity;
    float progress;
    vec2 origin;
};
layout(binding = 1) uniform sampler2D source;

void main() {
    const float n = 16.0;
    float slat = floor(qt_TexCoord0.x * n);
    float f = fract(qt_TexCoord0.x * n) - 0.5;

    float wave = abs((slat + 0.5) / n - origin.x) / max(origin.x, 1.0 - origin.x);
    float l = clamp((progress - 0.6 * min(wave, 1.0)) / 0.4, 0.0, 1.0);

    float half_ = 0.5 * cos(l * 1.5708);
    if (l >= 1.0 || abs(f) > half_) { fragColor = vec4(0.0); return; }

    vec2 uv = vec2((slat + 0.5 + f * 0.5 / half_) / n, qt_TexCoord0.y);
    fragColor = vec4(texture(source, uv).rgb * mix(1.0, 0.55, l), 1.0) * qt_Opacity;
}