Advertisement
tasuku

N9RoundedShapeEffect

Aug 24th, 2012
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import QtQuick 1.1
  2. import Qt.labs.shaders 1.0
  3.  
  4. ShaderEffectItem {
  5. id: root
  6. property alias sourceItem: source.sourceItem
  7. anchors.fill: root.sourceItem ? root.sourceItem : undefined
  8. property variant source: ShaderEffectSource {
  9. id: source
  10. hideSource: true
  11. smooth: true
  12. }
  13.  
  14. property variant mask: ShaderEffectSource {
  15. sourceItem: Image { source: './mask.png' }
  16.  
  17. hideSource: true
  18. smooth: true
  19. }
  20.  
  21. vertexShader: '
  22. uniform highp mat4 qt_ModelViewProjectionMatrix;
  23. attribute highp vec4 qt_Vertex;
  24. attribute highp vec2 qt_MultiTexCoord0;
  25. varying highp vec2 qt_TexCoord0;
  26. void main(void)
  27. {
  28. qt_TexCoord0 = qt_MultiTexCoord0;
  29. gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex;
  30. }'
  31. fragmentShader: '
  32. varying highp vec2 qt_TexCoord0;
  33. uniform sampler2D source;
  34. uniform sampler2D mask;
  35. void main(void)
  36. {
  37. lowp vec4 color = texture2D(source, qt_TexCoord0.st);
  38. color.a = texture2D(mask, qt_TexCoord0.st).a;
  39. if (color.a < 0.5)
  40. gl_FragColor = vec4(0.0);
  41. else
  42. gl_FragColor = color;
  43. }'
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement