Eye Adaption
- brussell
- Topic Author
This shader lightens or darkens the image depending on the average screen brightness, thus mimicking exposure adaption from cameras/eyes (hence the name).
Example Video
This shader is part of the offical reshade shaders repository.
For the latest updates visit my repository github.com/brussell1/Shaders
Changelog:
10.3.2019
-major rewrite
-better chroma preservation
-smoother color transition with less banding artifacts
-simpler, easier to understand parameters
-dedicated contols for shadows, midtones and highlights for brightening/darkening
-new parameter gives control over which screen area to consider for brightness adaption.
-fixed wrong frametime <-> adaption speed dependence
30.01.2018:
-added parameters for black and white protection
-fixed dynamic adaption calculations
-adaption speed now (almost) fps independent
-some code optimisation
08.02.2018:
-simplified adaption calculation
-added saturation parameters
14.02.2018:
-simpler, more efficient code, less parameters
-better saturation calculation
-toggable brightening and darkening
Please Log in or Create an account to join the conversation.
- Marty McFly
Please Log in or Create an account to join the conversation.
- kaicooper
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
-added parameters for black and white protection
-fixed dynamic adaption calculations
-adaption speed now (almost) fps independent
-some code optimisations
Please Log in or Create an account to join the conversation.
- Insomnia
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
-simplified adaption calculation
-added saturation parameters
Please Log in or Create an account to join the conversation.
- Martigen
Thank you brussel. Just one suggestion: please stop adding a default key and setting it enabled, this screws up profiles, and perhaps call it something more informative So for eg:brussell wrote: Changelog 08.02.2018:
-simplified adaption calculation
-added saturation parameters
technique LightAdaptionRussel
Thanks
Please Log in or Create an account to join the conversation.
- Rudy102
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
Yes. Soon.Rudy102 wrote: Thanks a lot. It's a really useful shader. One question, any chances for version with UI ?
btw:
Changelog 14.02.2018:
-simpler, more efficient code, less parameters
-better saturation calculation
-toggable brightening and darkening
Please Log in or Create an account to join the conversation.
- Rudy102
- brussell
- Topic Author
Please Log in or Create an account to join the conversation.
- moriz1
your luma averaging function isn't actually giving you an average - it is merely reporting the last luma value that the shader happens to sample. every time you reload the shader, it will give you a different luma value, even if the scene does not change in any way.
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- moriz1
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
Please Log in or Create an account to join the conversation.
- moriz1
i did however, notice that the luma value changes if i alt-tab in and out of the game window. doing this will cause the calculated luma to rise by about 0.05 in my test scene. not sure what that was about.
btw, this is the code i'm using to display the luma on screen:
float res = -0.1;
int line0[14] = { __L, __u, __m, __a, __Space, __C, __u, __r, __r, __e, __n, __t, __Colon, __Space }; //Luma Current: %d
DrawText_String(float2(100.0, 132.0), 32, 1, texcoord, line0, 14, res);
DrawText_Digit(DrawText_Shift(float2(100.0, 132.0), int2(14, 0), 32, 1), 32, 1, texcoord, 3, avglum, res);
if ( res != -0.1)
return res;
you need to include "DrawText.fxh" for this to work. this code snippet will print "Luma Current: ####" on the top left corner of the screen.
EDIT: is it a good idea to use gamma correction? i've been using:
float CalcLuma(float3 color) {
if (GammaCorrectionEnable) {
return pow((color.r*2 + color.b + color.g*3) / 6, 1/2.2);
}
return (color.r*2 + color.b + color.g*3) / 6;
}
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
moriz1 wrote: i did however, notice that the luma value changes if i alt-tab in and out of the game window. doing this will cause the calculated luma to rise by about 0.05 in my test scene. not sure what that was about.
btw, this is the code i'm using to display the luma on screen:
float res = -0.1; int line0[14] = { __L, __u, __m, __a, __Space, __C, __u, __r, __r, __e, __n, __t, __Colon, __Space }; //Luma Current: %d DrawText_String(float2(100.0, 132.0), 32, 1, texcoord, line0, 14, res); DrawText_Digit(DrawText_Shift(float2(100.0, 132.0), int2(14, 0), 32, 1), 32, 1, texcoord, 3, avglum, res); if ( res != -0.1) return res;
you need to include "DrawText.fxh" for this to work. this code snippet will print "Luma Current: ####" on the top left corner of the screen.
There seems to be a bug(?) in the DrawTextDigit function. Even if you choose a fixed value like this
DrawText_Digit(DrawText_Shift(float2(100.0, 132.0), int2(14, 0), 32, 1), 32, 1, texcoord, 3, 1, res);
EDIT: is it a good idea to use gamma correction? i've been using:
float CalcLuma(float3 color) { if (GammaCorrectionEnable) { return pow((color.r*2 + color.b + color.g*3) / 6, 1/2.2); } return (color.r*2 + color.b + color.g*3) / 6; }
No, not necessary.
Please Log in or Create an account to join the conversation.
- PureEvilWindom
Please Log in or Create an account to join the conversation.
- brussell
- Topic Author
PureEvilWindom wrote: can this effect combined with vignette ? so if you face bright light you simulate human eyes that half closed to reduce light.
Sure. How about that: i.imgur.com/fJsqNji.gifv
I've also tried to mimic some glare-through-eye lids-effect recently: i.imgur.com/ROF4BEW.gifv
If there's more resonance I will add it.
Please Log in or Create an account to join the conversation.
- Chavolatra