ngl: Improve the coloring shader

Since we are now passing a float anyway, we can avoid
the branch in the fragment shader.
This commit is contained in:
Matthias Clasen 2021-03-13 18:04:26 -05:00
parent c1f98d6837
commit 8aac574d63

View File

@ -12,7 +12,7 @@ void main() {
// We use this shader for both plain glyphs (used as mask)
// and color glpyhs (used as source). The renderer sets
// aColor to vec4(-1) for color glyhs.
if (distance(aColor, vec4(-1)) < 0.001)
if (distance(aColor,vec4(-1)) < 0.1)
use_color = 0.0;
else
use_color = 1.0;
@ -29,8 +29,5 @@ _IN_ float use_color;
void main() {
vec4 diffuse = GskTexture(u_source, vUv);
if (use_color > 0.0)
gskSetOutputColor(final_color * diffuse.a);
else
gskSetOutputColor(diffuse * u_alpha);
gskSetOutputColor(mix(diffuse * u_alpha, final_color * diffuse.a, use_color));
}