1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
import QtQuick 2.0
Item {
width: 320
height: 480
Text {
id: text
anchors.centerIn: parent
font.pixelSize: 80
text: "Shaderz!"
visible: false
}
ShaderEffectSource {
id: clamp
sourceItem: text
smooth: true
wrapMode: ShaderEffectSource.ClampToEdge
}
ShaderEffectSource {
id: hRepeat
sourceItem: text
smooth: true
wrapMode: ShaderEffectSource.RepeatHorizontally
}
ShaderEffectSource {
id: vRepeat
sourceItem: text
smooth: true
wrapMode: ShaderEffectSource.RepeatVertically
}
ShaderEffectSource {
id: repeat
sourceItem: text
smooth: true
wrapMode: ShaderEffectSource.Repeat
}
ShaderEffect {
anchors.fill: parent
property variant cyan: hRepeat
property variant magenta: vRepeat
property variant yellow: repeat
property variant black: clamp
fragmentShader: "
uniform lowp sampler2D cyan;
uniform lowp sampler2D magenta;
uniform lowp sampler2D yellow;
uniform lowp sampler2D black;
varying highp vec2 qt_TexCoord0;
uniform lowp float qt_Opacity;
void main() {
highp vec2 t = qt_TexCoord0 * 3. - 1.;
lowp float c = texture2D(cyan, t + vec2(.05, .09)).a;
lowp float m = texture2D(magenta, t + vec2(.04, -.10)).a;
lowp float y = texture2D(yellow, t + vec2(-.10, .01)).a;
lowp float k = texture2D(black, t).a;
gl_FragColor = 1. - vec4(c + k, m + k, y + k, 0.);
}
"
}
}
|