4
$\begingroup$

Hello I have a simple application with some bright 2d mono-color shapes I am hoping to make appear emissive with a nice glow around them. To do that I am producing multiple gaussian blurs of varying kernels and resolutions and adding them all together to create a composite glow.

I have seen many guides mention this and even mention what sizes and kernels they are using to produce their bloom however they never mention the math they used to put them all together. Right now I am assuming it was just regular additive blending.

I was wondering what tips you might have to put this glow effect together effectively as far as if I should do anything other than just adding pixels together to combine the various maps. Should I do something with the weight on certain textures used in the composite?

I am just trying to composite everything in an optimal manner.

My main concern is whether or not I should gamma correct my glow map or if that is accounted with the weights from the gaussian sampling or source material. Should I gamma correct my blurred composite before adding it to the source image?

$\endgroup$
4
$\begingroup$

In short:

You should not gamma correct your glow map. In fact, you should do everything in a linear color space. At the very end, when doing any color grading (which is the very last step), you convert the final image to the right color space. The color space include that gamma correction.

In long:

Gamma correction is a step in the encoding of images. It is usually done so that we use more bits to store the shadows and less bits to store the highlights, since we see less detail in the highlights anyway. It is also part of some color spaces. These color spaces make sure the image looks the way it is supposed to. It is the final step, often part of color grading. Just before it is send out to the display, or saved to a file. This means that everything before should be in a linear color space.

Usually things would look like this:

  1. Load textures and convert them to a linear space, so you do not double gamma correct..
  2. Render the image.
  3. Do the post effects.
  4. Convert the image to the final color space with color grading. Probably sRGB Gamma. Converting to the color space includes the gamma correcting.

    Color grading is not necessary, but optional.

When having everything at linear and doing the gamma correction at the very end, you will need a high precision for the color. Using floating point framebuffers is recommended. When using the default 8-bit framebuffer the whole way, you end up getting banding effects when gamma correcting.

This setup is not always done for games, to my knowledge, since most people will barely notice it or even care about it. In the film industry, VFX and animation, using the proper color space is more important.

When not doing it the 'right' way, the textures are not converted to linear and at the end, there is no gamma correction. Lights are supposed to have a quadratic falloff to be physically correct, but when gamma correcting it with a gamma of 2.0, it becomes a linear falloff. Lights can therefore get a linear falloff and look normal. As Noah Witherspoon pointed out, when blending and blurring you should use a linear color space, however this is not always done either.

The reasons for not doing it the 'right' way, is probably that it still looks fine. You do not need to do it this way, to end up with good graphics. It is always a matter of what the artist likes the most.

$\endgroup$
  • $\begingroup$ "The reasons for not doing it the 'right' way, is probably that it still looks fine" I suspect it's more that when graphics moved from work stations (such as SGI machines) that had, say, 10bit per channel support and perhaps did linear colour directly, to lower end devices with only 8bpc, that either doing the conversion was too expensive or simply forgotten about. $\endgroup$ – Simon F Jan 4 '18 at 14:50
2
$\begingroup$

You can get fancy with individual weighting on the blur maps if you want to adjust the look, but an equally weighted mix (and yes, it should be additive) will work too. I’m not sure about whether you need to gamma-correct the blurred image before adding it to the source one, but you should definitely get it into linear space before doing the blur; this article has some good illustrations as to why.

$\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.