[HLSL CODE] Dawn/Dusk independent effect

share shaders here
  • Author
  • Message
Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

[HLSL CODE] Dawn/Dusk independent effect

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
Last edited by kingeric1992 on 27 Aug 2014, 17:13, edited 1 time in total.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: [HLSL CODE] Sunrise/Sunset Separation

What is p_RS? Thanks
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Sunrise/Sunset Separation

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.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Sunrise/Sunset Separation

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.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Sunrise/Sunset Separation

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.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Sunrise/Sunset Separation

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

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Sunrise/Sunset Separation

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)
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: [HLSL CODE] Sunrise/Sunset Separation

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

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] Sunrise/Sunset Separation

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.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
*sensei*
Posts: 372
Joined: 28 Jul 2013, 23:26

Re: [HLSL CODE] Sunrise/Sunset Separation

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
Last edited by prod80 on 27 Aug 2014, 15:48, edited 4 times in total.
Post Reply