Glow 2D Filter

Hi,
this is my new 2D filter. It is like a regular bloom effect, but instead of blurring everything it only blurs within a certain threshold, which allows you to limit the objects that are blurred. The effect is perfect for lights and signs :smiley:


#version 120


uniform sampler2D bgl_RenderedTexture;
uniform float threshold;


#define SAMPLES 5


void main() {
    vec4 original = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
    
    vec4 col = vec4(0.0);


    for (int i = -SAMPLES; i < SAMPLES; i++) {
        for (int j = -SAMPLES; j < SAMPLES; j++) {
            vec4 s = texture2D(bgl_RenderedTexture, gl_TexCoord[0].xy + vec2(i, j) * 0.004);
           
            if (s.r >= threshold || s.g >= threshold || s.b >= threshold) {
                col += s * 0.25;
            }
        }
    }
    gl_FragColor = (col*0.04) + original;
}

Donā€™t forget to add a float property called ā€œthresholdā€ :slight_smile:

Screenshots:
threshold = 0.75
http://i.imgur.com/ZqzLSv1.png

threshold = 0.0
http://i.imgur.com/YoG0xD6.png


I hope you like it!

Woow! Looks very nice on the screenshot! Could you share your testing .blend with?
You think you could add a color filter to blur/bloom only selected colors? Very cool. Thanks for sharing

:slight_smile: We always see the same reflection textures on the teapots :smiley:

Do you just add this script to camera ? and threshold to camera properties ?

I canā€™t post the .blend because itā€™s a WIP :stuck_out_tongue:

We always see the same reflection textures on the teapots

Itā€™s a default, glossy Teapots are sexy.

Do you just add this script to camera ? and threshold to camera properties ?

Yes ^^

I think you only must select this filter in a 2Dfilter logicbrick in the camera and add the property.

Wow looks great, is there anyway to smooth/round off the glow? Looks very pixelated around the edges otherwise.

Keep up the good work.

I first did this a few months ago

Really nice!
Great work.

Looks amazing! Can I use the filter in my game?

Of course :slight_smile:

Nice filter but I agree with @Thatimster that if there is a way to smooth the samples it would look even better but from a distance it is definitely perfect. [URL="/u/Thatimster

To smooth increase the SAMPLES variable. But that is going to affect FPS really bad. I need to know if is there a faster way of blurring thingsā€¦