// Copyright (C) 2026 Danilo M. // // 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. // The old wallpaper dissolving like ink in water: a soft edge through noise // warped by more noise, the picture smearing as it goes. Compiled with: // qsb --qt6 -o ink.frag.qsb ink.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; float aspect; }; layout(binding = 1) uniform sampler2D source; float hash(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453); } float noise(vec2 p) { vec2 i = floor(p), f = fract(p); vec2 u = f * f * (3.0 - 2.0 * f); return mix(mix(hash(i), hash(i + vec2(1, 0)), u.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), u.x), u.y); } float fbm(vec2 p) { float v = 0.0, a = 0.5; for (int i = 0; i < 5; i++) { v += a * noise(p); p *= 2.03; a *= 0.5; } return v; } void main() { vec2 p = qt_TexCoord0 * vec2(aspect, 1.0); vec2 warp = vec2(fbm(p * 3.0 + progress), fbm(p * 3.0 + 7.3 - progress)); // fbm sits around 0.2 to 0.8; stretched and clamped, so the edge below // sweeps past every pixel. float t = clamp((fbm(p * 2.0 + warp * 1.5) - 0.2) / 0.6, 0.0, 1.0); const float w = 0.15; float a = smoothstep(0.0, w, t - mix(-w, 1.0, progress)); vec2 uv = qt_TexCoord0 + (warp - 0.5) * 0.04 * (1.0 - a); fragColor = vec4(texture(source, uv).rgb * a, a) * qt_Opacity; }