alacritty::renderer::text::glsl3Constant TEXT_SHADER_F
Source pub const TEXT_SHADER_F: &str = "#if defined(GLES2_RENDERER)\n// Require extension for dual source blending to work on GLES2.\n#extension GL_EXT_blend_func_extended: require\n\n#define int_t highp int\n#define float_t highp float\n#define vec3_t mediump vec3\n#define texture texture2D\n\nvarying mediump vec2 TexCoords;\nvarying mediump vec3 fg;\nvarying highp float colored;\nvarying mediump vec4 bg;\n\n#define FRAG_COLOR gl_FragColor\n#define ALPHA_MASK gl_SecondaryFragColorEXT\n#else\n\n#define int_t int\n#define float_t float\n#define vec3_t vec3\n\nin vec2 TexCoords;\nflat in vec4 fg;\nflat in vec4 bg;\n\nlayout(location = 0, index = 0) out vec4 color;\nlayout(location = 0, index = 1) out vec4 alphaMask;\n\n#define FRAG_COLOR color\n#define ALPHA_MASK alphaMask\n#endif\n\n#define COLORED 1\n\nuniform int_t renderingPass;\nuniform sampler2D mask;\n\nvoid main() {\n if (renderingPass == 0) {\n if (bg.a == 0.0) {\n discard;\n }\n\n ALPHA_MASK = vec4(1.0);\n // Premultiply background color by alpha.\n FRAG_COLOR = vec4(bg.rgb * bg.a, bg.a);\n return;\n }\n\n#if !defined(GLES2_RENDERER)\n float_t colored = fg.a;\n#endif\n\n // The wide char information is already stripped, so it\'s safe to check for equality here.\n if (int(colored) == COLORED) {\n // Color glyphs, like emojis.\n FRAG_COLOR = texture(mask, TexCoords);\n ALPHA_MASK = vec4(FRAG_COLOR.a);\n\n // Revert alpha premultiplication.\n if (FRAG_COLOR.a != 0.0) {\n FRAG_COLOR.rgb = vec3(FRAG_COLOR.rgb / FRAG_COLOR.a);\n }\n\n FRAG_COLOR = vec4(FRAG_COLOR.rgb, 1.0);\n } else {\n // Regular text glyphs.\n vec3_t textColor = texture(mask, TexCoords).rgb;\n ALPHA_MASK = vec4(textColor, textColor.r);\n FRAG_COLOR = vec4(fg.rgb, 1.0);\n }\n}\n";