<div dir="ltr"><div><div><div>Thank you Gunnar!<br><br></div>I completely misunderstood the "layer" property of the Item element! I thought its purpouse was to apply an effect (or a texture) to an Item before rendering it on the scene, not to render any Item as an out-of-scene texture which could then be used as the source for a ShaderEffect! I thought that's what ShaderEffectSource does!<br><br></div>In my defense I must say that Qt documentation is not very clear, nor there are many examples available :-)<br><br></div>Just out of curiosity then: why do you think my first code example works in the Emulator?<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 10, 2015 at 9:04 PM, Gunnar Sletta <span dir="ltr"><<a href="mailto:gunnar.sletta@jolla.com" target="_blank">gunnar.sletta@jolla.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word">
<div>Hi Luca, </div>
<div><br>
</div>
<div>The application code is not doing the right thing :)</div>
<div><br>
</div>
If the ShaderEffectSource depends on itself, it needs to have the “recursive” property set to true, and that is still probably not what you want. What you probably want is to set “layer.enabled: true; layer.smooth: true” on the gradientSource and then use it
 directly in the ShaderEffect. That should do what you want and comes without consequence.
<div><br>
</div>
<div>cheers,</div>
<div>Gunnar
<div><div class="h5"><div>
<div><br>
</div>
<div><br>
<div>
<blockquote type="cite">
<div>On 10 Feb 2015, at 11:54, Luca Donaggio <<a href="mailto:donaggio@gmail.com" target="_blank">donaggio@gmail.com</a>> wrote:</div>
<br>
<div>
<div dir="ltr">
<div>Thanks Andrey.<br>
</div>
<div><br>
I'll report this on TJC as well, trying to get more visibility. I hope that some Sailor will notice it: it's not that important, but it's disturbing nonetheless.<br>
</div>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Feb 10, 2015 at 11:39 AM, Andrey Kozhevnikov <span dir="ltr">
<<a href="mailto:coderusinbox@gmail.com" target="_blank">coderusinbox@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">yes i can confirm this behaviour.<br>
<br>
<div>10.02.2015 15:24, Luca Donaggio пишет:<br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>Hi Andrey, thanks for your reply.<br>
<br>
</div>
Still, can you try both tests on your Jolla?<br>
</div>
The first shouldn't work, while the second does.<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Tue, Feb 10, 2015 at 10:32 AM, Andrey Kozhevnikov <span dir="ltr">
<<a href="mailto:coderusinbox@gmail.com" target="_blank">coderusinbox@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">sorry, not using emulator at all.<br>
<br>
<div>10.02.2015 14:28, Luca Donaggio пишет:<br>
</div>
<blockquote type="cite">
<div>
<div>
<div dir="ltr">Anybody is willing to try my test code and confirm or deny my finding?<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Fri, Feb 6, 2015 at 2:12 PM, Luca Donaggio <span dir="ltr">
<<a href="mailto:donaggio@gmail.com" target="_blank">donaggio@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">The following code works fine in Emulator, changing the gradient of the Rectangle correctly updates the nested ShaderEffectSource and it is reflected on the ShaderEffect which uses it as its texture:<br>
<br>
Page {<br>
    id: page<br>
<br>
    SilicaFlickable {<br>
        anchors.fill: parent<br>
<br>
        contentHeight: column.height<br>
<br>
        Column {<br>
            id: column<br>
<br>
            anchors { top: parent.top; left: parent.left; right: parent.right; leftMargin: Theme.paddingLarge; rightMargin: Theme.paddingLarge; }<br>
            spacing: Theme.paddingLarge<br>
<br>
            PageHeader {<br>
                title: qsTr("ShaderEffect Test")<br>
            }<br>
<br>
            Row {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                spacing: Theme.paddingLarge<br>
<br>
                Column {<br>
                    spacing: Theme.paddingSmall<br>
<br>
                    Rectangle {<br>
                        id: gradientSource<br>
<br>
                        property list<Gradient> gradients: [<br>
                            Gradient {<br>
                                GradientStop { position: 0.0; color: "black"; }<br>
                                GradientStop { position: 1.0; color: "blue"; }<br>
                            },<br>
<br>
                            Gradient {<br>
                                GradientStop { position: 0.0; color: "black"; }<br>
                                GradientStop { position: 1.0; color: "red"; }<br>
                            }<br>
                        ]<br>
<br>
                        width: 100<br>
                        height: 100<br>
<br>
                        gradient: gradients[0]<br>
<br>
                        ShaderEffectSource {<br>
                            id: gradientTexture<br>
<br>
                            anchors.fill: parent<br>
                            sourceItem: gradientSource<br>
                            hideSource: false<br>
                            live: true<br>
                        }<br>
                    }<br>
<br>
                    Label {<br>
                        font.pixelSize: Theme.fontSizeExtraSmall<br>
                        wrapMode: Text.WordWrap<br>
                        text: "Rectangle\nShaderEffectSource"<br>
                    }<br>
                }<br>
<br>
                Column {<br>
                    spacing: Theme.paddingSmall<br>
<br>
                    ShaderEffect {<br>
                        property variant source: gradientTexture<br>
<br>
                        width: 100<br>
                        height: 100<br>
<br>
                        blending: false<br>
                        cullMode: ShaderEffect.BackFaceCulling<br>
                        fragmentShader: "<br>
                            varying highp vec2 qt_TexCoord0;<br>
                            uniform lowp float qt_Opacity;<br>
                            uniform sampler2D source;<br>
<br>
                            void main() {<br>
                                gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;<br>
                            }"<br>
                    }<br>
<br>
                    Label {<br>
                        font.pixelSize: Theme.fontSizeExtraSmall<br>
                        text: "ShaderEffect"<br>
                    }<br>
                }<br>
            }<br>
<br>
            Button {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                text: "Blue gradient"<br>
<br>
                onClicked: gradientSource.gradient = gradientSource.gradients[0]<br>
            }<br>
<br>
            Button {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                text: "Red gradient"<br>
<br>
                onClicked: gradientSource.gradient = gradientSource.gradients[1]<br>
            }<br>
        }<br>
    }<br>
}<br>
<br clear="all">
<div>It doesn't work on device though (changing Reactangle's gradient doesn't update the ShaderEffectSource).<br>
<br>
</div>
<div>Un-nesting the ShaderEffectSource from its source item (the Rectangle) works fine both on emulator and on device:<br>
<br>
Page {<br>
    id: page<br>
<br>
    SilicaFlickable {<br>
        anchors.fill: parent<br>
<br>
        contentHeight: column.height<br>
<br>
        Column {<br>
            id: column<br>
<br>
            anchors { top: parent.top; left: parent.left; right: parent.right; leftMargin: Theme.paddingLarge; rightMargin: Theme.paddingLarge; }<br>
            spacing: Theme.paddingLarge<br>
<br>
            PageHeader {<br>
                title: qsTr("ShaderEffect Test")<br>
            }<br>
<br>
            Row {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                spacing: Theme.paddingLarge<br>
<br>
                Column {<br>
                    spacing: Theme.paddingSmall<br>
<br>
                    Rectangle {<br>
                        id: gradientSource<br>
<br>
                        property list<Gradient> gradients: [<br>
                            Gradient {<br>
                                GradientStop { position: 0.0; color: "black"; }<br>
                                GradientStop { position: 1.0; color: "blue"; }<br>
                            },<br>
<br>
                            Gradient {<br>
                                GradientStop { position: 0.0; color: "black"; }<br>
                                GradientStop { position: 1.0; color: "red"; }<br>
                            }<br>
                        ]<br>
<br>
                        width: 100<br>
                        height: 100<br>
<br>
                        gradient: gradients[0]<br>
                    }<br>
<br>
                    Label {<br>
                        font.pixelSize: Theme.fontSizeExtraSmall<br>
                        text: "Rectangle"<br>
                    }<br>
                }<br>
<br>
                Column {<br>
                    spacing: Theme.paddingSmall<br>
<br>
                    ShaderEffectSource {<br>
                        id: gradientTexture<br>
<br>
                        width: 100<br>
                        height: 100<br>
                        sourceItem: gradientSource<br>
                        hideSource: false<br>
                        live: true<br>
                    }<br>
<br>
                    Label {<br>
                        font.pixelSize: Theme.fontSizeExtraSmall<br>
                        text: "ShaderEffectSource"<br>
                    }<br>
                }<br>
<br>
                Column {<br>
                    spacing: Theme.paddingSmall<br>
<br>
                    ShaderEffect {<br>
                        property variant source: gradientTexture<br>
<br>
                        width: 100<br>
                        height: 100<br>
<br>
                        blending: false<br>
                        cullMode: ShaderEffect.BackFaceCulling<br>
                        fragmentShader: "<br>
                            varying highp vec2 qt_TexCoord0;<br>
                            uniform lowp float qt_Opacity;<br>
                            uniform sampler2D source;<br>
<br>
                            void main() {<br>
                                gl_FragColor = texture2D(source, qt_TexCoord0) * qt_Opacity;<br>
                            }"<br>
                    }<br>
<br>
                    Label {<br>
                        font.pixelSize: Theme.fontSizeExtraSmall<br>
                        text: "ShaderEffect"<br>
                    }<br>
                }<br>
            }<br>
<br>
            Button {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                text: "Blue gradient"<br>
<br>
                onClicked: gradientSource.gradient = gradientSource.gradients[0]<br>
            }<br>
<br>
            Button {<br>
                anchors.horizontalCenter: parent.horizontalCenter<br>
                text: "Red gradient"<br>
<br>
                onClicked: gradientSource.gradient = gradientSource.gradients[1]<br>
            }<br>
        }<br>
    }<br>
}<br>
<br>
</div>
<div>Is it a bug?<span><font color="#888888"><br>
</font></span></div>
<span><font color="#888888">
<div><br>
-- <br>
<div>Luca Donaggio</div>
</div>
</font></span></div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>Luca Donaggio</div>
</div>
<br>
<fieldset></fieldset> <br>
</div>
</div>
<pre>_______________________________________________
<a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">devel-unsubscribe@lists.sailfishos.org</a></pre>
</blockquote>
<br>
</div>
<br>
_______________________________________________<br>
<a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">
devel-unsubscribe@lists.sailfishos.org</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>Luca Donaggio</div>
</div>
<br>
<fieldset></fieldset> <br>
<pre>_______________________________________________
<a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">devel-unsubscribe@lists.sailfishos.org</a></pre>
</blockquote>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
<a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">
devel-unsubscribe@lists.sailfishos.org</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div>Luca Donaggio</div>
</div>
_______________________________________________<br>
<a href="http://SailfishOS.org" target="_blank">SailfishOS.org</a> Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org" target="_blank">
devel-unsubscribe@lists.sailfishos.org</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>

<br>_______________________________________________<br>
SailfishOS.org Devel mailing list<br>
To unsubscribe, please send a mail to <a href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Luca Donaggio</div>
</div>