iDevGames Forums
How to do a Quick, Dirty bloom effect FAST! - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: How to do a Quick, Dirty bloom effect FAST! (/thread-1406.html)



How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 23, 2009 05:31 PM

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?


How to do a Quick, Dirty bloom effect FAST! - aBabyRabbit - Apr 24, 2009 02:20 AM

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.


How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 24, 2009 03:33 AM

Any way I can do that on another thread?
Any examples of this?
I am trying to minimize cpu calculations and transfers.


How to do a Quick, Dirty bloom effect FAST! - aBabyRabbit - Apr 24, 2009 04:13 AM

Maybe try a variation of http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=36

But if you want to minimize cpu calcs & transfers, then FBOs and shaders are the way to go imho.


How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 24, 2009 12:33 PM

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)


How to do a Quick, Dirty bloom effect FAST! - SethWillits - Apr 24, 2009 12:34 PM

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?


How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 24, 2009 12:38 PM

Yes but glCopyTexSubImage isn't being friendly, but I cant show the code until Saturday or later.


How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 25, 2009 04:13 PM

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


How to do a Quick, Dirty bloom effect FAST! - _ibd_ - Apr 27, 2009 07:56 AM

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?


How to do a Quick, Dirty bloom effect FAST! - Ingemar - Apr 29, 2009 11:54 AM

_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.


How to do a Quick, Dirty bloom effect FAST! - Fenris - Apr 29, 2009 02:59 PM

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


How to do a Quick, Dirty bloom effect FAST! - Oddity007 - Apr 30, 2009 01:37 PM

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 )


How to do a Quick, Dirty bloom effect FAST! - aardvarc - May 9, 2009 09:42 AM

_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!)