From 92ffe572fc22d9fae79d720655f3ab9b20cad9a1 Mon Sep 17 00:00:00 2001 From: chlorospingus Date: Sun, 28 Dec 2025 13:29:22 -0800 Subject: [PATCH] Triangles fade from bottom and behave better on antialiased mask edges --- .gitignore | 1 + default.vert | 12 ++++++++++++ shell.qml | 29 ++++++++++++++++++----------- trifade.frag | 14 ++++++++++++++ 4 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 .gitignore create mode 100644 default.vert create mode 100644 trifade.frag diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..91fb65d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.qsb diff --git a/default.vert b/default.vert new file mode 100644 index 0000000..fdd59c1 --- /dev/null +++ b/default.vert @@ -0,0 +1,12 @@ +#version 440 +layout(location = 0) in vec4 qt_Vertex; +layout(location = 1) in vec2 qt_MultiTexCoord0; +layout(location = 0) out vec2 coord; +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; +void main() { + coord = qt_MultiTexCoord0; + gl_Position = qt_Matrix * qt_Vertex; +} diff --git a/shell.qml b/shell.qml index 6ae34b8..085fc2b 100644 --- a/shell.qml +++ b/shell.qml @@ -155,7 +155,7 @@ PanelWindow { gradient: Gradient { orientation: Gradient.Horizontal GradientStop { - color: Qt.darker(button.color, 8) + color: Qt.darker(button.color, 16) position: 0 } GradientStop { @@ -205,17 +205,24 @@ PanelWindow { onObjectAdded: (index, obj) => obj.parent = triangles } } - MultiEffect { - source: triangles + Rectangle { + id: triMask + x: triangles.x + y: triangles.y + width: triangles.width + height: triangles.height + visible: false + layer.enabled: true + radius: root.radius + color: "red" + } + ShaderEffect { anchors.fill: triangles - maskEnabled: true - maskSource: ShaderEffectSource { sourceItem: Rectangle { - x: triangles.x - y: triangles.y - width: triangles.width - height: triangles.height - radius: root.radius - } } + property var src: triangles + property var mask: triMask + vertexShader: "default.vert.qsb" + fragmentShader: "trifade.frag.qsb" + } Item { diff --git a/trifade.frag b/trifade.frag new file mode 100644 index 0000000..5a83065 --- /dev/null +++ b/trifade.frag @@ -0,0 +1,14 @@ +#version 440 +layout(location = 0) in vec2 coord; +layout(location = 0) out vec4 fragColor; +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; +}; +layout(binding = 1) uniform sampler2D src; +layout(binding = 2) uniform sampler2D mask; +void main() { + vec4 tex = texture(src, coord); + float a = texture(mask, coord).a * tex.a * (1-coord.y); + fragColor = vec4(tex.r * a, tex.g * a, tex.b * a, a); +}