// bloom.frag — two-pass Gaussian bloom
#version 330 core
in vec2 f_uv;
uniform sampler2D u_texture;
uniform bool u_horizontal;
uniform float u_radius;
out vec4 o_color;
// 9-tap Gaussian weights
const float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
void main() {
vec2 tex_offset = 1.0 / textureSize(u_texture, 0) * u_radius;
vec3 result = texture(u_texture, f_uv).rgb * weight[0];
if (u_horizontal) {
for (int i = 1; i < 5; ++i) {
result += texture(u_texture, f_uv + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
result += texture(u_texture, f_uv - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
}
} else {
for (int i = 1; i < 5; ++i) {
result += texture(u_texture, f_uv + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
result += texture(u_texture, f_uv - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
}
}
o_color = vec4(result, 1.0);
}