Gaussian blur alternative for bloom effects

Started by
11 comments, last by l0calh05t 5 years ago

Perusing various articles on different blur algorithms for a bloom step, they all seem to regard a gaussian blur as the convolution of choice. However, after putting it to the test with a large array of conditions, I came to the conclusion that a gaussian blur isn't as visually appealing as one would expect, not even taking artifacts incurred by cheap approximations into account. No matter how large a kernel and standard deviation I use, the bloom cuts off way too abruptly in a circle around bright centers.

By artificially deviating from a standard gaussian curve and adding more weight to the center of a kernel without reducing the tail too much, I achieve results that I find to be more pleasing and in line with what I expect bloom to look like. Now, arbitrarily tuning the weights with no physical or mathematical basis isn't exactly ideal, so I am wondering if there is an appropriate alternative to the good old bell curve for this purpose.

Advertisement

I've found it really depends on how "physically based" the range of lighting values in your scene is. If you have a very large dynamic range, then a gaussian with a very thin/tallpeak and a very weak but very long tail is important. For scenes that are closer to traditional LDR ranges, then a more typical bell curve shape suits :|

For artistic results, you can also do some directional blurs that aren't part of a separable-convolution. e.g. if you do "source->horizontal + source->vertical" instead of "source->horizontal->vertical" then you get a + shape instead of a circular shape. Adding some of these streaks in can help to approximate the phenomenon of a real eye/eye-lashes, or lens effects, or sensor overload effects (e.g. that massive vertical blue streak when a cheap digital camera is exposed to something too bright).

To go more hardcore though, you could look into how light diffracts within the eye. I think I remember seeing a forum member, years ago, posting a simulation of this :D Or, for cameras, there's approaches such as this to accurately reproduce some of the distortions that occur in the "bloom" part of the capture process - http://resources.mpi-inf.mpg.de/lensflareRendering/pdf/flare.pdf

[edit] Also, all old LDR blooms used a threshold value, but IMHO it should be discarded from modern renderers -- there's no mechanism where a material can subtract a constant level of brightness. Adding a multiplying/attenuating light make sense, but subtracting/thresholding doesn't.

Left-right-up-down filtering with IIR filters can approximate Gaussian filters with a very long (full image) tail very well. IIRC, Microsoft Research had a paper on how to do this efficiently on GPUs a few years ago.

EDIT: Found it: GPU-Efficient Recursive Filtering and Summed-Area Tables by Nehab et al.: http://hhoppe.com/recursive.pdf 

The abrupt circle cutoff is probably exactly due to the cheap approximations. A true Gaussian filter has an infinite support

Quote

For artistic results, you can also do somedirectional blurs 

 

48 minutes ago, l0calh05t said:

The abrupt circle cutoff is probably exactly due to the cheap approximations. A true Gaussian filter has an infinite support

Distant contributions quickly become negligible with anything but screen-wide blurs, and you have yourself a myopia-simulator by then.

It's not strictly speaking abrupt, but it's obvious that you are looking at a moderately concentrated disk, whereas real bright lights seen by your eyes tend to subtlety wash out a better part of your entire field of view and only bleed strongly within a degree of the light source.

53 minutes ago, silikone said:

Distant contributions quickly become negligible with anything but screen-wide blurs

Are you sure about the "negligible" part? Real HDR values can be many orders of magnitude apart, making what is negligible in LDR significant.

17 hours ago, l0calh05t said:

Are you sure about the "negligible" part? Real HDR values can be many orders of magnitude apart, making what is negligible in LDR significant.

Even at max FP16 values of ~65K, a gaussian kernel with a sigma of 1 modulates such a value to levels below the standard RGB range at any pixel radius consisting of two digits.

Of course, that's not a very blurry kernel (and you probably wouldn't want to use full-res pixels), but the higher you go, the less energy is concentrated near the center of a kernel, weakening the bleeding glow effect seen immediately around bright objects.

In essence, you want to retain both the soft round shape of a high-radius kernel and the high peak of a low-radius kernel.

Here's a stock photo that demonstrates a mixture of soft and hard glows.

flashing-lamp-bulb-light-glowing-incande

One distribution you could look into that might match your expectations better is the Cauchy distribution (https://en.wikipedia.org/wiki/Cauchy_distribution) it has a sharp peak and a very wide, low intensity tail. As the Gaussian is non-physical anyway, there's nothing wrong with trying different distributions.

2 hours ago, silikone said:

Even at max FP16 values of ~65K, a gaussian kernel with a sigma of 1 modulates such a value to levels below the standard RGB range at any pixel radius consisting of two digits.

One more thought: are you correctly applying gamma or outputting the clamped result of the convolution as an SDR image as-is?

Just now, l0calh05t said:

One distribution you could look into that might match your expectations better is the Cauchy distribution (https://en.wikipedia.org/wiki/Cauchy_distribution) it has a sharp peak and a very wide, low intensity tail. As the Gaussian is non-physical anyway, there's nothing wrong with trying different distributions.

One more thought: are you correctly applying gamma or outputting the clamped result of the convolution as an SDR image as-is?

Thanks, that seems to be a candidate for what I was looking for. I don't mind non-physical models as long as they are backed up by well-established maths. I am applying sRGB gamma correction, for the record.

This topic is closed to new replies.

Advertisement