#include "version.sh"

// #extension GL_OES_standard_derivatives : enable
uniform sampler2D texUnit;

in vec2 uv_f;
in vec3 edge_outline_aagap_f;
in highp vec4 fillcolor_f;
in highp vec4 outlinecolor_f;

layout(location = 0) out vec4 fragColor;

void main()
{
    highp float edge = edge_outline_aagap_f.x;
    highp float outline = edge_outline_aagap_f.y;
    highp float aagap = edge_outline_aagap_f.z;
    
    highp float distance = texture(texUnit, uv_f).r;
    highp float halfAA = aagap * 0.5;
    highp float outlineFactor = smoothstep(edge - halfAA, edge + halfAA, distance);
    lowp vec4 color = mix(outlinecolor_f, fillcolor_f, outlineFactor);
    highp float transparentFactor = smoothstep(outline - halfAA, outline + halfAA, distance);
    fragColor = color * transparentFactor;
}
