summaryrefslogtreecommitdiffstats
path: root/examples/shadereffectitem/Effectoids/Colorize.qml
blob: 74fc4cd4461d0e980edb4d6e6128e59c8da75b65 (plain)
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
import QtQuick 2.0

ShaderEffectItem
{
    fragmentShader:
            "varying highp vec2 qt_TexCoord;                                        \n" +
            "uniform sampler2D qt_Texture;                                          \n" +
            "uniform lowp vec4 color;                                               \n" +
            "uniform lowp float intensity;                                          \n" +
            "void main() {                                                          \n" +
            "    lowp vec4 pix = texture2D(qt_Texture, qt_TexCoord);                \n" +
            "    lowp float gray = dot(pix.rgb, vec3(0.5, 0.5, 0.5));            \n" +
            "    gl_FragColor = mix(pix, color * (gray * pix.w), intensity);        \n" +
            "}"

    vertexShader:
            "attribute highp vec4 qt_VertexPosition;                              \n" +
            "attribute highp vec2 qt_VertexTexCoord;                              \n" +
            "uniform highp mat4 qt_Matrix;                                        \n" +
            "varying highp vec2 qt_TexCoord;                                      \n" +
            "void main() {                                                        \n" +
            "    qt_TexCoord = qt_VertexTexCoord;                                 \n" +
            "    gl_Position = qt_Matrix * qt_VertexPosition;                     \n" +
            "}"

    property color color;
    property real intensity;
    active: intensity > 0
    anchors.fill: source

}