From 068309acaa787fe8a094869e839c1d0131721f55 Mon Sep 17 00:00:00 2001 From: Martin Andersson Date: Mon, 18 Nov 2019 13:51:06 +0100 Subject: QDistanceFieldMaterial: Don't scale rgb colors with distance field alpha Scaling the rbg colors with the calculated distance field alpha value can result in faint text and different colors across the same text. These issues are most obvious when the text is small. Change-Id: Ia12e54e3f344cb918575739a15e519e34d67e0f1 Reviewed-by: Wieland Hagen Reviewed-by: Paul Lemire --- src/extras/shaders/es2/distancefieldtext.frag | 2 +- src/extras/shaders/gl3/distancefieldtext.frag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/extras/shaders/es2/distancefieldtext.frag b/src/extras/shaders/es2/distancefieldtext.frag index d2db2e306..b7563e397 100644 --- a/src/extras/shaders/es2/distancefieldtext.frag +++ b/src/extras/shaders/es2/distancefieldtext.frag @@ -33,5 +33,5 @@ void main() FP float maxAlpha = threshold + range; FP float distVal = texture2D(distanceFieldTexture, texCoord).r; - gl_FragColor = color * smoothstep(minAlpha, maxAlpha, distVal); + gl_FragColor = vec4(color.rgb, color.a * smoothstep(minAlpha, maxAlpha, distVal)); } diff --git a/src/extras/shaders/gl3/distancefieldtext.frag b/src/extras/shaders/gl3/distancefieldtext.frag index 23dff8e0f..8e0684adc 100644 --- a/src/extras/shaders/gl3/distancefieldtext.frag +++ b/src/extras/shaders/gl3/distancefieldtext.frag @@ -34,6 +34,6 @@ void main() float maxAlpha = threshold + range; float distVal = texture(distanceFieldTexture, texCoord).r; - fragColor = color * smoothstep(minAlpha, maxAlpha, distVal); + fragColor = vec4(color.rgb, color.a * smoothstep(minAlpha, maxAlpha, distVal)); gl_FragDepth = gl_FragCoord.z - zValue * 0.00001; } -- cgit v1.2.3