summaryrefslogtreecommitdiffstats
path: root/src/runtime/shaders/distancefieldtext.vert
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/shaders/distancefieldtext.vert')
-rw-r--r--src/runtime/shaders/distancefieldtext.vert14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/runtime/shaders/distancefieldtext.vert b/src/runtime/shaders/distancefieldtext.vert
index fa96ff7..306d109 100644
--- a/src/runtime/shaders/distancefieldtext.vert
+++ b/src/runtime/shaders/distancefieldtext.vert
@@ -1,3 +1,9 @@
+#ifdef GL_OES_standard_derivatives
+# extension GL_OES_standard_derivatives : enable
+#else
+# define use_fallback
+#endif
+
uniform highp mat4 mvp;
uniform highp float fontScale;
uniform int textureWidth;
@@ -7,6 +13,8 @@ attribute highp vec4 vCoord;
attribute highp vec2 tCoord;
varying highp vec2 sampleCoord;
+
+#ifdef use_fallback
varying highp vec2 alphas;
highp float thresholdFunc(highp float scale)
@@ -53,11 +61,15 @@ highp float determinant(highp mat4 m)
det -= m[3][0] * determinantOfSubmatrix(m, 0, 1, 2, 1, 2, 3);
return det;
}
+#endif
void main()
{
- highp float scale = fontScale * sqrt(abs(determinant(mvp)));
+#ifdef use_fallback
+ highp float scale = fontScale * pow(abs(determinant(mvp)), 1.0 / 3.0);
alphas = alphaRange(scale);
+#endif
+
sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight));
gl_Position = mvp * vCoord;
}