// 是dash_line_2D.fs的变体，对断面增加了抗锯齿处理，GPU性能消耗较高
#include "version.sh"


in highp vec3  umf_df_adf;
in highp float anti_length_f;

uniform lowp vec4 color0;
uniform lowp vec4 color1;
uniform highp float period_rev;
uniform highp float space_ratio;
out lowp vec4 fragColor;

void main()
{
    highp float acc_period = umf_df_adf.z * period_rev;
    acc_period = fract(acc_period);
    highp float k = period_rev * anti_length_f;
    lowp float ratio = 1.0;
    if (acc_period <= k)
    {
        ratio = (k - acc_period) * 0.5 / k;
    }
    else if (acc_period <= space_ratio - k)
    {
        ratio = 0.0;
    }
    else if (acc_period <= space_ratio + k)
    {
        ratio = (acc_period - space_ratio + k) / (2.0 * k);
    }
    else if (acc_period <= 1.0 - k)
    {
        ratio = 1.0;
    }
    else
        ratio = (1.0 + k - acc_period) * 0.5 / k;
    fragColor = mix(color1, color0, ratio);
    fragColor.a *= clamp(umf_df_adf.x - abs(umf_df_adf.y), 0.0, 1.0);
}
