Wallpaper: shaders improvements with more parameters and new Stripes shader
This commit is contained in:
parent
d36bcb1d4d
commit
477d38d928
12 changed files with 260 additions and 66 deletions
|
|
@ -1,3 +1,5 @@
|
|||
|
||||
// ===== wp_wipe.frag =====
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 qt_TexCoord0;
|
||||
|
|
@ -11,7 +13,7 @@ layout(std140, binding = 0) uniform buf {
|
|||
float qt_Opacity;
|
||||
float progress; // Transition progress (0.0 to 1.0)
|
||||
float direction; // 0=left, 1=right, 2=up, 3=down
|
||||
float smoothness; // Edge smoothness (0.01 to 0.5, default 0.05)
|
||||
float smoothness; // Edge smoothness (0.0 to 1.0, 0=sharp, 1=very smooth)
|
||||
} ubuf;
|
||||
|
||||
void main() {
|
||||
|
|
@ -19,37 +21,41 @@ void main() {
|
|||
vec4 color1 = texture(source1, uv); // Current (old) wallpaper
|
||||
vec4 color2 = texture(source2, uv); // Next (new) wallpaper
|
||||
|
||||
// Map smoothness from 0.0-1.0 to 0.001-0.5 range
|
||||
// Using a non-linear mapping for better control
|
||||
float mappedSmoothness = mix(0.001, 0.5, ubuf.smoothness * ubuf.smoothness);
|
||||
|
||||
float edge = 0.0;
|
||||
float factor = 0.0;
|
||||
|
||||
// Extend the progress range to account for smoothness
|
||||
// This ensures the transition completes fully at the edges
|
||||
float extendedProgress = ubuf.progress * (1.0 + 2.0 * ubuf.smoothness) - ubuf.smoothness;
|
||||
float extendedProgress = ubuf.progress * (1.0 + 2.0 * mappedSmoothness) - mappedSmoothness;
|
||||
|
||||
// Calculate edge position based on direction
|
||||
// As progress goes from 0 to 1, we reveal source2 (new wallpaper)
|
||||
if (ubuf.direction < 0.5) {
|
||||
// Wipe from right to left (new image enters from right)
|
||||
edge = 1.0 - extendedProgress;
|
||||
factor = smoothstep(edge - ubuf.smoothness, edge + ubuf.smoothness, uv.x);
|
||||
factor = smoothstep(edge - mappedSmoothness, edge + mappedSmoothness, uv.x);
|
||||
fragColor = mix(color1, color2, factor);
|
||||
}
|
||||
else if (ubuf.direction < 1.5) {
|
||||
// Wipe from left to right (new image enters from left)
|
||||
edge = extendedProgress;
|
||||
factor = smoothstep(edge - ubuf.smoothness, edge + ubuf.smoothness, uv.x);
|
||||
factor = smoothstep(edge - mappedSmoothness, edge + mappedSmoothness, uv.x);
|
||||
fragColor = mix(color2, color1, factor);
|
||||
}
|
||||
else if (ubuf.direction < 2.5) {
|
||||
// Wipe from bottom to top (new image enters from bottom)
|
||||
edge = 1.0 - extendedProgress;
|
||||
factor = smoothstep(edge - ubuf.smoothness, edge + ubuf.smoothness, uv.y);
|
||||
factor = smoothstep(edge - mappedSmoothness, edge + mappedSmoothness, uv.y);
|
||||
fragColor = mix(color1, color2, factor);
|
||||
}
|
||||
else {
|
||||
// Wipe from top to bottom (new image enters from top)
|
||||
edge = extendedProgress;
|
||||
factor = smoothstep(edge - ubuf.smoothness, edge + ubuf.smoothness, uv.y);
|
||||
factor = smoothstep(edge - mappedSmoothness, edge + mappedSmoothness, uv.y);
|
||||
fragColor = mix(color2, color1, factor);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue