9
$\begingroup$

I am trying to make a glow shader using separable gaussian blurring.

I have recently been inspired by the short youtube video "computer color is broken" and I have messed with it with color interpolation and boy his suggestion is beautiful!

A big thing the video talks about is that this principal should be applied to blurring, however I am pretty confused. I don't really know what to square when and what to sqrt when when values are being added. My current theory is each texture sample for the gaussian blur gets raised by the power of two weighted with a bell curve and added to a sum like usual. At the end the sum is square rooted, but i'm not sure if that is correct. Could someone please confirm? Would this make an appreciable difference that made things worth it?

$\endgroup$
  • $\begingroup$ No the power is 2.2 usually (read about gamma correction) $\endgroup$ – joojaa Jun 30 '16 at 11:14
  • $\begingroup$ So wait add the sum of your pixels with each one raised to the 2.2 power. And then take that sum by the 1/2.2 power? $\endgroup$ – J.Doe Jul 1 '16 at 5:09
  • $\begingroup$ Depends on how pedantic you want to be, a gamma correction of 2.2 certainly is close to srgb but if you really want to be pedantically correct google dor linear to srgb $\endgroup$ – joojaa Jul 1 '16 at 5:27
7
$\begingroup$

Yes, your theory is correct. A gamma-correct blur entails converting the input pixels to linear color space, performing the blur weighting and accumulation in that space, and then converting back to gamma space at the end.

As noted in the comments, the actual transform is not literally squaring and square-rooting, that's just an approximation (and not that good of one). For the true sRGB gamma transform, see the equations in this Wikipedia article (look down the page for the equations involving $C_\text{srgb}$ and $C_\text{linear}$).

By the way, some visual comparisons of gamma-correct and gamma-incorrect blurs can be found on this page by Elle Stone, which shows why this whole thing matters.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.