vibe out them edge reflections

This commit is contained in:
kossLAN 2025-06-10 13:12:50 -04:00
parent 78964344d2
commit 8845996c8c
Signed by: kossLAN
SSH key fingerprint: SHA256:bdV0x+wdQHGJ6LgmstH3KV8OpWY+OOFmJcPcB0wQPV8
3 changed files with 121 additions and 18 deletions

View file

@ -10,6 +10,8 @@ layout(std140, binding = 0) uniform buf {
float warpStrength;
float flowSpeed;
float scale;
float edgeReflectionStrength;
float edgeReflectionWidth;
} ubuf;
layout(binding = 1) uniform sampler2D source;
@ -49,16 +51,72 @@ void main() {
// Combine flows for more organic movement
vec2 finalFlow = (flowDir1 + flowDir2 * 0.5) * ubuf.warpStrength * 0.01;
// Apply subtle chromatic aberration like Apple's effect
// Apply subtle chromatic aberration
float aberration = length(finalFlow) * 0.5;
vec2 distortedUV = uv + finalFlow;
// Sample with slight chromatic separation
// Sample with slight chromatic separation for main glass effect
float r = texture(source, distortedUV + vec2(aberration, 0.0)).r;
float g = texture(source, distortedUV).g;
float b = texture(source, distortedUV - vec2(aberration, 0.0)).b;
fragColor = vec4(r, g, b, 1.0) * ubuf.qt_Opacity;
vec4 glassColor = vec4(r, g, b, 1.0);
// Simple edge reflection - back to what worked
float edgeWidth = ubuf.edgeReflectionWidth;
// Calculate distance from edges
float distFromLeft = uv.x;
float distFromRight = 1.0 - uv.x;
float distFromTop = uv.y;
float distFromBottom = 1.0 - uv.y;
// Find the minimum distance to any edge
float minDistToEdge = min(min(distFromLeft, distFromRight), min(distFromTop, distFromBottom));
// Create edge mask
float edgeMask = smoothstep(edgeWidth, 0.0, minDistToEdge);
if (edgeMask > 0.0) {
vec2 reflectionUV = distortedUV;
// Simple reflection logic
if (minDistToEdge == distFromLeft) {
// Left edge - flip horizontally
reflectionUV.x = 1.0 - distortedUV.x;
} else if (minDistToEdge == distFromRight) {
// Right edge - keep as is but sample from further right
reflectionUV.x = distortedUV.x + 0.1;
} else if (minDistToEdge == distFromTop) {
// Top edge - flip vertically
reflectionUV.y = 1.0 - distortedUV.y;
} else {
// Bottom edge - flip vertically
reflectionUV.y = 1.0 - distortedUV.y + 0.1;
}
// Clamp to valid range
reflectionUV = clamp(reflectionUV, 0.0, 1.0);
// Sample reflection with same chromatic aberration
float rRefl = texture(source, reflectionUV + vec2(aberration, 0.0)).r;
float gRefl = texture(source, reflectionUV).g;
float bRefl = texture(source, reflectionUV - vec2(aberration, 0.0)).b;
vec4 reflectionColor = vec4(rRefl, gRefl, bRefl, 1.0);
// Blend reflection with glass effect
glassColor = mix(glassColor, reflectionColor, edgeMask * ubuf.edgeReflectionStrength);
}
// Simple glass overlay enhancement
vec2 centeredUV = (uv - 0.5) * 2.0;
float fresnel = pow(1.0 - abs(dot(normalize(vec3(centeredUV, 1.0)), vec3(0.0, 0.0, 1.0))), 1.5);
// Add subtle white tint and fresnel
glassColor.rgb = mix(glassColor.rgb, vec3(1.0), 0.02 + fresnel * 0.03);
fragColor = glassColor * ubuf.qt_Opacity;
}

Binary file not shown.