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 warpStrength;
float flowSpeed; float flowSpeed;
float scale; float scale;
float edgeReflectionStrength;
float edgeReflectionWidth;
} ubuf; } ubuf;
layout(binding = 1) uniform sampler2D source; layout(binding = 1) uniform sampler2D source;
@ -49,16 +51,72 @@ void main() {
// Combine flows for more organic movement // Combine flows for more organic movement
vec2 finalFlow = (flowDir1 + flowDir2 * 0.5) * ubuf.warpStrength * 0.01; 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; float aberration = length(finalFlow) * 0.5;
vec2 distortedUV = uv + finalFlow; 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 r = texture(source, distortedUV + vec2(aberration, 0.0)).r;
float g = texture(source, distortedUV).g; float g = texture(source, distortedUV).g;
float b = texture(source, distortedUV - vec2(aberration, 0.0)).b; 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.

View file

@ -24,7 +24,6 @@ ShellRoot {
} }
ColumnLayout { ColumnLayout {
// anchors.fill: parent
anchors { anchors {
centerIn: parent centerIn: parent
} }
@ -58,12 +57,13 @@ ShellRoot {
live: true live: true
} }
FastBlur { GaussianBlur {
id: backgroundBlur id: backgroundBlur
anchors.fill: parent anchors.fill: parent
source: blurredBackground source: blurredBackground
radius: 16 radius: 4
transparentBorder: true samples: 4
// transparentBorder: true
} }
// Liquid glass shader warp // Liquid glass shader warp
@ -75,6 +75,9 @@ ShellRoot {
property real warpStrength: warpSlider.value property real warpStrength: warpSlider.value
property real flowSpeed: speedSlider.value property real flowSpeed: speedSlider.value
property real scale: 3.0 property real scale: 3.0
property real edgeReflectionStrength: edgeReflectionSlider.value
property real edgeReflectionWidth: edgeWidthSlider.value
property real cornerRadius: 0.1
property variant source: ShaderEffectSource { property variant source: ShaderEffectSource {
sourceItem: backgroundBlur sourceItem: backgroundBlur
@ -83,30 +86,40 @@ ShellRoot {
} }
} }
// Glass overlay // Subtle glass overlay
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: Qt.rgba(1,1,1, 0.05) color: "transparent"
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.3)
radius: 20 radius: 20
// Subtle inner glow
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
anchors.margins: 1 anchors.margins: 1
radius: parent.radius - 1 radius: parent.radius - 1
color: "transparent"
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.05)
}
border.width: 1
border.color: Qt.rgba(1, 1, 1, 0.15)
Rectangle {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 1
height: parent.height * 0.3
radius: parent.radius - 1
gradient: Gradient { gradient: Gradient {
GradientStop { GradientStop {
position: 0.0 position: 0.0
color: Qt.rgba(1, 1, 1, 0.1) color: Qt.rgba(1, 1, 1, 0.08)
}
GradientStop {
position: 0.3
color: Qt.rgba(1, 1, 1, 0.05)
} }
GradientStop { GradientStop {
position: 1.0 position: 1.0
color: Qt.rgba(0, 0, 0, 0.05) color: Qt.rgba(1, 1, 1, 0.0)
} }
} }
} }
@ -161,6 +174,38 @@ ShellRoot {
Layout.preferredHeight: 30 Layout.preferredHeight: 30
} }
} }
RowLayout {
Text {
text: "Edge Reflection:"
}
Slider {
id: edgeReflectionSlider
from: 0
to: 1
value: 0.3
Layout.fillWidth: true
Layout.preferredHeight: 30
}
}
RowLayout {
Text {
text: "Edge Width:"
}
Slider {
id: edgeWidthSlider
from: 0.01
to: 0.2
value: 0.1
Layout.fillWidth: true
Layout.preferredHeight: 30
}
}
} }
} }
} }