1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

More wallpaper effects + per-monitor auto cycling

This commit is contained in:
bbedward
2025-09-22 17:51:59 -04:00
parent d9b9da4b3d
commit cf5dec733d
17 changed files with 850 additions and 201 deletions

View File

@@ -1,30 +0,0 @@
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float imageOpacity;
} ubuf;
void main() {
// Center coordinates around (0, 0)
vec2 uv = qt_TexCoord0 - 0.5;
// Calculate distance from center
float distance = length(uv);
// Create circular mask - anything beyond radius 0.5 is transparent
float mask = 1.0 - smoothstep(0.48, 0.52, distance);
// Sample the texture
vec4 color = texture(source, qt_TexCoord0);
// Apply the circular mask and opacity
float finalAlpha = color.a * mask * ubuf.imageOpacity * ubuf.qt_Opacity;
fragColor = vec4(color.rgb * finalAlpha, finalAlpha);
}

View File

@@ -1,56 +0,0 @@
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
// Custom properties with non-conflicting names
float itemWidth;
float itemHeight;
float cornerRadius;
float imageOpacity;
} ubuf;
// Function to calculate the signed distance from a point to a rounded box
float roundedBoxSDF(vec2 centerPos, vec2 boxSize, float radius) {
vec2 d = abs(centerPos) - boxSize + radius;
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0) - radius;
}
void main() {
// Get size from uniforms
vec2 itemSize = vec2(ubuf.itemWidth, ubuf.itemHeight);
float cornerRadius = ubuf.cornerRadius;
float itemOpacity = ubuf.imageOpacity;
// Normalize coordinates to [-0.5, 0.5] range
vec2 uv = qt_TexCoord0 - 0.5;
// Scale by aspect ratio to maintain uniform rounding
vec2 aspectRatio = itemSize / max(itemSize.x, itemSize.y);
uv *= aspectRatio;
// Calculate half size in normalized space
vec2 halfSize = 0.5 * aspectRatio;
// Normalize the corner radius
float normalizedRadius = cornerRadius / max(itemSize.x, itemSize.y);
// Calculate distance to rounded rectangle
float distance = roundedBoxSDF(uv, halfSize, normalizedRadius);
// Create smooth alpha mask
float smoothedAlpha = 1.0 - smoothstep(0.0, fwidth(distance), distance);
// Sample the texture
vec4 color = texture(source, qt_TexCoord0);
// Apply the rounded mask and opacity
// Make sure areas outside the rounded rect are completely transparent
float finalAlpha = color.a * smoothedAlpha * itemOpacity * ubuf.qt_Opacity;
fragColor = vec4(color.rgb * finalAlpha, finalAlpha);
}

View File

@@ -0,0 +1,100 @@
// ===== wp_iris_bloom.frag =====
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source1; // Current wallpaper
layout(binding = 2) uniform sampler2D source2; // Next wallpaper
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress; // 0.0 -> 1.0
float centerX; // 0..1
float centerY; // 0..1
float smoothness; // 0..1 (edge softness)
float aspectRatio; // width / height
// Fill mode parameters
float fillMode; // 0=no(center), 1=crop(fill), 2=fit(contain), 3=stretch
float imageWidth1;
float imageHeight1;
float imageWidth2;
float imageHeight2;
float screenWidth;
float screenHeight;
vec4 fillColor;
} ubuf;
vec2 calculateUV(vec2 uv, float imgWidth, float imgHeight) {
vec2 transformedUV = uv;
if (ubuf.fillMode < 0.5) {
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imageOffset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - vec2(imgWidth, imgHeight)) * 0.5;
vec2 imagePixel = screenPixel - imageOffset;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
}
else if (ubuf.fillMode < 1.5) {
float scale = max(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (scaledImageSize - vec2(ubuf.screenWidth, ubuf.screenHeight)) / scaledImageSize;
transformedUV = uv * (vec2(1.0) - offset) + offset * 0.5;
}
else if (ubuf.fillMode < 2.5) {
float scale = min(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - vec2(scaledImageSize)) * 0.5;
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imagePixel = (screenPixel - offset) / scale;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
}
// else stretch
return transformedUV;
}
vec4 sampleWithFillMode(sampler2D tex, vec2 uv, float imgWidth, float imgHeight) {
vec2 tuv = calculateUV(uv, imgWidth, imgHeight);
if (tuv.x < 0.0 || tuv.x > 1.0 || tuv.y < 0.0 || tuv.y > 1.0) {
return ubuf.fillColor;
}
return texture(tex, tuv);
}
void main() {
vec2 uv = qt_TexCoord0;
vec4 color1 = sampleWithFillMode(source1, uv, ubuf.imageWidth1, ubuf.imageHeight1);
vec4 color2 = sampleWithFillMode(source2, uv, ubuf.imageWidth2, ubuf.imageHeight2);
// Edge softness mapping
float edgeSoft = mix(0.001, 0.45, ubuf.smoothness * ubuf.smoothness);
// Aspect-corrected coordinates so the iris stays circular
vec2 center = vec2(ubuf.centerX, ubuf.centerY);
vec2 acUv = vec2(uv.x * ubuf.aspectRatio, uv.y);
vec2 acCenter = vec2(center.x * ubuf.aspectRatio, center.y);
float dist = length(acUv - acCenter);
// Max radius needed to cover the screen from the chosen center
float maxDistX = max(center.x * ubuf.aspectRatio, (1.0 - center.x) * ubuf.aspectRatio);
float maxDistY = max(center.y, 1.0 - center.y);
float maxDist = length(vec2(maxDistX, maxDistY));
float p = ubuf.progress;
p = p * p * (3.0 - 2.0 * p);
float radius = p * maxDist - edgeSoft;
// Soft circular edge: inside -> color2 (new), outside -> color1 (old)
float t = smoothstep(radius - edgeSoft, radius + edgeSoft, dist);
vec4 col = mix(color2, color1, t);
// Exact snaps at ends
if (ubuf.progress <= 0.0) col = color1;
if (ubuf.progress >= 1.0) col = color2;
fragColor = col * ubuf.qt_Opacity;
}

View File

@@ -0,0 +1,99 @@
// ===== wp_pixelate.frag =====
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source1; // Current wallpaper (underlay)
layout(binding = 2) uniform sampler2D source2; // Next wallpaper (pixelated overlay → sharp)
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress; // 0..1
float centerX; // (unused, API compat)
float centerY; // (unused)
float smoothness; // controls starting block size (0..1)
float aspectRatio; // (unused)
// Fill mode parameters
float fillMode; // 0=no(center), 1=crop, 2=fit, 3=stretch
float imageWidth1;
float imageHeight1;
float imageWidth2;
float imageHeight2;
float screenWidth;
float screenHeight;
vec4 fillColor;
} ubuf;
vec2 calculateUV(vec2 uv, float imgWidth, float imgHeight) {
vec2 transformedUV = uv;
if (ubuf.fillMode < 0.5) {
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imageOffset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - vec2(imgWidth, imgHeight)) * 0.5;
vec2 imagePixel = screenPixel - imageOffset;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
} else if (ubuf.fillMode < 1.5) {
float scale = max(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (scaledImageSize - vec2(ubuf.screenWidth, ubuf.screenHeight)) / scaledImageSize;
transformedUV = uv * (vec2(1.0) - offset) + offset * 0.5;
} else if (ubuf.fillMode < 2.5) {
float scale = min(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - scaledImageSize) * 0.5;
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imagePixel = (screenPixel - offset) / scale;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
}
return transformedUV;
}
vec4 sampleWithFillMode(sampler2D tex, vec2 uv, float w, float h) {
vec2 tuv = calculateUV(uv, w, h);
if (tuv.x < 0.0 || tuv.x > 1.0 || tuv.y < 0.0 || tuv.y > 1.0) return ubuf.fillColor;
return texture(tex, tuv);
}
vec2 quantizeUV(vec2 uv, float cellPx) {
vec2 screenSize = vec2(max(1.0, ubuf.screenWidth), max(1.0, ubuf.screenHeight));
float cell = max(1.0, ceil(cellPx)); // integer pixel cells
vec2 grid = floor(uv * screenSize / cell) * cell + 0.5 * cell;
return grid / screenSize;
}
void main() {
vec2 uv = qt_TexCoord0;
vec4 oldCol = sampleWithFillMode(source1, uv, ubuf.imageWidth1, ubuf.imageHeight1);
float p = clamp(ubuf.progress, 0.0, 1.0);
float pe = p * p * (3.0 - 2.0 * p); // smootherstep for opacity
// Screen-relative starting cell size:
// smoothness=0 → ~10% of min(screen), smoothness=1 → ~80% of min(screen)
float s = clamp(ubuf.smoothness, 0.0, 1.0);
float minSide = min(max(1.0, ubuf.screenWidth), max(1.0, ubuf.screenHeight));
float startPx = mix(minSide * 0.10, minSide * 0.80, s); // big and obvious even on small screens
// Cell size shrinks continuously from startPx → 1 as p grows
float cellPx = mix(startPx, 1.0, p);
// Sample next as pixelated overlay
vec2 uvq = quantizeUV(uv, cellPx);
vec4 newPix = sampleWithFillMode(source2, uvq, ubuf.imageWidth2, ubuf.imageHeight2);
// As we approach the end, sharpen the next from pixelated → full-res
float sharpen = smoothstep(0.75, 1.0, p); // only near the end
vec4 newFull = sampleWithFillMode(source2, uv, ubuf.imageWidth2, ubuf.imageHeight2);
vec4 newCol = mix(newPix, newFull, sharpen);
vec4 outColor = mix(oldCol, newCol, pe);
// Snaps
if (p <= 0.0) outColor = oldCol;
if (p >= 1.0) outColor = newFull;
fragColor = outColor * ubuf.qt_Opacity;
}

103
Shaders/frag/wp_portal.frag Normal file
View File

@@ -0,0 +1,103 @@
// ===== wp_portal.frag =====
#version 450
layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(binding = 1) uniform sampler2D source1; // Current wallpaper (shrinks away)
layout(binding = 2) uniform sampler2D source2; // Next wallpaper (underneath)
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float progress; // 0..1
float centerX; // 0..1
float centerY; // 0..1
float smoothness; // 0..1 (edge softness)
float aspectRatio; // width / height
// Fill mode parameters
float fillMode; // 0=no(center), 1=crop(fill), 2=fit(contain), 3=stretch
float imageWidth1;
float imageHeight1;
float imageWidth2;
float imageHeight2;
float screenWidth;
float screenHeight;
vec4 fillColor;
} ubuf;
vec2 calculateUV(vec2 uv, float imgWidth, float imgHeight) {
vec2 transformedUV = uv;
if (ubuf.fillMode < 0.5) {
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imageOffset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - vec2(imgWidth, imgHeight)) * 0.5;
vec2 imagePixel = screenPixel - imageOffset;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
}
else if (ubuf.fillMode < 1.5) {
float scale = max(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (scaledImageSize - vec2(ubuf.screenWidth, ubuf.screenHeight)) / scaledImageSize;
transformedUV = uv * (vec2(1.0) - offset) + offset * 0.5;
}
else if (ubuf.fillMode < 2.5) {
float scale = min(ubuf.screenWidth / imgWidth, ubuf.screenHeight / imgHeight);
vec2 scaledImageSize = vec2(imgWidth, imgHeight) * scale;
vec2 offset = (vec2(ubuf.screenWidth, ubuf.screenHeight) - scaledImageSize) * 0.5;
vec2 screenPixel = uv * vec2(ubuf.screenWidth, ubuf.screenHeight);
vec2 imagePixel = (screenPixel - offset) / scale;
transformedUV = imagePixel / vec2(imgWidth, imgHeight);
}
// else: stretch
return transformedUV;
}
vec4 sampleWithFillMode(sampler2D tex, vec2 uv, float w, float h) {
vec2 tuv = calculateUV(uv, w, h);
if (tuv.x < 0.0 || tuv.x > 1.0 || tuv.y < 0.0 || tuv.y > 1.0) return ubuf.fillColor;
return texture(tex, tuv);
}
void main() {
vec2 uv = qt_TexCoord0;
vec4 oldCol = sampleWithFillMode(source1, uv, ubuf.imageWidth1, ubuf.imageHeight1);
vec4 newCol = sampleWithFillMode(source2, uv, ubuf.imageWidth2, ubuf.imageHeight2);
// Edge softness
float edgeSoft = mix(0.001, 0.45, ubuf.smoothness * ubuf.smoothness);
// Aspect-corrected distance from center (keep circle round)
vec2 center = vec2(ubuf.centerX, ubuf.centerY);
vec2 acUv = vec2(uv.x * ubuf.aspectRatio, uv.y);
vec2 acCenter = vec2(center.x * ubuf.aspectRatio, center.y);
float dist = length(acUv - acCenter);
// Max radius from center to cover screen
float maxDistX = max(center.x * ubuf.aspectRatio, (1.0 - center.x) * ubuf.aspectRatio);
float maxDistY = max(center.y, 1.0 - center.y);
float maxDist = length(vec2(maxDistX, maxDistY));
// Smooth easing for a friendly feel
float p = ubuf.progress;
p = p * p * (3.0 - 2.0 * p);
// Portal radius shrinks from full to zero (bias by edgeSoft so it vanishes cleanly)
float radius = (1.0 - p) * (maxDist + edgeSoft) - edgeSoft;
// Inside circle = old wallpaper; outside = new wallpaper
float t = smoothstep(radius - edgeSoft, radius + edgeSoft, dist);
// When radius is large: t ~ 0 inside (old), ~1 outside (new)
// As radius shrinks, old area collapses to center.
vec4 col = mix(oldCol, newCol, t);
// Snaps
if (ubuf.progress <= 0.0) col = oldCol; // full old at start
if (ubuf.progress >= 1.0) col = newCol; // full new at end
fragColor = col * ubuf.qt_Opacity;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.