2020-11-10 03:38:15 +00:00
|
|
|
uniform sampler2D gTextSampler;
|
|
|
|
uniform sampler2D gTextOutlineSampler;
|
2018-03-13 20:42:05 +00:00
|
|
|
|
2020-11-10 03:38:15 +00:00
|
|
|
uniform vec4 gVertColor;
|
|
|
|
uniform vec4 gVertOutlineColor;
|
2018-03-13 20:42:05 +00:00
|
|
|
|
|
|
|
noperspective in vec2 texCoord;
|
|
|
|
noperspective in vec4 outVertColor;
|
|
|
|
|
|
|
|
out vec4 FragClr;
|
|
|
|
void main()
|
|
|
|
{
|
2021-04-30 22:42:37 +00:00
|
|
|
vec4 textColor = gVertColor * outVertColor * vec4(1.0, 1.0, 1.0, texture(gTextSampler, texCoord).r);
|
|
|
|
vec4 textOutlineTex = gVertOutlineColor * vec4(1.0, 1.0, 1.0, texture(gTextOutlineSampler, texCoord).r);
|
|
|
|
|
2018-03-13 20:42:05 +00:00
|
|
|
// ratio between the two textures
|
|
|
|
float OutlineBlend = (1.0 - textColor.a);
|
2021-04-30 22:42:37 +00:00
|
|
|
|
2018-03-13 20:42:05 +00:00
|
|
|
// since the outline is always black, or even if it has decent colors, it can be just added to the actual color
|
|
|
|
// without loosing any or too much color
|
|
|
|
|
|
|
|
// lerp isn't commutative, so add the color the fragment looses by lerping
|
|
|
|
// this reduces the chance of false color calculation if the text is transparent
|
|
|
|
|
|
|
|
// first get the right color
|
|
|
|
vec4 textOutlineFrag = vec4(textOutlineTex.rgb * textOutlineTex.a, textOutlineTex.a) * OutlineBlend;
|
|
|
|
vec3 textFrag = (textColor.rgb * textColor.a);
|
|
|
|
vec3 finalFragColor = textOutlineFrag.rgb + textFrag;
|
|
|
|
|
|
|
|
float RealAlpha = (textOutlineFrag.a + textColor.a);
|
|
|
|
|
|
|
|
// simply add the color we will loose through blending
|
|
|
|
FragClr = vec4(finalFragColor / RealAlpha, RealAlpha);
|
|
|
|
}
|