<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?<br></div><div><br>-- <br><div class="gmail_signature">Luca Donaggio</div>
</div></div>