#version 300 es
precision mediump float;
precision highp int;

layout(std140) uniform fs_ub
{
    highp vec4 u_textColor;
    highp vec4 u_effectColor;
    highp float u_effectWidth;
    mediump int u_labelPass;
} _37;

uniform mediump sampler2D u_tex0;

in highp vec2 v_texCoord;
layout(location = 0) out highp vec4 FragColor;
in highp vec4 v_color;

void main()
{
    highp float dist = texture(u_tex0, v_texCoord).x;
    highp float smoothing = fwidth(dist);
    highp float alpha = smoothstep(0.5 - smoothing, 0.5 + smoothing, dist);
    if (_37.u_labelPass == 0)
    {
        FragColor = v_color * vec4(_37.u_textColor.xyz, _37.u_textColor.w * alpha);
    }
    else
    {
        if (_37.u_labelPass == 1)
        {
            highp float pivot = clamp(0.5 + (1.0 - _37.u_effectWidth), 0.0, 1.0);
            highp float mu = smoothstep(0.0, pivot, dist);
            highp vec4 color = (_37.u_effectColor * (1.0 - alpha)) + (_37.u_textColor * alpha);
            FragColor = v_color * vec4(color.xyz, max(alpha, mu) * color.w);
        }
        else
        {
            FragColor = v_color * vec4(_37.u_effectColor.xyz, _37.u_effectColor.w * alpha);
        }
    }
}

