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ä --- .../distancefieldtext_dropshadow_core.frag | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag') diff --git a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag index 4e46bd5f..51aae5a7 100644 --- a/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag +++ b/src/Runtime/res/effectlib/distancefieldtext_dropshadow_core.frag @@ -8,24 +8,22 @@ uniform sampler2D _qt_texture; uniform vec4 color; uniform vec4 shadowColor; -in vec2 alphas; - void main() { - float shadowAlpha = smoothstep(alphas.x, - alphas.y, - texture(_qt_texture, - clamp(shadowSampleCoord, - normalizedTextureBounds.xy, - normalizedTextureBounds.zw)).r); + float shadowDistance = texture(_qt_texture, + clamp(shadowSampleCoord, + normalizedTextureBounds.xy, + normalizedTextureBounds.zw)).r; + float shadowDistanceD = fwidth(shadowDistance); + float shadowAlpha = smoothstep(0.5 - shadowDistanceD, 0.5, shadowDistance); vec4 shadowPixel = color * shadowColor * shadowAlpha; - float textAlpha = smoothstep(alphas.x, - alphas.y, - texture(_qt_texture, - clamp(sampleCoord, - normalizedTextureBounds.xy, - normalizedTextureBounds.zw)).r); + float textDistance = texture(_qt_texture, + clamp(sampleCoord, + normalizedTextureBounds.xy, + normalizedTextureBounds.zw)).r; + float textDistanceD = fwidth(textDistance); + float textAlpha = smoothstep(0.5 - textDistanceD, 0.5, textDistance); vec4 textPixel = color * textAlpha; fragColor = mix(shadowPixel, textPixel, textPixel.a); -- cgit v1.2.3