Auto-sensing Brightness

In a scene, different area usually has different luminance, it would be best use suitable brightness apart for various areas. For example, when you look at a window, lower brightness; and for a corner, heighten brightness. To achieve Auto-sensing Brightness, you need:

1. Evaluating the luminance of current frame image

We can down scale image step by step, finally get a 1x1 image. So the final pixel is the approximate luminance.

A example flow path:

first use a none shader Post to copy current frame image to a 128 x 128 texture image:

then use the stretch_copy.fx shader to down scale the 128 size image to 32 x 32 image, then to 8 x 8, then 2 x 2, 1x1:

2. Adjust brightness by the luminance

use the expose.fx shader to adjust brightnesss.


The brightness is sensed now, but it's changing is instantaneous. By experience in daily life, the human visual system does not adjust instantly for changing light conditions. To simulate this delayed behavior, we can introduce another 1x1 texture (adapted lum) as the input luminance image of expose.fx shader. Then use the calc_adapted_lum.fx shader to calculate the adapted lum. The calc_adapted_lum.fx shader accept two luminance images and output to adapted lum. It simulate delayed effect by closing the gap between adapted luminance and current luminance by 2% every frame, based on a 30 fps rate.