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ä --- .../res/effectlib/distancefieldtext_core.vert | 32 ++-------------------- 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/Runtime/res/effectlib/distancefieldtext_core.vert') diff --git a/src/Runtime/res/effectlib/distancefieldtext_core.vert b/src/Runtime/res/effectlib/distancefieldtext_core.vert index ce6a165c..2dc198f4 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_core.vert +++ b/src/Runtime/res/effectlib/distancefieldtext_core.vert @@ -3,41 +3,13 @@ in vec2 tCoord; out vec2 sampleCoord; -out vec2 alphas; - uniform mat4 mvp; uniform int textureWidth; uniform int textureHeight; uniform float fontScale; -float thresholdFunc(float scale) -{ - float base = 0.5; - float baseDev = 0.065; - float devScaleMin = 0.15; - float devScaleMax = 0.3; - return base - ((clamp(scale, devScaleMin, devScaleMax) - devScaleMin) - / (devScaleMax - devScaleMin) * -baseDev + baseDev); -} - -float spreadFunc(float scale) -{ - return 0.06 / scale; -} - -vec2 alphaRange(float scale) -{ - float base = thresholdFunc(scale); - float range = spreadFunc(scale); - float alphaMin = max(0.0, base - range); - float alphaMax = min(base + range, 1.0); - return vec2(alphaMin, alphaMax); -} - void main() { - float scale = fontScale * sqrt(abs(determinant(mvp))); - alphas = alphaRange(scale); - sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); - gl_Position = mvp * vec4(vCoord, 1.0); + sampleCoord = tCoord * vec2(1.0 / float(textureWidth), 1.0 / float(textureHeight)); + gl_Position = mvp * vec4(vCoord, 1.0); } -- cgit v1.2.3