summaryrefslogtreecommitdiffstats
path: root/src/Runtime/res/effectlib/distancefieldtext.frag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Runtime/res/effectlib/distancefieldtext.frag')
-rw-r--r--src/Runtime/res/effectlib/distancefieldtext.frag24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Runtime/res/effectlib/distancefieldtext.frag b/src/Runtime/res/effectlib/distancefieldtext.frag
index efcf89e4..1d834902 100644
--- a/src/Runtime/res/effectlib/distancefieldtext.frag
+++ b/src/Runtime/res/effectlib/distancefieldtext.frag
@@ -1,12 +1,28 @@
+#ifdef GL_OES_standard_derivatives
+# extension GL_OES_standard_derivatives : enable
+#else
+# define use_fallback
+#endif
+
varying highp vec2 sampleCoord;
-varying highp vec2 alphas;
uniform sampler2D _qt_texture;
uniform highp vec4 color;
+#ifdef use_fallback
+varying highp vec2 alphas;
+#endif
+
void main()
{
- gl_FragColor = color * smoothstep(alphas.x,
- alphas.y,
- texture2D(_qt_texture, sampleCoord).a);
+ 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;
}