Sign in to follow this  
grunt123

blooming effect without shader

Recommended Posts

grunt123    280
I'm trying to implement blooming effect without shader. I can grab backbuffer and render only high-color intensity area to offscreen buffer. But, i'm a bit confused about blurring this texture. People usually say that you blur it horizontally and then vertically. Could anyone explain how this is done? (without shader) thanks in advance

Share this post


Link to post
Share on other sites
Sneftel    1788
Well, you could simply render the same quad several times with alpha blending, offset each time. Why are you so averse to using shaders, though?

Share this post


Link to post
Share on other sites
EternalNewbie    207
Try looking at
Frame Buffer Postprocessing Effects in DOUBLE-S.T.E.A.L for an explanation on hhow to apply bloom.

The way you perform a blur is by applying a convolution. This involves for each pixel\texel apply a kernel which sums neighbouring pixel with a weight. The simplest convolution is a box blur which takes all neighbouring pixel and averages them. Here the kernel might be a 3x3 where each weight 1/9th.
As the kernel uniform(?) and applying a 2d kernel more expensive than applying two 1d kernel, we can optimse by applying two 1d kernels.

First we apply a 3x1 kernel horizontally then we apply 1x3 kernel vertically.


float hKernel[3] = {0.33f, 0.33f,0.33f};
float vKernel[3] = {0.33f, 0.33f,0.33f};

//Horizontal Blur
for(int y = 0; y < height; y++){
for(int x = 1; x < width - 1); x++){
tmp = hKernel[0] * Buf[(y * width) + x - 1];
tmp += hKernel[1] * Buf[(y * width) + x];
tmp += hKernel[2] * Buf[(y * width) + x + 1];
tmpBuf[(y * width) + x) = tmp;
}
}
//Vertical Blur
for(int y = 1; y < height - 1; y++){
for(int x = 0; x < width); x++){
tmp = vKernel[0] * tmpBuf[((y - 1)* width) + x];
tmp += vKernel[1] * tmpBuf[(y * width) + x];
tmp += vKernel[2] * tmpBuf[((y - 1) * width) + x];
tmpBuf[(y * width) + x) = tmp;
}
}





Thats off the top of my head but is roughly right. Actually the above wont work perfectly as there are details missing (like handling edge condition).
But with with a little research you should be able to fill in the blanks.
Also the above show a simple box blur, but are other blur techniques which may be better.

(Edit) Fixed your link. <3 mittens

[Edited by - mittens on July 12, 2007 8:30:27 AM]

Share this post


Link to post
Share on other sites
remigius    1172
Another option would be to decrease the size of the overlay texture and take advantage of the limitations of bilinear texture filtering to blur the image (as described over here). Sneftel's right though, shaders can make this easier to tweak, better looking and consistent across graphics cards. So if you don't have any specific reasons not to use shaders, I'd use 'em :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this