summaryrefslogtreecommitdiffstats
path: root/res/text.f.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'res/text.f.glsl')
-rw-r--r--res/text.f.glsl21
1 files changed, 18 insertions, 3 deletions
diff --git a/res/text.f.glsl b/res/text.f.glsl
index 70ad3d19..cf477eb0 100644
--- a/res/text.f.glsl
+++ b/res/text.f.glsl
@@ -15,6 +15,7 @@
in vec2 TexCoords;
flat in vec3 fg;
flat in vec4 bg;
+flat in int colored;
uniform int backgroundPass;
layout(location = 0, index = 0) out vec4 color;
@@ -31,8 +32,22 @@ void main()
alphaMask = vec4(1.0);
color = vec4(bg.rgb, 1.0);
} else {
- vec3 textColor = texture(mask, TexCoords).rgb;
- alphaMask = vec4(textColor, textColor.r);
- color = vec4(fg, 1.0);
+ if (colored != 0) {
+ // Color glyphs, like emojis.
+ vec4 glyphColor = texture(mask, TexCoords);
+ alphaMask = vec4(glyphColor.a);
+
+ // Revert alpha premultiplication.
+ if (glyphColor.a != 0) {
+ glyphColor.rgb = vec3(glyphColor.rgb / glyphColor.a);
+ }
+
+ color = vec4(glyphColor.rgb, 1.0);
+ } else {
+ // Regular text glyphs.
+ vec3 textColor = texture(mask, TexCoords).rgb;
+ alphaMask = vec4(textColor, textColor.r);
+ color = vec4(fg, 1.0);
+ }
}
}