
uniform sampler2D g_input;

layout (location = 0) out vec3 frag_color;

const float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);

void main() {
    vec2 size = vec2(textureSize(g_input, 0).xy);
    vec2 single = 1.0 / size;
    vec2 coords = vec2(gl_FragCoord.xy) / size;

    vec3 result = texture(g_input, coords).rgb * weight[0];
    #ifdef HORZ
        for (int i = 1; i < 5; i++) {
            result += texture(g_input, coords + vec2(single.x * i, 0.0)).rgb * weight[i];
            result += texture(g_input, coords - vec2(single.x * i, 0.0)).rgb * weight[i];
        }
    #else
        for (int i = 1; i < 5; i++) {
            result += texture(g_input, coords + vec2(0.0, single.y * i)).rgb * weight[i];
            result += texture(g_input, coords - vec2(0.0, single.y * i)).rgb * weight[i];
        }
    #endif
    frag_color = result;
}
