<commit_before>uniform float alphaScaling;
uniform int kernelType;

in vec4 gsColor;
in vec2 gsLineCoord;
in vec2 gsLineSize;

out vec4 fsColor;

float erf(float x) {
    const float PI = 3.1415926535897932384626433832795;
    return 2.0 / sqrt(PI) * sign(x) * sqrt(1.0 - exp(-pow(x, 2.0))) * (sqrt(PI) / 2.0 + 31.0 / 200.0 * exp(-pow(x, 2.0)) - 341.0 / 8000.0 * exp(-2.0 * pow(x, 2.0)));
}

// http://www.wolframalpha.com/input/?i=integrate+e%5E(-0.5*(h%5E2%2Bx%5E2))%2F(sigma+*+2.506628274631000502415765284811)+dx+from+x%3D0+to+l%2F2
float integral2DGauss(float h, float l) {
    float sigma = 2.0;
    return 0.5 * exp(-0.5 * h * h) * erf(0.353553 * l) / sigma;
}

float movingKernel(vec2 position, float width, float len) {
    // Intersection between circle and center line.
    float delta = pow(width, 2.0) - pow(position.y, 2.0);
    if (delta <= 0) {
        // Less than two intersections.
        return 0;
    }
    delta = sqrt(delta);

    // Compute two intersected center points.
    float x1 = position.x + delta;
    float x2 = position.x - delta;
    if (x1 < 0) {
        x1 = 0;
    } else if (x1 > len) {
        x1 = len;
    }
    if (x2 < 0) {
        x2 = 0;
    } else if (x2 > len) {
        x2 = len;
    }

    // Compute the distance between the two center points.
    switch (kernelType) {
    case 0:
        return abs(x1 - x2) / (2.0 * width);
        break;
    case 1:
        //integrate gauss2(x*6) dx from 0 to half distance with normalized distance and position
        return 2.0 * integral2DGauss(3.0 * position.y / width, 3.0 * abs(x1 - x2) / (2.0 * width)); //
        break;
    default:
        return 0.0;
    }
}

void main(void) {
    float alpha = movingKernel(gsLineCoord, gsLineSize.x, gsLineSize.y);
    alpha *= alphaScaling;
    fsColor = vec4(gsColor.rgb, gsColor.a * alpha);
}<commit_msg>Fix unreachable statement<commit_after>uniform float alphaScaling;
uniform int kernelType;

in vec4 gsColor;
in vec2 gsLineCoord;
in vec2 gsLineSize;

out vec4 fsColor;

float erf(float x) {
    const float PI = 3.1415926535897932384626433832795;
    return 2.0 / sqrt(PI) * sign(x) * sqrt(1.0 - exp(-pow(x, 2.0))) * (sqrt(PI) / 2.0 + 31.0 / 200.0 * exp(-pow(x, 2.0)) - 341.0 / 8000.0 * exp(-2.0 * pow(x, 2.0)));
}

// http://www.wolframalpha.com/input/?i=integrate+e%5E(-0.5*(h%5E2%2Bx%5E2))%2F(sigma+*+2.506628274631000502415765284811)+dx+from+x%3D0+to+l%2F2
float integralGauss2(float h, float l) {
    float sigma = 2.0;
    return 0.5 * exp(-0.5 * h * h) * erf(0.353553 * l) / sigma;
}

float movingKernel(vec2 position, float width, float len) {
    // Intersection between circle and center line.
    float delta = pow(width, 2.0) - pow(position.y, 2.0);
    if (delta <= 0) {
        // Less than two intersections.
        return 0;
    }
    delta = sqrt(delta);

    // Compute two intersected center points.
    float x1 = position.x + delta;
    float x2 = position.x - delta;
    if (x1 < 0) {
        x1 = 0;
    } else if (x1 > len) {
        x1 = len;
    }
    if (x2 < 0) {
        x2 = 0;
    } else if (x2 > len) {
        x2 = len;
    }

    // Compute the distance between the two center points.
    float alpha;
    switch (kernelType) {
    case 0:
        alpha = abs(x1 - x2) / (2.0 * width);
        break;
    case 1:
        // Integrate gauss2(x*6) dx from 0 to half distance with normalized distance and position.
        alpha = 2.0 * integralGauss2(3.0 * position.y / width, 3.0 * abs(x1 - x2) / (2.0 * width));
        break;
    default:
        alpha = 0.0;
    }
    return alpha;
}

void main(void) {
    float alpha = movingKernel(gsLineCoord, gsLineSize.x, gsLineSize.y);
    alpha *= alphaScaling;
    fsColor = vec4(gsColor.rgb, gsColor.a * alpha);
}
{'fraction_non_alphanumeric': 0.14862336273723603, 'fraction_numerical': 0.08981555733761026, 'mean_word_length': 2.3500447627573857, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6187840', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1456, 'n_words': 376}