glsl bloom shader

I’m currently working on making an computer game and I’ve searched the whole internet for an glsl bloom shader that works on ATI cards. Found nothing, so I had to make my own one. Here it is. Have fun.

uniform sampler2D bgl_RenderedTexture;

void main()
   vec4 sum = vec4(0);
   vec2 texcoord = vec2(gl_TexCoord[0]);
   int j;
   int i;

   for( i= -4 ;i < 4; i++)
        for (j = -3; j < 3; j++)
            sum += texture2D(bgl_RenderedTexture, texcoord + vec2(j, i)*0.004) * 0.25;
       if (texture2D(bgl_RenderedTexture, texcoord).r < 0.3)
       gl_FragColor = sum*sum*0.012 + texture2D(bgl_RenderedTexture, texcoord);
        if (texture2D(bgl_RenderedTexture, texcoord).r < 0.5)
            gl_FragColor = sum*sum*0.009 + texture2D(bgl_RenderedTexture, texcoord);
            gl_FragColor = sum*sum*0.0075 + texture2D(bgl_RenderedTexture, texcoord);
About these ads

13 thoughts on “glsl bloom shader”

  1. YESSS! Thanks a bundle! I had everything in my HDR pipeline working (hi-pass and such) except blooming of highlight values! This did the trick!

  2. Very nice shader
    i use this code to understand the power of glsl code and test it with DELTA3D OSG (prerender test)
    good job
    best regards

  3. Hello…I’m new in GLSL. I tried to place your code in my fragment shader, but I don’t know what I have to write in the main opengl file. Can you help me?

  4. Hi ! Nice ! and thanks for this piece of code. I’m a beginner and have a question.
    Could you confirm that we need to render the scene to a textured quad in front of screen and using this shader for only for this “scene quad” ?
    Also, I only see a fragment shader code but no vertex shader. Is it possible to only bind a fragment shader without vertex shader ?
    Thanks in advance for your answer.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s