#version 330

in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 finalColor;

uniform sampler2D texture0;
uniform vec2 renderSize;

void main() {
    const float RADIUS = 12.0;
    const int SAMPLES = 24;

    vec2 px = 1.0 / renderSize;
    vec4 sum = vec4(0.0);

    for (int i = 0; i < SAMPLES; i++) {
        float angle = float(i) * 6.283185 / float(SAMPLES);
        vec2 offset = vec2(cos(angle), sin(angle)) * RADIUS * px;
        sum += texture(texture0, fragTexCoord + offset);
    }

    vec4 blurred = sum / float(SAMPLES);
    finalColor = vec4(blurred.rgb * 0.3, fragColor.a);
}
