From d7bbf9d82e9f129877e6d304b527071155348c59 Mon Sep 17 00:00:00 2001 From: Jere Tuliniemi Date: Mon, 20 May 2019 13:12:37 +0300 Subject: Copy distance field shader changes to OpenGL runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixes the OpenGL runtime to use alpha channel for the glyph texture when using ES2. Task-number: QT3DS-3343 Change-Id: Ia37c341802e504da21ebeaff6f3f1f5b50bd1bfe Reviewed-by: Mahmoud Badri Reviewed-by: Miikka Heikkinen Reviewed-by: Antti Määttä --- src/Runtime/res/effectlib/distancefieldtext.vert | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/Runtime/res/effectlib/distancefieldtext.vert') diff --git a/src/Runtime/res/effectlib/distancefieldtext.vert b/src/Runtime/res/effectlib/distancefieldtext.vert index 01024c6b..f6b2de41 100644 --- a/src/Runtime/res/effectlib/distancefieldtext.vert +++ b/src/Runtime/res/effectlib/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 vec3 vCoord; attribute highp vec2 tCoord; varying highp vec2 sampleCoord; + +#ifdef use_fallback varying highp vec2 alphas; highp float thresholdFunc(highp float scale) @@ -55,11 +63,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); - sampleCoord = tCoord * vec2(1.0 / highp float(textureWidth), 1.0 / highp float(textureHeight)); +#endif + + sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); gl_Position = mvp * vec4(vCoord, 1.0); } -- cgit v1.2.3