![](https://uploads.gamedev.net/forums/monthly_2021_07/38a313cdf0094ee0acf0c5ab63a8862a.aaaaa.png)
So my base texture looks like this D below (black background white text) now i want to say rendered text to appear black that means this image above, how should i mix colors to actually achieve this,
In my opinion i should somehow find transition between one to another, by that i mean that if i want to render red text i should somehow check how much from original color to its inverse i need to go to match desired font color anyway i fail at that greatly….
here is sample code if someone is eager to read alpha is always 1.0 and lux is supposed to check whenever we want to sample background and discard.
precision highp float;
uniform sampler2D font_tex;
varying vec2 texcoord;
uniform int use_boundary;
uniform vec2 bmin;
uniform vec2 bmax;
varying vec2 scr_coord;
uniform float alpha;
uniform vec3 FONT_COLOR;
vec3 vectorAB(vec3 a, vec3 b) { return b-a; }
void main()
{
vec3 color = texture2D( font_tex, texcoord ).rgb;
vec3 finalColor = vec3(0.0);
vec3 DESIGN_FONT_COLOR = vec3(1.0, 1.0, 1.0);
vec3 inverse = vec3(1.0) - color;
vec3 toInverse = vectorAB(color, inverse);
finalColor = color - FONT_COLOR * toInverse;
float lux = ( (color.x+color.y+color.z) / 3.0 );
if (lux < 0.005) lux = 0.0;
float intensity = lux * alpha;
if ( (use_boundary == 1) )
{
if ( (scr_coord.x > bmin.x) &&
(scr_coord.x < bmax.x) &&
(scr_coord.y > bmin.y) &&
(scr_coord.y < bmax.y) )
gl_FragColor = vec4(finalColor, intensity);
else
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
} else
gl_FragColor = vec4(finalColor, intensity);
}
cheers….