<div dir="ltr">Wow! Documentation for Qt 5.4 has massively improved! Never thought about looking at the 5.4 branch for docs though, as I'm developing for SailfishOS exclusively and it's still 5.2 based; but from now on I will for sure, it's sooo much better, thank you for pointing this out!<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 11, 2015 at 8:07 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">
<br>
<div><span class="">
<blockquote type="cite">
<div>On 11 Feb 2015, at 10:46, Luca Donaggio <<a href="mailto:donaggio@gmail.com" target="_blank">donaggio@gmail.com</a>> wrote:</div>
<br>
<div>
<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! </div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span><div>A convenient way of adding an effect is one usecase certainly. You can use it for other things though. The Qt 5.4 docs should have a fairly good explanation of how it works.  <a href="http://doc-snapshot.qt-project.org/qt5-5.4/qml-qtquick-item.html#item-layers" target="_blank">http://doc-snapshot.qt-project.org/qt5-5.4/qml-qtquick-item.html#item-layers</a></div><span class="">
<br>
<blockquote type="cite">
<div>
<div dir="ltr">
<div>
<div>I thought that's what ShaderEffectSource does!<br>
</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span><div>layer is a more convenient ShaderEffectSource which doesn’t require you to add items into the sibling hierarchy.  </div><span class="">
<br>
<blockquote type="cite">
<div>
<div dir="ltr">
<div>
<div><br>
</div>
In my defense I must say that Qt documentation is not very clear, nor there are many examples available :-)<br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span><div>In pre Qt 5.4, yes. Very much so :) If you find the 5.4 docs lacking, please let me know.</div><span class="">
<br>
<blockquote type="cite">
<div>
<div dir="ltr">
<div><br>
</div>
Just out of curiosity then: why do you think my first code example works in the Emulator?<br>
</div>
</div>
</blockquote>
<div><br>
</div>
</span><div>Using the FBO as a source texture while writing to it is supported on many graphics cards.</div><div><div class="h5">
<br>
<blockquote type="cite">
<div>
<div dir="ltr"><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>
<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>
<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></div></div>
<br>
</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>