• Advertisement
Sign in to follow this  

Calculate average luminance of image with mips

This topic is 1840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)?

 

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement