I have had a post-processing filter in my engine for a long time, but it wasn't very blurry, even though I was using a 5x5 gaussian kernel. Instead, it acted like more of a saturation boost than a glow or blur.
On Sunday I decided to track down the issue once and for all. Turns out I was only doing it half right. A while ago I experimented with the StretchRect() method, where you just take, say, a 1024x768 screen and StrectchRect() it down to a 256x256 texture, then stretch it back over the screen. I found this method wanting, due to the large amount of temporal aliasing. This sort of blinking on and off effect was very apparent in a few demos I'd seen, and even in an earlier build of Guild Wars. Not sure if they've fixed it since.
One way to reduce this while still using StretchRect(), which is nice because it's easy, would be to do 4 offset StretchRects, then blend them all together. This large decimation method definitely thrashes the texture cache, because you are minifying the texture so much that you are pulling in a lot of texels into the cache that are never used. In this example, only 1/2 of the texels horizontally and 2/3 of the texels vertically are re-used, taking bilinear filtering into account.
Instead, I was taking my screen rez, stretch recting offscreen to a front-buffer sized ( 1024x768 ) tetxure ( to work nicely with AA ), and then sampling this front-buffer-sized texture into a 1/5 size texture in width, then filtering the front buffer again, this time to a 1/5 height texture.
That 2nd filter step was the bug. Instead, I fixed it to to go from 1 x 1 -> 1/5 x 1 -> 1/5 x 1/5
Then I take 4 offset samples of the small 1/5 x 1/5 texture, threshold it, then add it back over the scene. This creates a nice glow effect without very much temporal aliasing at all.
I also cleaned up the code a bit, and added more text-tweakable parameters, like the blur kernel width. Right now I support off, 3x3, 5x5, 7x7 and 9x9. I settled on the 5x5, as it gives a nice effect with very minimal strobing.
Here are two shots of the blur without thresholding. It also shows the two camera zoom levels available - one for immersion, the other for tactics :
I'd like to do a poll of those reading this journal. Please respond in the comment section.
Do you prefer the close camera, far camera, or the option to have both?