Tell me about separable gaussian convolutions...

Sage
Posts: 1,199
Joined: 2004.10
Post: #1
I've experimented with gaussian blurs in GLSL -- they work great actually, but the performance is fairly poor on my 5200. I get about 6 or 7 fps running a 5x5 kernel on a 800x600 rect texture. I can't say I'm surprised, but hey, that's what experimenting is for.

Now, I've already done some experimenting with running the blur on a downsampled image. Say, I downsample my 800x600 screen texture to 256x256, run the blur on that, then draw it scaled back up to 800x600. This works -- and runs pretty quickly -- but I get some nasty sampling artifacts.

That said, when I run GooBall, I see a gorgeous fullscreen gaussian blur that looks as if it were something large, like 21x21 or so, running at a fast rate in 1024x768. Significantly, I don't see what appear to be the kinds of artifacts I'd expect if this were being performed the way I describe above ( with the downsampling->blur->upsample approach ).

So I googled a bit and have seen described that gaussian blurs can be "separable", and performed in two blurring passes, one horizontal, one vertical.

What I haven't seen is any good description of why this would result in an acceptable output -- it seems to me it would look horrible.

Can somebody describe it to me why it should work? I'm willing to try.
Quote this message in a reply
Member
Posts: 446
Joined: 2002.09
Post: #2
Separable blurs look just fine IMHO - perhaps not quite as soft as Gaussian but way faster to create. This Gamasutra article has a nice illustrated example.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
This paper is also worth a read-- recall that the hardware is capable of sampling more than 4 texels during a texture fetch, so you might as well take advantage of that.
Quote this message in a reply
Member
Posts: 168
Joined: 2004.10
Post: #4
TomorrowPlusX Wrote:That said, when I run GooBall, I see a gorgeous fullscreen gaussian blur that looks as if it were something large, like 21x21 or so, running at a fast rate in 1024x768. Significantly, I don't see what appear to be the kinds of artifacts I'd expect if this were being performed the way I describe above ( with the downsampling->blur->upsample approach ).

There was a thread about light bloom with Gooball screenshots being thrown around over at the Unity forums a while back:

http://forum.unity3d.com/viewtopic.php?t=1727
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #5
arekkusu Wrote:This paper is also worth a read-- recall that the hardware is capable of sampling more than 4 texels during a texture fetch, so you might as well take advantage of that.

The offset by half a pixel while downsampling seems a clever way to perform a high-quality downsampling. I'm going to look into that.

Also, I implemented a simple full 800x600 separated gaussian convolution this morning. I compared my brute-force 5x5 kernel ( 25 texture lookups per fragment ) to a 13x13 separable ( 26 lookups ) and even though the separable requires two passes, the performance was almost identical ( slow! ), but the latter looked for all the world like a real 13x13. Excellent.

I'm going to look into the high quality downsampling approach described in the PDF. Thanks, arrekusu.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #6
Whoo!

With the downsampling trick to eliminate jaggies, I've got good gaussian blurring and 30fps on my 5200!

[Image: blurry.png]

Whoo!
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #7
beautiful. Cry

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #8
I've re-implemented my Melancholy and Bloom filters to use this new code, they're faster now, and they look a hell of a lot better since I don't get downsampling artifacts anymore.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #9
Well, I did a lot of work over the weekend and integrated it into my game, with classloading for specification of filters in the .world files my game uses, and it's working great, except, it's too slow for my machine. Rasp

That said, it'll be easy enough to turn them on or off from preferences.

Here's my melancholia shader, the opposite of "bloom".

[Image: Screenshots-2006-07-17-03.png]

...
[Image: Screenshots-2006-07-17-04.png]
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
0.11fps? ouch!

Looks fantastic, though Smile
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #11
lol -- it's not that bad, it's 11.

Unplayable... though. I get about 22 to 60 depending on viewpoint without the filters attached, but ( on my 5200 ) anything that requires multiple fbo passes pretty much stomps performance. My gaussian blur effects require an averaging downsampling pass, two 1-d kernel passes, and a combination pass ( differently implemented for bloom, melancholy, etc ). This is why I'm saving for a mac book pro Rasp

Thanks for the kind words, though!
Quote this message in a reply
Jones
Unregistered
 
Post: #12
Wow that looks amazing. Blink

I love that subtle-blurred edge lighting kinda look. Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Gaussian blur g00se 0 2,321 Oct 3, 2011 12:58 PM
Last Post: g00se
  Gaussian blur, software fallback on GMA950 Fenris 11 7,028 Jul 28, 2007 05:00 PM
Last Post: OneSadCookie