Sign in to follow this  

How to? Sample Average Brightness

This topic is 3844 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

Hey everyone, I'm working on an adaptive bloom and I'm trying to figure out the average screen brightness to simulate an HDR like effect (though obviously NOT HDR). I already have the screen copied onto a texture. It has one texture level. I changed it to have multisample levels, but it does not seem to auto sample down to the 1x1 (It might be, I might be misusing it but anywho...). I called the GenerateMipLevels or whatever it is called on the IDirect3DTexture9 but that didn't seem to do anything either. I sent it in through a pixel shader as well and set it's mipping and blending sample states all to linear and then copied it onto a 1x1 surface but it isn't smoothly sampling the whole thing (even with mipmapping)... What is the right way to go about getting the texture to a 1x1 pixel tex correctly??? Thanks a ton! Stephen Timothy Cooney

Share this post


Link to post
Share on other sites
Using auto-generation of MIP maps may be a way to do this, but it'd be tricky, since you'd have to make sure the GPU uses the right MIP map. You will need to create the texture with the D3DUSAGE_AUTOGENMIPMAP flag, as described in the docs under "Automatic Generation of Mipmaps".

The least tricky version of scaling down is using point sampling and a shader which reads 4 or 16 (or more; with ps_3_0 you can sample quite a lot) pixels and averages them, then use it to scale down several times, until you get to 1x1. It's far from being optimal in terms of performance, but may be worth implementing this initially just to get things to work.

You can take advantage of bilinear filtering to do some of the averaging for you.

There may be a better way I'm not aware of.

Share this post


Link to post
Share on other sites

This topic is 3844 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.

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