i want to implement a bloom effect similar to the one described by this guy.
i do understand the basic principle of what he is doing, since it seems fairly easy to understand and to implement, but im not sure about the technical details.
seems to me, unless you have a card with an awesome fill rate, this method is rather expensive. but maybe it isn't, or i'm just not doing it right.
so this is how i would generate the bloom texture:
- i do a regular render of my scene to a texture 'SCENE'. to keep this example easy, lets say i have a square screen with 1024x1024 resolution. *without* the bloom effect, i would now simply render a screen filling quad with this texture to the backbuffer and advance the swapchain, displaying the scene on screen. at the moment, this is also the status quo for my code.
- however, now i want to generate a bloom texture based on the SCENE texture. so i go and render the SCENE screen quad to another texture BRIGHTPASS (by 'screen quad' im talking of normalized device coordinates, obviously, just something that fills the rendertarget) the size of BRIGHTPASS is only 1/64 of SCENE: 128x128. the pixelshader for this pass has to look something like this (pseudocode):
sample all texels from (x-blursize,y) to (x+blursize,y) {
if (luminance is above a certain value) //probably something like (texel.r+texel.g+texel.b > 2.4)
accumulate the contribution in color, multiplied by the gauss blur constant for that texel
}
normalize color in respect to samples taken
return color
this would yield a brightpass and a horizontal blur
- now render to yet another texture BLUR1 applying a vertical blur (size of BLUR1 128x128)
- at this point BLUR1 should contain a downscaled, brightpass filtered and blurred texture.
- repeat this process for 2 other rendertargets with the sizes 256x256, BLUR2, and 512x512 BLUR3
- render SCENE, then blend in BLUR1 to BLUR3 additively (which are all now mapped to a screen filling quad), using linear filtering or such to magnify
- drink a beer
would be nice if anyone could comment on this. dont care too much about the numbers used, they are more or less arbitrary, im more interested if the m.o. is correct. if you have got a completely different method of doing a nice bloom/glare effect that is even way more awesome than this feel free to post realism is not necessary, im more interested in speed, and, to a degree, in flexibilty considering the parameters (like the strength of the glare, scalability of the speed/quality tradeoff).
and yes, i do intend to drink a beer EVERY FRAME.
cheers,
tasche