Shader goodness: Bloom!

In the last post I talked about lighting, this time it's shadersand more specifically bloom. I must say I like the effect when it's used subtly as a mood enhancement and dislike it in it's quite common burn-your-eyes-out -form..

For the platformer game I'm planning to use the effect for a nice and quiet dreamlike feel, although I'm still not sure what kind of game it will be (except that it's a 4-way scrolling platformer!).. And as I often do, I find myself getting carried away doing all sorts of graphical effects (lighting, shaders) when I don't even have the basic game mechanics in place! Can't help it though, I must have some eye candy going on to keep myself motivated in a project. *shrugs*

So I coded a quick & dirty shader support to the engine, and today I've been trying to get the bloom working. And now it does. :) I'm still not done with it, needs some tweaking – and that's somewhat impossible right now since I have no final assets for the game yet! Everything you see in those screens is temporary and/or random. For anyone interested, here's some technical details on the subject.

I based the implementation on the GLSL bloom shaders from Funguloids, which in turn are modified from Ogre sample shaders. I'm still a beginner with the shader programming as I may have mentioned, so having anything to work from was invaluable. I tweaked the shaders to get the subtle look I was aiming for.

I'm using two small render textures (which are FBOs, no support for Pbuffers yet – and I think I'll have to do those at some point, as my laptop doesn't support FBOs), 128×128 in dimension and one bigger 512×512 RT. I render the scene normally to the bigger RT. The blurring is then done in two passes: first the scene RT gets rendered to 128×128 RT #1 using a horizontal blur shader (it also does some luminance stuff to have the bright parts more bright and dim parts more dim). Then RT #1 gets rendered to RT #2, this time with a vertical blur shader. Finally the RT #2 contents are blended additively over a normal 1:1 render of the scene. It needs quite a lot of tweaking, but I think it looks quite nice now.

In another news, my thesis is now almost complete! ^^