Refactored the handling of glyph and shadow alpha values to make the text and shadow clearer for fonts with narrow glyphs

This commit is contained in:
Robert Osfield 2018-04-24 15:33:03 +01:00
parent 1d431fcb3d
commit 05af4340e1

View File

@ -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"