Files
z-bar-qt/Plugins/ZShell/Internal/shaders/wallpaper_trans_doom_melt.frag
T
zach e655ec5bc7
C++ / fmt (pull_request) Failing after 5s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 28s
Python / verify (pull_request) Failing after 1m29s
Rust / build (pull_request) Successful in 53s
Rust / fmt (pull_request) Successful in 42s
Rust / clippy (pull_request) Successful in 1m4s
feat: add wallpaper transitions, store crop in database per-wallpaper, move CUDA context creation to async thread
2026-10-26 14:47:47 +01:00

73 lines
1.8 KiB
GLSL

// Doom-style melt wipe, from gl-transitions.com
// Author: Zeh Fernando (MIT)
// Description: the outgoing image melts down in uneven columns, like the Doom
// screen wipe. Fully procedural (no displacement texture).
//
// Ported to ZShell's GLSL ABI (see wallpaper_trans_bowtie.frag). Optional
// gl-transitions params are fixed here: bars = 30, amplitude = 2.0,
// noise = 0.1, frequency = 0.5, dripScale = 0.5.
uniform sampler2D from;
uniform sampler2D to;
uniform vec2 size;
uniform vec4 fromCrop;
uniform vec4 toCrop;
uniform float progress;
uniform float fromFlip;
uniform float toFlip;
out vec4 outColor;
const int bars = 30;
const float amplitude = 2.0;
const float noise = 0.1;
const float frequency = 0.5;
const float dripScale = 0.5;
vec4 getFromColor(vec2 uv) {
vec2 s = vec2(uv.x, fromFlip > 0.5 ? 1.0 - uv.y : uv.y);
return texture(from, fromCrop.xy + s * fromCrop.zw);
}
vec4 getToColor(vec2 uv) {
vec2 s = vec2(uv.x, toFlip > 0.5 ? 1.0 - uv.y : uv.y);
return texture(to, toCrop.xy + s * toCrop.zw);
}
float rand(int num) {
return fract(mod(float(num) * 67123.313, 12.0) * sin(float(num) * 10.3) *
cos(float(num)));
}
float wave(int num) {
float fn = float(num) * frequency * 0.1 * float(bars);
return cos(fn * 0.5) * cos(fn * 0.13) * sin((fn + 10.0) * 0.3) / 2.0 + 0.5;
}
float drip(int num) {
return sin(float(num) / float(bars - 1) * 3.141592) * dripScale;
}
float pos(int num) {
return (noise == 0.0 ? wave(num)
: mix(wave(num), rand(num), noise)) +
(dripScale == 0.0 ? 0.0 : drip(num));
}
vec4 transition(vec2 uv) {
int bar = int(uv.x * float(bars));
float scale = 1.0 + pos(bar) * amplitude;
float phase = progress * scale;
float posY = uv.y;
if (phase + posY < 1.0) {
return getFromColor(vec2(uv.x, uv.y + phase));
}
return getToColor(uv);
}
void main() {
vec2 uv = gl_FragCoord.xy / size;
outColor = transition(uv);
}