diff --git a/package/contents/ui/LunaIcon.qml b/package/contents/ui/LunaIcon.qml index f62fd6a0d778b0770e9d3af5b483a0e8b7b7fabc..26d2790ff39b10d4f6145bfeba028214ac4cb921 100644 --- a/package/contents/ui/LunaIcon.qml +++ b/package/contents/ui/LunaIcon.qml @@ -104,44 +104,6 @@ Item { } - Canvas { - id: shadow - - property int theta: lunaIcon.theta - property bool showShadow: lunaIcon.showShadow - - width: lunaBackground.width - height: lunaBackground.height - visible: true - anchors.centerIn: parent - contextType: "2d" - onThetaChanged: requestPaint() - onShowShadowChanged: requestPaint() - onWidthChanged: requestPaint() - onPaint: { - context.reset(); - if (showShadow) { - var cosTheta = Math.cos(theta / 180 * Math.PI); - var counterclockwisep = (theta < 180); - context.globalAlpha = 0.9; - context.translate(radius, radius); - if (theta != 180) { - context.beginPath(); - context.fillStyle = '#000000'; - context.strokeStyle = '#000000'; - context.arc(0, 0, radius, -0.5 * Math.PI, 0.5 * Math.PI, counterclockwisep); - if ((theta % 180) != 90) { - context.scale(cosTheta, 1); - context.arc(0, 0, radius, 0.5 * Math.PI, -0.5 * Math.PI, counterclockwisep); - } - context.closePath(); - context.fill(); - context.stroke(); - } - } - } - } - Canvas { id: markers @@ -223,6 +185,54 @@ Item { } + ShaderEffectSource { + id: shadow + + anchors.centerIn: parent + width: lunaBackground.width + height: lunaBackground.height + visible: false + antialiasing: false + + sourceItem: Canvas { + property int theta: lunaIcon.theta + property bool showShadow: lunaIcon.showShadow + + antialiasing: true + width: lunaBackground.width + height: lunaBackground.height + visible: true + anchors.centerIn: parent + contextType: "2d" + onThetaChanged: requestPaint() + onShowShadowChanged: requestPaint() + onWidthChanged: requestPaint() + onPaint: { + context.reset(); + if (showShadow) { + var cosTheta = Math.cos(theta / 180 * Math.PI); + var counterclockwisep = (theta < 180); + context.globalAlpha = 0.9; + context.translate(radius, radius); + if (theta != 180) { + context.beginPath(); + context.fillStyle = '#ffffff'; + context.strokeStyle = '#ffffff'; + context.arc(0, 0, radius, -0.5 * Math.PI, 0.5 * Math.PI, counterclockwisep); + if ((theta % 180) != 90) { + context.scale(cosTheta, 1); + context.arc(0, 0, radius, 0.5 * Math.PI, -0.5 * Math.PI, counterclockwisep); + } + context.closePath(); + context.fill(); + context.stroke(); + } + } + } + } + + } + ShaderEffectSource { id: lunaMask @@ -230,6 +240,7 @@ Item { width: lunaBackground.width height: lunaBackground.height visible: false + antialiasing: false sourceItem: Shape { opacity: 1 @@ -264,6 +275,7 @@ Item { property variant mask: lunaMask property int transparent: transparentShadow + opacity: 1 rotation: latitude - 90 visible: true antialiasing: true diff --git a/src/shadow.frag b/src/shadow.frag index 60b3f89d3654fab96016090eeadee5e4af4e493e..9f0e5d287d85c581044fb044ff83ea97d245d3c1 100644 --- a/src/shadow.frag +++ b/src/shadow.frag @@ -11,9 +11,14 @@ layout(binding = 1) uniform sampler2D source; layout(binding = 2) uniform sampler2D shadow; layout(binding = 3) uniform sampler2D mask; -void main() { fragColor = texture(source, qt_TexCoord0) - * texture(mask, qt_TexCoord0).a - * (1 - texture(shadow, qt_TexCoord0).a * transparent) - * qt_Opacity ; +void main() { + fragColor = vec4( + ((1 - transparent)* texture(source, qt_TexCoord0) * (1- texture(shadow, qt_TexCoord0)) + + transparent * texture(source, qt_TexCoord0)).rgb, + texture(source, qt_TexCoord0).a) + * texture(mask, qt_TexCoord0).a + * (1 - texture(shadow, qt_TexCoord0).a * transparent) + * qt_Opacity ; } +