Sign in to follow this  

Question about Gaussian coefficients for bloom

This topic is 3572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Reading http://prideout.net/bloom/index.php The section about "Exploit Hardware Filtering". Looks like he just adds the weights of the two outer samples to get three from the five, with weight 1+4=5. I'm not sure I see how that is justified though mathematically. But more importantly, how are the exact sample locations calculated? He uses offset of 1.2 texels in the demo program, but I've no idea where that came from, and how to calculate offsets when I want more samples. Also, I'd like to ask if I should do MIP mapping on the FBOs being blurred. I tried glGenerateMipmapEXT after binding the brightness-thresholded image, but didn't see any improvement in the blurring. I don't know if this is because the FBO is with non-power-of-two dimensions, and how to get it working if that's the problem--or whether it's needed at all (I'm combining several min->blur->mag at various resize scales).

Share this post


Link to post
Share on other sites
Not sure about the weights or offsets, other than it seems like you want to be calculating offsets that put you in between the texels so that your bilinear filtering will give you more bang for the buck.

Mip-mapping, on the other hand, seems superfluous. You're applying a full screen texture in screen-space, right? It should always be using the top mip, otherwise your texture is way too big :). Mip-mapping is a minification filter, not a mag filter. Now, if you're using auto-mip generation to accelerate a downsample/blur operation, that's a different story, but you need to be explicit about which mip-map you're sampling from through some kind of state setting (not sure the commands in opengl). Otherwise, as you found, you should see no difference with mips generated or not, you're just throwing away some frame time.

Share this post


Link to post
Share on other sites
If I don't do the gaussian, I do see a difference between non-mipmapped and mipmapped. But it may not be worth the extra inefficiency.
The minification is between the thresholded image and the various scalings of the images to be blurred and then magnified again. My thresholded image is 1/2 in either dimensions of the original, and just linear is used on the original. The first blur is 1/2 of that, so linear would be fine, but the next is 1/4, then 1/8, so for those it does make sense to have the thresholded image mipmapped since it's so minified more. I guess it would make sense to only generate those mip levels to which it is used, but I don't know how to do that.

Share this post


Link to post
Share on other sites
Okay, here's the trick. You have a texture containing two samples tex(0) and tex(1) at positions 0 and 1, and you want to combine them with positive weights w0 and w1 ie. you want to compute w0 * tex(0) + w1 * tex(1).

So the obvious thing to do is to just point sample the texture at points 0 and 1, then do the weighted sum yourself - costs two texture lookups, a couple multiplications and an add.

The tricky way is this. Turn on bilinear filtering and sample at position w1 / (w0 + w1) and scale the result by (w0 + w1) ie. compute (w0 + w1) * tex(w1 / (w0 + w1)) This will always give you the same result as long as w0 and w1 are positive, and takes half the texture lookups. Usually w0 and w1 are constants, so this formula is just a single multiply.

Share this post


Link to post
Share on other sites

This topic is 3572 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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