Files
z-bar-qt/Plugins/ZShell/Wallpaper/shaders/wallpaper_trans_tiles_wave.frag
T
zach b0cb43f75c
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 11s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Failing after 32s
Rust / build (pull_request) Successful in 52s
Python / verify (pull_request) Failing after 1m23s
Rust / fmt (pull_request) Successful in 51s
Rust / clippy (pull_request) Successful in 1m2s
feat: add vaapi path for video wallpapers on generic gpus
2026-10-27 02:15:16 +01:00

90 lines
2.6 KiB
GLSL

// Tiles wave reveal, from gl-transitions.com
// Author: numb3r23 (MIT)
// Description: the incoming image is revealed tile by tile in a diagonal wave.
//
// Ported to ZShell's GLSL ABI (see wallpaper_trans_bowtie.frag).
// Optional gl-transitions params are fixed here: tileCount = (8, 8),
// flipX = true, flipY = false.
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 ivec2 tileCount = ivec2(8, 8);
const bool flipX = true;
const bool flipY = false;
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);
}
vec4 transition(vec2 uv) {
vec2 tileSize = 1.0 / vec2(tileCount);
vec2 posInTile = fract(uv * vec2(tileCount));
vec2 tileNum = floor(uv * vec2(tileCount));
float countTiles = float(tileCount.x * tileCount.y);
// Diagonal wave from bottom-left to top-right.
float offset = (tileNum.y + tileNum.x * float(tileCount.y)) / countTiles;
float timeOffset = clamp((progress - offset) * countTiles, 0.0, 0.5);
float sinTime = 1.0 - abs(cos(fract(timeOffset) * 3.1415926));
vec2 texC = posInTile;
if (sinTime <= 0.5) {
if (flipX) {
if (texC.x < sinTime || texC.x > 1.0 - sinTime)
return getFromColor(uv);
texC.x = texC.x < 0.5
? (texC.x - sinTime) * 0.5 / (0.5 - sinTime)
: (texC.x - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
}
if (flipY) {
if (texC.y < sinTime || texC.y > 1.0 - sinTime)
return getFromColor(uv);
texC.y = texC.y < 0.5
? (texC.y - sinTime) * 0.5 / (0.5 - sinTime)
: (texC.y - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
}
vec2 globalUV = tileNum * tileSize + texC * tileSize;
return getFromColor(globalUV);
} else {
if (flipX) {
if (texC.x > sinTime || texC.x < 1.0 - sinTime)
return getToColor(uv);
texC.x = texC.x < 0.5
? (texC.x - sinTime) * 0.5 / (0.5 - sinTime)
: (texC.x - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
texC.x = 1.0 - texC.x;
}
if (flipY) {
if (texC.y > sinTime || texC.y < 1.0 - sinTime)
return getToColor(uv);
texC.y = texC.y < 0.5
? (texC.y - sinTime) * 0.5 / (0.5 - sinTime)
: (texC.y - 0.5) * 0.5 / (0.5 - sinTime) + 0.5;
texC.y = 1.0 - texC.y;
}
vec2 globalUV = tileNum * tileSize + texC * tileSize;
return getToColor(globalUV);
}
}
void main() {
vec2 uv = gl_FragCoord.xy / size;
outColor = transition(uv);
}