diff --git a/modules/OverviewBackdrop.qml b/modules/OverviewBackdrop.qml index 7051114..e369b0a 100644 --- a/modules/OverviewBackdrop.qml +++ b/modules/OverviewBackdrop.qml @@ -31,10 +31,11 @@ PanelWindow { anchors.fill: parent fragmentShader: Qt.resolvedUrl("hex_wave.frag.qsb") - // Uniforms - property size uResolution: Qt.size(width, height) + // Uniforms — order must match shader std140 layout property real uSize: 50.0 property real uWavePhase: -200 + property real _pad0: 0 + property vector4d uResolution: Qt.vector4d(width, height, 0, 0) property color uC0: M.Theme.base0C property color uC1: M.Theme.base0E property color uC2: M.Theme.base09 diff --git a/modules/hex_wave.frag b/modules/hex_wave.frag index 8ba8be2..3335303 100644 --- a/modules/hex_wave.frag +++ b/modules/hex_wave.frag @@ -6,14 +6,13 @@ layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { mat4 qt_Matrix; float qt_Opacity; - - vec2 uResolution; float uSize; float uWavePhase; + float _pad0; + vec4 uResolution; // xy = resolution, zw unused vec4 uC0; vec4 uC1; vec4 uC2; - vec4 uSpinners0; vec4 uSpinners1; vec4 uSpinners2; @@ -37,7 +36,8 @@ float sdHexFlat(vec2 p, float r) { } void main() { - vec2 frag = qt_TexCoord0 * uResolution; + vec2 res = uResolution.xy; + vec2 frag = qt_TexCoord0 * res; float dx = uSize * 1.5; float dy = uSize * 1.7320508; @@ -47,14 +47,12 @@ void main() { float row = round((frag.y - yoff) / dy); vec2 center = vec2(col * dx, row * dy + yoff); - // Wave factor float dist = center.x - uWavePhase; float wf = exp(-dist * dist / 9000.0); float baseR = uSize * 0.48; float inradius = baseR * (1.0 + 0.35 * wf); - // Check spinners float spinAngle = 0.0; vec4 spinners[12] = vec4[12]( uSpinners0, uSpinners1, uSpinners2, uSpinners3, @@ -81,22 +79,18 @@ void main() { return; } - // Gradient color - float fx = clamp(center.x / uResolution.x, 0.0, 1.0); + float fx = clamp(center.x / res.x, 0.0, 1.0); vec3 rgb = fx < 0.5 ? mix(uC0.rgb, uC1.rgb, fx * 2.0) : mix(uC1.rgb, uC2.rgb, (fx - 0.5) * 2.0); - // Alpha from distance to center - float fy = clamp(center.y / uResolution.y, 0.0, 1.0); + float fy = clamp(center.y / res.y, 0.0, 1.0); float dc = length(vec2(fx - 0.5, fy - 0.5)); float a = 0.03 + dc * 0.06; - // Wave brighten rgb = min(rgb + vec3(0.3 * wf), vec3(1.0)); a += 0.12 * wf; - // Anti-alias float aa = 1.0 - smoothstep(-1.0, 0.0, d); a *= aa;