1 INPUT mediump vec2 vTexCoord;
2 uniform sampler2D sTexture;
3 #ifdef IS_REQUIRED_STYLE
4 uniform sampler2D sStyle;
6 #ifdef IS_REQUIRED_OVERLAY
7 uniform sampler2D sOverlayStyle;
9 #ifdef IS_REQUIRED_MULTI_COLOR
10 #elif defined(IS_REQUIRED_EMOJI)
11 // Single color with emoji.
12 uniform sampler2D sMask;
13 uniform lowp float uHasMultipleTextColors;
15 uniform lowp vec4 uTextColorAnimatable;
16 uniform lowp vec4 uColor;
17 uniform lowp vec3 mixColor;
21 #ifdef IS_REQUIRED_STYLE
22 mediump vec4 styleTexture = TEXTURE( sStyle, vTexCoord );
25 #ifdef IS_REQUIRED_OVERLAY
26 mediump vec4 overlayStyleTexture = TEXTURE( sOverlayStyle, vTexCoord );
29 #if defined(IS_REQUIRED_MULTI_COLOR) || defined(IS_REQUIRED_EMOJI)
30 // Multiple color or use emoji.
31 mediump vec4 textColor = TEXTURE(sTexture, vTexCoord);
33 #ifdef IS_REQUIRED_MULTI_COLOR
34 #elif defined(IS_REQUIRED_EMOJI)
35 // Single color with emoji.
36 mediump float maskTexture = TEXTURE(sMask, vTexCoord).r;
38 // Set the color of non-transparent pixel in text to what it is animated to.
39 // Markup text with multiple text colors are not animated (but can be supported later on if required).
40 // Emoji color are not animated.
41 mediump float vstep = step( 0.0001, textColor.a );
42 textColor.rgb = mix(textColor.rgb, uTextColorAnimatable.rgb, vstep * maskTexture * (1.0 - uHasMultipleTextColors));
45 // Single color without emoji.
46 mediump float textTexture = TEXTURE(sTexture, vTexCoord).r;
47 mediump vec4 textColor = uTextColorAnimatable * textTexture;
50 // Draw the text as overlay above the style
51 OUT_COLOR = uColor * vec4(mixColor, 1.0) * (
52 #ifdef IS_REQUIRED_OVERLAY
56 #ifdef IS_REQUIRED_STYLE
57 + styleTexture * (1.0 - textColor.a)
59 #ifdef IS_REQUIRED_OVERLAY
60 ) * (1.0 - overlayStyleTexture.a) + overlayStyleTexture