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
|
// 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.
// Both pictures pulled away from a random point by their own brightness,
// flowing into each other: the old one stretches as it leaves, the new one
// settles as it arrives. Opaque throughout. Compiled with:
// qsb --qt6 -o crosswarp.frag.qsb crosswarp.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;
layout(binding = 2) uniform sampler2D target;
float luma(vec3 c) { return dot(c, vec3(0.299, 0.587, 0.114)); }
void main() {
vec2 uv = qt_TexCoord0;
vec2 dir = uv - origin;
float x = smoothstep(0.0, 1.0, progress);
vec2 ua = uv + dir * luma(texture(source, uv).rgb) * x * 0.3;
vec2 ub = uv - dir * luma(texture(target, uv).rgb) * (1.0 - x) * 0.3;
fragColor = vec4(mix(texture(source, ua).rgb, texture(target, ub).rgb, x), 1.0) * qt_Opacity;
}
|