Updated from OpenSceneGraph-Data/shader/text.frag to add fixes to handling of vertexColor's alpha values

This commit is contained in:
Robert Osfield
2017-10-26 12:08:00 +01:00
parent 5918735ebc
commit 1e896777d1

View File

@@ -79,15 +79,15 @@ char text_frag[] = "$OSG_GLSL_VERSION\n"
" }\n"
" else if (edge_distance>-blend_half_width)\n"
" {\n"
" return mix(vertexColor, BACKDROP_COLOR, smoothstep(0.0, 1.0, (blend_half_width-edge_distance)/(blend_width)));\n"
" return mix(vertexColor, vec4(BACKDROP_COLOR.rgb, BACKDROP_COLOR.a*vertexColor.a), smoothstep(0.0, 1.0, (blend_half_width-edge_distance)/(blend_width)));\n"
" }\n"
" else if (edge_distance>(blend_half_width-outline_width))\n"
" {\n"
" return BACKDROP_COLOR;\n"
" return vec4(BACKDROP_COLOR.rgb, BACKDROP_COLOR.a*vertexColor.a);\n"
" }\n"
" else if (edge_distance>-(outline_width+blend_half_width))\n"
" {\n"
" return vec4(BACKDROP_COLOR.rgb, ((blend_half_width+outline_width+edge_distance)/blend_width));\n"
" return vec4(BACKDROP_COLOR.rgb, vertexColor.a * ((blend_half_width+outline_width+edge_distance)/blend_width));\n"
" }\n"
" else\n"
" {\n"
@@ -100,7 +100,7 @@ char text_frag[] = "$OSG_GLSL_VERSION\n"
" }\n"
" else if (edge_distance>-blend_half_width)\n"
" {\n"
" return vec4(vertexColor.rgb, smoothstep(1.0, 0.0, (blend_half_width-edge_distance)/(blend_width)));\n"
" return vec4(vertexColor.rgb, vertexColor.a * smoothstep(1.0, 0.0, (blend_half_width-edge_distance)/(blend_width)));\n"
" }\n"
" else\n"
" {\n"
@@ -214,7 +214,7 @@ char text_frag[] = "$OSG_GLSL_VERSION\n"
" if (outline_alpha==0.0) return vec4(0.0, 0.0, 0.0, 0.0); // outside glyph and outline\n"
"\n"
" vec4 color = mix(BACKDROP_COLOR, vertexColor, smoothstep(0.0, 1.0, alpha));\n"
" color.a = smoothstep(0.0, 1.0, outline_alpha);\n"
" color.a = vertexColor.a * smoothstep(0.0, 1.0, outline_alpha);\n"
"\n"
" return color;\n"
"\n"