This is a shaderEffect codes from an example

Qt Code:
  1. // Shader Effect
  2. ShaderEffect {
  3. id: shaderEffect
  4. anchors.fill: bug
  5. property variant source: bug
  6. property real amplitude: 0.01
  7. property real frequency: 20
  8. property real time: 0
  9. NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
  10. fragmentShader:
  11. "uniform lowp float qt_Opacity;" +
  12. "uniform highp float amplitude;" +
  13. "uniform highp float frequency;" +
  14. "uniform highp float time;" +
  15. "uniform sampler2D source;" +
  16. "varying highp vec2 qt_TexCoord0;" +
  17. "void main() {" +
  18. " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
  19. " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
  20. "}"
  21. }
To copy to clipboard, switch view to plain text mode 

I encapsulate it in a new component

Wobble.qml
Qt Code:
  1. // Shader Effect
  2. ShaderEffect {
  3. id: root
  4.  
  5. property variant source
  6. property real amplitude: 0.01
  7. property real frequency: 20
  8. property real time: 0
  9. NumberAnimation on time { loops: Animation.Infinite; from: 0; to: Math.PI * 2; duration: 600 }
  10. fragmentShader:
  11. "uniform lowp float qt_Opacity;" +
  12. "uniform highp float amplitude;" +
  13. "uniform highp float frequency;" +
  14. "uniform highp float time;" +
  15. "uniform sampler2D source;" +
  16. "varying highp vec2 qt_TexCoord0;" +
  17. "void main() {" +
  18. " highp vec2 p = sin(time + frequency * qt_TexCoord0);" +
  19. " gl_FragColor = texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x)) * qt_Opacity;" +
  20. "}"
  21. }
To copy to clipboard, switch view to plain text mode 

And I use it like this

main.qml

Qt Code:
  1. import QtQuick 2.0
  2.  
  3. Rectangle {
  4. width : bug.width
  5. height : bug.height
  6.  
  7. Image{
  8. id: bug
  9.  
  10. anchors.fill: parent
  11.  
  12. source: "/Downloads/1359170070532.jpg"
  13. smooth: true
  14. fillMode: Image.PreserveAspectFit
  15. }
  16.  
  17. Wobble{
  18. id: wobble
  19.  
  20. anchors.fill: bug
  21. source: bug
  22. }
To copy to clipboard, switch view to plain text mode 

However, it can’t work, if I replace Wobble by the original ShaderEffect, it works
What am I miss?Besides, do we have a solution to pass uniform array by qml?

ex:

Qt Code:
  1. //.....
  2. uniform vec2 offset[9];
  3.  
  4. uniform int kernel[9];
  5.  
  6. //......
To copy to clipboard, switch view to plain text mode