aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/particles/defaultshaders/imagefragment.shader
blob: 5286c8519abcf98a14801fd00946c8f55282cc48 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
uniform sampler2D texture;
uniform lowp float qt_Opacity;

#ifdef SPRITE
varying highp vec4 fTexS;
#else
#ifdef DEFORM //First non-pointsprite
varying highp vec2 fTex;
#endif
#endif
#ifdef COLOR
varying lowp vec4 fColor;
#else
varying lowp float fFade;
#endif
#ifdef TABLE
varying lowp vec2 tt;
uniform sampler2D colortable;
uniform sampler2D opacitytable;
uniform sampler2D sizetable;
#endif

void main() {
#ifdef SPRITE
    gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), tt.y)
            * fColor
            * texture2D(colortable, tt)
            * (texture2D(opacitytable, tt).w * qt_Opacity);
#else
#ifdef TABLE
    highp vec2 tex = (((fTex - 0.5) / texture2D(sizetable, tt).w) + 0.5);
    lowp vec4 color;
    if(tex.x < 1.0 && tex.x > 0.0 && tex.y < 1.0 && tex.y > 0.0){//No CLAMP_TO_BORDER in ES2, so have to do it ourselves
        color = texture2D(texture, tex);//TODO: Replace with uniform array in vertex shader
    }else{
        color = vec4(0.,0.,0.,0.);
    }
    gl_FragColor = color
            * fColor
            * texture2D(colortable, tt)
            * (texture2D(opacitytable,tt).w * qt_Opacity);
#else
#ifdef DEFORM
    gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;
#else
#ifdef COLOR
    gl_FragColor = (texture2D(texture, gl_PointCoord)) * fColor * qt_Opacity;
#else
    gl_FragColor = texture2D(texture, gl_PointCoord) * (fFade * qt_Opacity);
#endif //COLOR
#endif //DEFORM
#endif //TABLE
#endif //SPRITE
}