How to do a Quick, Dirty bloom effect FAST!

Member
Posts: 227
Joined: 2008.08
Post: #1
I am trying to add a bloom effect by copying the back buffer to a texture, apply a scale and bias to make it grayscale, and downsample it to make it pixelated. However there are no examples of this on the 'net, any better ways (not using fbos or pbos or pbuffers), or examples of how to do this?
Quote this message in a reply
Member
Posts: 45
Joined: 2008.04
Post: #2
You could render the scene (with exaggerated lighting if necessary) to a small viewport (say 64x64), copy that to a texture, then draw scaled using linear filtering over the top of your full sized scene using additive blending.

The minus is the need to render your scene twice, but pluses are that a small texture is faster to copy and you don't have to do anything 'clever' in terms of downsampling or blurring.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #3
Any way I can do that on another thread?
Any examples of this?
I am trying to minimize cpu calculations and transfers.
Quote this message in a reply
Member
Posts: 45
Joined: 2008.04
Post: #4
Maybe try a variation of http://nehe.gamedev.net/data/lessons/les...?lesson=36

But if you want to minimize cpu calcs & transfers, then FBOs and shaders are the way to go imho.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #5
None of those will work, Im trying to go without extensions for now.
I get a white screen with glCopyTexSubImage2d, I am allocating memory but it refuses to work. I also looked at the Ocean demo, but that does hideous glReadBuffer ops.

My code later ( as I've been doing this whole thread on my iTouch)
Quote this message in a reply
⌘-R in Chief
Posts: 1,254
Joined: 2002.05
Post: #6
In regards to the original post... no idea. But in response to the reply... You could just render it once, scale it down into a new texture, and scale that back up. I'd imagine it'd be a lot faster than rendering twice. The results would look different, but probably not significantly?
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #7
Yes but glCopyTexSubImage isn't being friendly, but I cant show the code until Saturday or later.
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #8
I managed to get it working with an example at zavie.free.fr
However now i get a problem where my pixels of the covering image aren't lining up to my screen:
Code:
#define Effects_bloomTextureBufferSize 128
.....
glLoadIdentity();
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_CULL_FACE);

        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glOrtho(oe.screen.width,0,oe.screen.height,0,0,1);
        glMatrixMode(GL_MODELVIEW);

        glColor4f(1,1,1,0.5);

        glBindTexture(GL_TEXTURE_2D,bloomTexture);

        static float center[2]={oe.screen.width/2,oe.screen.height/2};
        glTranslatef(center[0],center[1],0);
        glScalef(1,-1,1);
        glBegin(GL_QUADS);
            glTexCoord2f(1,1);
            glVertex2f(-center[0],center[1]);
            glTexCoord2f(1,0);
            glVertex2f(-center[0],-center[1]);
            glTexCoord2f(0,0);
            glVertex2f(center[0],-center[1]);
            glTexCoord2f(0,1);
            glVertex2f(center[0],center[1]);
        glEnd();

        glColor4f(1,1,1,1);

        glMatrixMode(GL_PROJECTION);
        glPopMatrix();
        glMatrixMode(GL_MODELVIEW);

        glEnable(GL_CULL_FACE);
        glEnable(GL_DEPTH_TEST);
I figure this is because my rectangle is larger than my viewport of 800 x 500
Edit: No I still get the problem with a viewport of 512 x 512 and 128 x 128
Quote this message in a reply
Member
Posts: 59
Joined: 2007.12
Post: #9
There was a tutorial once that explained how to do this. If you would like to search for it, the article was called "Real-Time "TRON 2.0" Glow For Low-Spec Hardware". It's pretty fast, works without any extensions and you can leave out different parts such as the multiplication of the source image or the blur to make it faster.

BTW, why don't you want to use any FBOs?
Quote this message in a reply
Member
Posts: 260
Joined: 2005.05
Post: #10
_ibd_ Wrote:There was a tutorial once that explained how to do this. If you would like to search for it, the article was called "Real-Time "TRON 2.0" Glow For Low-Spec Hardware". It's pretty fast, works without any extensions and you can leave out different parts such as the multiplication of the source image or the blur to make it faster.
I searched for it but found only dead links.
Quote:BTW, why don't you want to use any FBOs?
No matter what the reason is, glCopyTexSubImage is an alternative. It is not as fast as using FBOs, but it is the best choice I know if you must work without FBOs. But you will also need to do (fake) some degree of filtering. Just using a low-res texture can't be enough.

I did a halfway faked glow. I tried doing it the "real" way until I found that the GMA GPU can't do FP buffers. Then I rendered the scene with an offset to put the low ranges under 0, and filtered that with shaders. Worked OK, but doesn't quite fit the demands above.
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #11
Just stretching a copy over the previous frame will not work: everything will be pushed outwards toward the edges. Try it in Photoshop or GIMP, you'll see why immediately. I feel obligated to question why you're not using EXTs - fixed pipeline is dead and slow. The modern approaches are not expensive, and much easier to use. Let go of the ringside, man! Wink
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #12
Fenris Wrote:Just stretching a copy over the previous frame will not work: everything will be pushed outwards toward the edges. Try it in Photoshop or GIMP, you'll see why immediately. I feel obligated to question why you're not using EXTs - fixed pipeline is dead and slow. The modern approaches are not expensive, and much easier to use. Let go of the ringside, man! Wink

I'm targeting the low-end hardware of 10 years ago, don't ask me why. ( Laughing )
Quote this message in a reply
Member
Posts: 26
Joined: 2008.08
Post: #13
_ibd_ Wrote:There was a tutorial once that explained how to do this. If you would like to search for it, the article was called "Real-Time "TRON 2.0" Glow For Low-Spec Hardware". It's pretty fast, works without any extensions and you can leave out different parts such as the multiplication of the source image or the blur to make it faster.

Does no one know of the awesomeness that is the Internet Archive?

In other words, said article may still be read there: VERC · Real-Time "TRON 2.0" Glow For Low-Spec Hardware. (Yay Internet Archive!)
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Temple Run Magnet Effect anmetv 2 1,341 Dec 1, 2013 05:24 PM
Last Post: JustinFic
  Using blending for a text fading effect. cjcaufield 2 4,332 Jun 30, 2010 08:21 PM
Last Post: cjcaufield
  Halo-Effect in 3D OpenGL ES Bersaelor 4 5,763 Dec 17, 2009 11:54 AM
Last Post: Mark Levin
  malloc particle effect (glDrawArray) Graphic Ace 1 3,109 Mar 15, 2009 03:13 PM
Last Post: maximile
  Glow/bloom in OpenGL Jar445 8 8,407 Jan 31, 2009 07:00 PM
Last Post: arekkusu