diff --git a/shaders/liquid-glass.frag b/shaders/liquid-glass.frag index 3faaa4f..36d746f 100644 --- a/shaders/liquid-glass.frag +++ b/shaders/liquid-glass.frag @@ -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; } diff --git a/shaders/liquid-glass.frag.qsb b/shaders/liquid-glass.frag.qsb index 805b78b..8f49b0f 100644 Binary files a/shaders/liquid-glass.frag.qsb and b/shaders/liquid-glass.frag.qsb differ diff --git a/shell.qml b/shell.qml index 6900819..90b06e5 100644 --- a/shell.qml +++ b/shell.qml @@ -24,7 +24,6 @@ ShellRoot { } ColumnLayout { - // anchors.fill: parent anchors { centerIn: parent } @@ -58,12 +57,13 @@ ShellRoot { live: true } - FastBlur { + GaussianBlur { id: backgroundBlur anchors.fill: parent source: blurredBackground - radius: 16 - transparentBorder: true + radius: 4 + samples: 4 + // transparentBorder: true } // Liquid glass shader warp @@ -75,38 +75,51 @@ ShellRoot { property real warpStrength: warpSlider.value property real flowSpeed: speedSlider.value property real scale: 3.0 + property real edgeReflectionStrength: edgeReflectionSlider.value + property real edgeReflectionWidth: edgeWidthSlider.value + property real cornerRadius: 0.1 property variant source: ShaderEffectSource { - sourceItem: backgroundBlur + sourceItem: backgroundBlur hideSource: false live: true } } - // Glass overlay + // Subtle glass overlay Rectangle { anchors.fill: parent - color: Qt.rgba(1,1,1, 0.05) - border.width: 1 - border.color: Qt.rgba(1, 1, 1, 0.3) + color: "transparent" radius: 20 + // Subtle inner glow Rectangle { anchors.fill: parent anchors.margins: 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 { GradientStop { position: 0.0 - color: Qt.rgba(1, 1, 1, 0.1) - } - GradientStop { - position: 0.3 - color: Qt.rgba(1, 1, 1, 0.05) + color: Qt.rgba(1, 1, 1, 0.08) } GradientStop { 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 } } + + 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 + } + } } } }