summaryrefslogtreecommitdiffstats
path: root/res/effectlib/distancefieldtext.frag
blob: 1d834902e4be574514434381c9194573d3170761 (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
#ifdef GL_OES_standard_derivatives
#  extension GL_OES_standard_derivatives : enable
#else
#  define use_fallback
#endif

varying highp vec2 sampleCoord;

uniform sampler2D _qt_texture;
uniform highp vec4 color;

#ifdef use_fallback
varying highp vec2 alphas;
#endif

void main()
{
    highp float distance = texture2D(_qt_texture, sampleCoord).a;

#ifdef use_fallback
    highp float alpha = smoothstep(alphas.x, alphas.y, distance);
#else
    highp float f = fwidth(distance);
    highp float alpha = smoothstep(0.5 - f, 0.5, distance);
#endif

    gl_FragColor = color * alpha;
}