Calculate average luminance of image with mips

Started by
1 comment, last by B_old 11 years, 4 months ago

What do people use nowadays to calculate the average luminance for an image (e.g. for use with tonemapping)?

Right now I'm just generating the mips for a luminance map of my scene, starting from whatever the image resolution is. Most of the time those are non-power-of-2 resolutions, so I guess the results could get a bit funky. Indeed I sometimes notice very different behavior for different resolutions that I cannot account to anything else.

One approach that I have seen is to render the luminance map into a square, power-of-2 target before generating the mips. But won't the average luminance be too high in that case, if the original image has a common 16/10 or 16/9 ratio? Could this error be minimized by using a 2/1 luminance map?

Or is it better to simply calculate the average in one step (e.g. with a GPGPU-API)?

Advertisement

If you can use compute shaders the best way to do it (IMO) is with a parallel reduction. You still have to do multiple passes, but less passes than generating a full mip chain. If you download the demo from here you can see how I do it.

Thanks, I'll take a look at that.

This topic is closed to new replies.

Advertisement