diff options
author | Martin Andersson <g02maran@gmail.com> | 2019-11-18 13:51:06 +0100 |
---|---|---|
committer | Martin Andersson <g02maran@gmail.com> | 2019-12-09 22:33:29 +0100 |
commit | 068309acaa787fe8a094869e839c1d0131721f55 (patch) | |
tree | 371215d00812ba7e77f4762a95b20fc0eb269416 | |
parent | 69789d0184ffa54c1760ad5204bb4539c9399753 (diff) |
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 <wieland.hagen@kdab.com>
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r-- | src/extras/shaders/es2/distancefieldtext.frag | 2 | ||||
-rw-r--r-- | src/extras/shaders/gl3/distancefieldtext.frag | 2 |
2 files changed, 2 insertions, 2 deletions
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; } |