From 31c29f43183335e49ee78e069f45562019135577 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 24 Apr 2018 15:33:03 +0100 Subject: [PATCH] Refactored the handling of glyph and shadow alpha values to make the text and shadow clearer for fonts with narrow glyphs --- src/osgText/shaders/text_frag.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/osgText/shaders/text_frag.cpp b/src/osgText/shaders/text_frag.cpp index 4687a6bb6..bcbef2d12 100644 --- a/src/osgText/shaders/text_frag.cpp +++ b/src/osgText/shaders/text_frag.cpp @@ -245,7 +245,19 @@ char text_frag[] = "$OSG_GLSL_VERSION\n" " shadow_color.rgb = BACKDROP_COLOR.rgb;\n" "\n" " vec4 glyph_color = textColor(texCoord);\n" + "\n" + " // lower the alpha_power value the greater the staturation, no need to be so aggressive with SDF than GREYSCALE\n" + " #if SIGNED_DISTANCE_FIELD\n" + " float alpha_power = 0.6;\n" + " #else\n" + " float alpha_power = 0.5;\n" + " #endif\n" + "\n" + " // over saturate the alpha values to make sure the font and it's shadow are clear\n" + " shadow_color.a = pow(shadow_color.a, alpha_power);\n" + " glyph_color.a = pow(glyph_color.a, alpha_power);\n" " vec4 color = mix(shadow_color, glyph_color, glyph_color.a);\n" + "\n" "#else\n" " vec4 color = textColor(texCoord);\n" "#endif\n"