Adaptation speed - percents per frame, if playing at 30FPS.
Default is 0.02 (2% each 130s).
If our scene is really dark (or really bright), we might not want to
stretch its contrast to the full range.
limitMinimum=0, limitMaximum=1 is the same as not applying the effect at all.
limitMinimum=1, limitMaximum=0 is always stretching colors to full range.
The limit on the minimum luminance (0...1) - we won't go above this.
The limit on the maximum luminance (0...1) - we won't go below this.
To maintain adaptation levels over time, we need two 1x1 render textures
and ping-pong between them.
Computes scene luminance (grayscale) image
Reduces size of the image by 2x2, while computing maximumminimum values.
By repeatedly applying this shader, we reduce the initial luminance image
to 1x1 image with minimummaximum luminances found.
Adaptation shader - gradually "adapts" minimummaximum luminances,
based on currently adapted 1x1 image and the actual 1x1 image of the current scene.
Final pass - stretches the color values of the original scene, based on currently
adpated minimummaximum values.
Disable if we don't support image effects
Apply the filter
Blit to smaller RT and convert to luminance on the way
const int TEMP_RATIO = 1; 4x4 smaller
Repeatedly reduce this image in size, computing minmax luminance values
In the end we'll have 1x1 image with minmax luminances found.
const int FINAL_SIZE = 1;
const int REDUCE_RATIO = 2; our shader does 2x2 reduction
Release old src temporary, and make new temporary the source
Update viewer's adaptation level
Apply contrast strech to the original scene, using currently adapted parameters
Helper function to do gradual adaptation to minmax luminances
Adaptation speed is expressed in percentsframe, based on 30FPS.
Calculate the adaptation lerp, based on current FPS.
clear destination RT so its contents don't need to be restored