out vec4 outcolor; in vec2 frag_texture_coord; uniform sampler2D source; uniform float threshold; // Bloom curve selection: // 0 = Linear (default) - simple linear fade // 1 = Smooth - smoothstep for more gradual fade-in // 2 = Power - adjustable power curve #define BLOOM_CURVE 0 void main() { vec3 color = texture(source, frag_texture_coord).rgb; // Calculate perceptual luminance float brightness = dot(color, vec3(0.2126, 0.7152, 0.0722)); // Inverted bloom: full bloom at threshold and above, fades below threshold // At brightness >= threshold: bloom_amount = 1.0 (full bloom) // At brightness = 0: bloom_amount = 0.0 (no bloom) float bloom_amount = min(brightness / threshold, 1.0); #if BLOOM_CURVE == 1 // Smooth curve - more gradual fade-in using smoothstep bloom_amount = smoothstep(0.0, 1.0, bloom_amount); #elif BLOOM_CURVE == 2 // Power curve - adjust exponent for different feel // < 1.0 = gentler fade, > 1.0 = steeper fade bloom_amount = pow(bloom_amount, 0.7); #endif // BLOOM_CURVE == 0 uses linear (no modification needed) outcolor = vec4(color * bloom_amount, 1.0); }