Sign in to follow this  
B_old

Calculate average luminance of image with mips

Recommended Posts

B_old    689

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
MJP    19754

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this