out vec4 outcolor; in vec2 frag_texture_coord; uniform sampler2D source; uniform bool horizontal; // ========== QUALITY SETTINGS ========== // Change this to switch between quality levels: // 0 = Fastest (5-tap, best for integrated GPUs) // 1 = Medium quality (9-tap, good balance) // 2 = High quality (17-tap, beautiful bloom but expensive) #define BLUR_QUALITY 2 #if BLUR_QUALITY == 0 // 5-tap gaussian blur (3 samples each direction) const int SAMPLE_COUNT = 3; const float weight[3] = float[](0.3829249226, 0.2419707245, 0.0606531529); const float blur_radius = 1.0; #elif BLUR_QUALITY == 1 // 9-tap gaussian blur (5 samples each direction) const int SAMPLE_COUNT = 5; const float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); const float blur_radius = 1.0; #else // 17-tap gaussian blur (9 samples each direction) const int SAMPLE_COUNT = 9; const float weight[9] = float[](0.1964825501511404, 0.1782316199485724, 0.12149164501415554, 0.0652229951888931, 0.027835877787234808, 0.009270061520867907, 0.0024201487396289743, 0.0004963317290261215, 0.0000801326238056394); const float blur_radius = 1.0; #endif void main() { vec2 tex_offset = 1.0 / vec2(textureSize(source, 0)); vec3 result = texture(source, frag_texture_coord).rgb * weight[0]; if(horizontal) { for(int i = 1; i < SAMPLE_COUNT; ++i) { float offset = tex_offset.x * float(i) * blur_radius; result += texture(source, frag_texture_coord + vec2(offset, 0.0)).rgb * weight[i]; result += texture(source, frag_texture_coord - vec2(offset, 0.0)).rgb * weight[i]; } } else { for(int i = 1; i < SAMPLE_COUNT; ++i) { float offset = tex_offset.y * float(i) * blur_radius; result += texture(source, frag_texture_coord + vec2(0.0, offset)).rgb * weight[i]; result += texture(source, frag_texture_coord - vec2(0.0, offset)).rgb * weight[i]; } } outcolor = vec4(result, 1.0); }