summaryrefslogtreecommitdiffstats
path: root/res/effectlib/distancefieldtext.frag
diff options
context:
space:
mode:
Diffstat (limited to 'res/effectlib/distancefieldtext.frag')
-rw-r--r--res/effectlib/distancefieldtext.frag28
1 files changed, 28 insertions, 0 deletions
diff --git a/res/effectlib/distancefieldtext.frag b/res/effectlib/distancefieldtext.frag
new file mode 100644
index 0000000..1d83490
--- /dev/null
+++ b/res/effectlib/distancefieldtext.frag
@@ -0,0 +1,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;
+}