Sunday, September 7, 2008

Gauss Filter Kernel

Just found a good tutorial on how to setup a Gauss filter kernel here:

OpenGL Bloom Tutorial

The interesting part is that he shows a way on how to generate the offset values and he also mentions a trick that I use for a long time. He reduces the filter kernel size by utilizing the hardware linear filtering. So he can go down from 5 to 3 taps. I usually use bilinear filtering to go down from 9 to 4 taps or 25 to 16 taps (with non-separable filter kernels) ... you got the idea.

Eric Haines just reminded me of the fact that this is also described in ShaderX2 - Tips and Tricks on page 451. You can find the -now free- book at

http://www.gamedev.net/reference/programming/features/shaderx2/Tips_and_Tricks_with_DirectX_9.pdf

BTW: Eric Haines contacted all the authors of this book to get permission to make it "open source". I would like to thank him for this.
Check out his blog at

http://www.realtimerendering.com/blog/

2 comments:

  1. Yes, this is a good old trick, using bilinear filtering in this way. As the article discusses, for a Gaussian filter or box filter, which are separable, you can sample a 5x5 area with just 2x3 samples: sample horizontally with 3 samples per texel, then sample the resulting buffer vertically in the same weighting.

    The article's nice, but his method of computing weights is a little indirect. There's a direct formula for each cell, and in fact it's given in your (now free) ShaderX^2 Tips & Tricks book, see page 450.

    ReplyDelete
  2. LOL ... this is probably where I got the idea from. Thanks Eric ... I guess I know you :-)
    I also build non-separated filter kernels with this. Those are the ones I mention in my blog :-)

    ReplyDelete