Eye Adaption

  • brussell
  • Topic Author
More
6 years 2 months ago - 5 years 1 month ago #1 by brussell Eye Adaption was created by brussell
Description:
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:
Warning: Spoiler!
Last edit: 5 years 1 month ago by brussell.
The following user(s) said Thank You: Marty McFly, Insomnia, Martigen, DeMondo, luluco250, Qsimil, andrew, MakeNX, Numity, Ryukou36 and 11 other people also said thanks.

Please Log in or Create an account to join the conversation.

  • Marty McFly
More
6 years 2 months ago #2 by Marty McFly Replied by Marty McFly on topic brussells humble shaders: Adaption
Interesting. To simulate adaptation before tonemapping (instead of untonemapping and retonemapping, try to protect white tones by reducing the darkening for those pixels. That'll retain most of the image fidelity.
The following user(s) said Thank You: brussell

Please Log in or Create an account to join the conversation.

  • kaicooper
More
6 years 2 months ago #3 by kaicooper Replied by kaicooper on topic brussells humble shaders: Adaption
wow thats somthing..perfect

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 2 months ago #4 by brussell Replied by brussell on topic brussells humble shaders: Adaption
Changelog 30.01.2018:
-added parameters for black and white protection
-fixed dynamic adaption calculations
-adaption speed now (almost) fps independent
-some code optimisations
The following user(s) said Thank You: Qsimil

Please Log in or Create an account to join the conversation.

  • Insomnia
More
6 years 2 months ago #5 by Insomnia Replied by Insomnia on topic brussells humble shaders: Adaption
I have to say I really, really like this shader. :) Thanks for sharing!

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 2 months ago #6 by brussell Replied by brussell on topic brussells humble shaders: Adaption
Changelog 08.02.2018:
-simplified adaption calculation
-added saturation parameters

Please Log in or Create an account to join the conversation.

  • Martigen
More
6 years 2 months ago - 6 years 2 months ago #7 by Martigen Replied by Martigen on topic brussells humble shaders: Adaption

brussell wrote: Changelog 08.02.2018:
-simplified adaption calculation
-added saturation parameters

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:
technique LightAdaptionRussel

Thanks :)
Last edit: 6 years 2 months ago by Martigen.

Please Log in or Create an account to join the conversation.

  • Rudy102
More
6 years 2 months ago #8 by Rudy102 Replied by Rudy102 on topic brussells humble shaders: Adaption
Thanks a lot. It's a really useful shader. One question, any chances for version with UI ?

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 2 months ago #9 by brussell Replied by brussell on topic brussells humble shaders: Adaption

Rudy102 wrote: Thanks a lot. It's a really useful shader. One question, any chances for version with UI ?

Yes. Soon. :)

btw:
Changelog 14.02.2018:
-simpler, more efficient code, less parameters
-better saturation calculation
-toggable brightening and darkening
The following user(s) said Thank You: Rudy102

Please Log in or Create an account to join the conversation.

  • Rudy102
More
6 years 1 month ago #10 by Rudy102 Replied by Rudy102 on topic brussells humble shaders: Adaption
What a nice update, thank you kindly :)

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 1 month ago - 6 years 1 month ago #11 by brussell Replied by brussell on topic brussells humble shaders: Adaption
I've added the GUI-version to the initial post. I will also try to add it to the official shader repository soon.
Last edit: 6 years 1 month ago by brussell.
The following user(s) said Thank You: GP-Unity

Please Log in or Create an account to join the conversation.

  • moriz1
More
6 years 1 month ago #12 by moriz1 Replied by moriz1 on topic brussells humble shaders: Adaption
one quick thing:

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
More
6 years 1 month ago #13 by crosire Replied by crosire on topic brussells humble shaders: Adaption
Nope. It's correct. It works by using ReShade's mipmap generation to do the averaging and then simply samples the result from the lowest mipmap.
The following user(s) said Thank You: brussell

Please Log in or Create an account to join the conversation.

  • moriz1
More
6 years 1 month ago - 6 years 1 month ago #14 by moriz1 Replied by moriz1 on topic brussells humble shaders: Adaption
if that's the case, shouldn't the calculated luma value be the same every time you hit reload? with my test scene (which is a completely static scene), this luma value fluctuates every time i reload.
Last edit: 6 years 1 month ago by moriz1.

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 1 month ago #15 by brussell Replied by brussell on topic brussells humble shaders: Adaption
I can't reproduce this behavior. And even if the first frame after a reload somehow has a luma of 0 or 1, it should settle after a few seconds (depending on AdaptionSpeed).

Please Log in or Create an account to join the conversation.

  • moriz1
More
6 years 1 month ago - 6 years 1 month ago #16 by moriz1 Replied by moriz1 on topic brussells humble shaders: Adaption
my mistake. apparently i didn't set the mipmap level correctly (i was trying out the sampling algorithm in a different shader), so it must be sampling that isn't actually a 1x1 texture.

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;
}
Last edit: 6 years 1 month ago by moriz1.

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
6 years 1 month ago - 6 years 1 month ago #17 by brussell Replied by brussell on topic brussells humble shaders: Adaption

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);
,something like 1.09 gets displayed.

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.
Last edit: 6 years 1 month ago by brussell.

Please Log in or Create an account to join the conversation.

  • PureEvilWindom
More
5 years 10 months ago #18 by PureEvilWindom Replied by PureEvilWindom on topic Eye Adaption
can this effect combined with vignette ? so if you face bright light you simulate human eyes that half closed to reduce light.

Please Log in or Create an account to join the conversation.

  • brussell
  • Topic Author
More
5 years 10 months ago #19 by brussell Replied by brussell on topic Eye Adaption

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.
The following user(s) said Thank You: PureEvilWindom, Meddy

Please Log in or Create an account to join the conversation.

  • Chavolatra
More
5 years 10 months ago #20 by Chavolatra Replied by Chavolatra on topic Eye Adaption
OMG, it is vey nice =)

post this fast

Please Log in or Create an account to join the conversation.

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.