Page 1 of 2

[HLSL CODE] Dawn/Dusk independent effect

Posted: 26 Aug 2014, 01:28
by kingeric1992
This is a rather simple code that utilize ENightDayFactor. Currently, it still cannot tell whether it is dawn or dusk since they have same ENightDayFactor value.

here is original Day-Night separation code:

Code: Select all

p = lerp(p_Night, p_Day, EnightDayFactor);
Adding Dawn/Dusk specified value

Code: Select all

//p_DD as Dawn/Dusk value
p_ND = lerp(p_Night, p_Day, EnightDayFactor);
P       = lerp(p_DD, p_ND, (2 * abs(ENightDayFactor - 0.5)));
Finally, with Ext-Int separation

Code: Select all

p_ND = lerp(p_Night, p_Day, EnightDayFactor);
P_E   = lerp(p_DD, p_ND, (2 * abs(ENightDayFactor - 0.5)));
P       = lerp(p_E, p_I, EInteriorFactor);
It requires DetectorOldVersion=false in enbseries.ini

the code is based on observation on N-Dfactor
Image

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 26 Aug 2014, 16:36
by number6
What is p_RS? Thanks

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 26 Aug 2014, 16:56
by kingeric1992
I'll update this topic soon with new time of day parameter.

number6
I mean sunrise/sunset specified value.
I suppose there are better way to do this with new update.

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 26 Aug 2014, 20:55
by --JawZ--
I've been tinkering myself with the "middle" value, but ultimately it just ended up as an intensifier option during sunsets and sunrises as well as a mild intensity increase at night and day, at best.
I couldn't produce anything that did not affect day and night to some extent.

Is it the same here too perhaps? From just glancing the code here it seems that it would behave similar to the experiments I did.

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 04:44
by kingeric1992
I hope not.
I've test it with pure black & white(Day and Night as white, dawn and dusk as black), which only affect during sunset and sunrise.

To my understanding, ENighyDayFactor returns 1 between sunrise & sunset; 0 from (sunset + sunset duration) to (sunrise - sunrise duration) if DetectorOldVersion=false in enbseries.ini.
So, sunrise/sunset value will not interpolating with Day/Night values during day time or night time.

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 09:21
by --JawZ--

Code: Select all

float Brightness_ND = lerp(0.0, 0.0, ENightDayFactor);
float Brightness_E  = lerp(50.0, Brightness_ND, (2 * abs(ENightDayFactor - 0.5)));
float Brightness_I  = lerp(50.0, Brightness_ND, (2 * abs(ENightDayFactor - 0.5)));
float Brightness    = lerp(Brightness_E, Brightness_I, EInteriorFactor);

color.xyz*=Brightness;
With the above code setup it does not function at absolute 1.0 sunset or sunrise but close around it 0.01, 0.99.
Maybe it's morning drowsiness, but I can't see how I did your code wrong based on the examples you gave?


And just in case here are the TOD and ND Detector settings;

Code: Select all

[TIMEOFDAY] // Using similar values as used in Skyrim's default climate
Enable=true
DawnDuration=4.0
SunriseTime=7.5
DayTime=12.0
SunsetTime=18.5
DuskDuration=4.0
NightTime=0.0

[NIGHTDAY] // Default ENBSeries values
DetectorOldVersion=false
DetectorDefaultDay=false
DetectorLevelDay=0.7
DetectorLevelNight=0.15
DetectorLevelCurve=1.0

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 10:08
by kingeric1992
what do you mean by
does not function at absolute 1.0 sunset or sunrise but close around it 0.01, 0.99.
?

according to your func, it should return color black(brightness = 0) during daytime and night, and brightness = 50 at dawn and dusk.
have you check Night-Day factor in statistics?

PS. ENightDayFactor will lag if game timescale is too fast. (I saw it change a little before stabilize after opening console)

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 11:12
by --JawZ--
At sunrise and sunset (Hour 7.5 or 18.5) when the Sunset or Sunrise factor is at 1.0 it uses the DN value of 0.0 instead of the RS value.
And when the Sunrise or Sunset Factor value is at 0.99 and the Night or Day Factor value is at 0.01 it uses the RS value of 50 and the DN value of 0.0.
When it's absolute Sunset the supposed Sunset value doesn't do anything.

I wrote it down wrong before, sorry about that.

The timescale is not the problem as it alters smoothly along with the factor change.


Here are some pics if you like some in game data from the statistics section.

Game hour 12.00 = ND value
Image
enb 2014_08_27 12_38_55_32 by Anders "JawZ" Wedin, on Flickr

Game hour 7.5 = ND value
Image
enb 2014_08_27 12_39_14_14 by Anders "JawZ" Wedin, on Flickr

Game hour 7.45 = RS value with ND value
Image
enb 2014_08_27 12_39_30_88 by Anders "JawZ" Wedin, on Flickr

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 12:25
by kingeric1992
Still, I not sure what you meant by "absolute Sunset"
But the thing that might have confusion here is the term"sunrise" and "sunset"

This is what I think how ENightDayFactor behave
Image
so by design, it is suppose to ignore sunset/sunrise value between 7.5~18.5 & 22.5~3.5 with your TOD setting.

Re: [HLSL CODE] Sunrise/Sunset Separation

Posted: 27 Aug 2014, 15:08
by prod80
Just wrote this out of the top of my head, not tested but should work...

Code: Select all

#define SUNRISESET			0.5	//Where in ENightDayFactor is Sunrise/Set event
#define SUNRISESET_DURATION	0.1	//Total duration of the event

#define COLOR_NIGHT			float3(0, 0, 0)
#define COLOR_SUNRISESET	float3(1, 0, 0)
#define COLOR_DAY			float3(1, 1, 1)

//IF NIGHT
if (ENightDayFactor < SUNRISESET - 0.5 * SUNRISESET_DURATION)
	color.rgb	= COLOR_NIGHT;

//TRANSITION NIGHT - SUNRISE/SUNSET
else if (ENightDayFactor >= SUNRISESET - 0.5 * SUNRISESET_DURATION && ENightDayFactor < SUNRISESET)
	color.rgb	= lerp( COLOR_NIGHT, COLOR_SUNRISESET, smoothstep( SUNRISESET - 0.5 * SUNRISESET_DURATION, SUNRISESET, ENightDayFactor ));

//TRANSITION SUNRISE/SUNSET - DAY
else if (ENightDayFactor >= SUNRISESET && ENightDayFactor <= SUNRISESET + 0.5 * SUNRISESET_DURATION)
	color.rgb	= lerp( COLOR_SUNRISESET, COLOR_DAY, smoothstep( SUNRISESET, SUNRISESET + 0.5 * SUNRISESET_DURATION, ENightDayFactor ));

//IF DAY
else if (ENightDayFactor > SUNRISESET + 0.5 * SUNRISESET_DURATION)
	color.rgb	= COLOR_DAY;
But this will assume ENightDayFactor is tied to TIMEOFDAY [Min/Max values, not other?], which I think it is not. I believe ENB is using sun position to determine what to do, not game time. Anyway if TOD is actually linked to ENightDayFactor you need to set the ranges correctly so that the above code takes effect correctly, meaning exactly the same.

I didn't have much success to practically implementing this, too many variables try to play nice together. Its a hassle, I don't think worth it.

Edits: typo's in code :P