[REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separation

share shaders here
  • Author
  • Message
Offline
*sensei*
Posts: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

[REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separation

This is the default ENB effects file (enbeffect.fx), modified to add full interior/exterior and day/night/sunrise/sunset separation for all of the ldr correction options Boris added to the in-game GUI editor.

This is intended as a modder's resource only. I recommend using a program like WinMerge to compare this enbeffect.fx file to the one that comes with ENB, so you can see how the changes were made. It does not effect appearance by itself at all, just adds the separation.

By default, these settings (brightness, contrast, gamma, black/white in/out, etc.) were all GLOBAL, meaning there was just one setting and it effected the display whether you were inside, outside, or if it was daytime or night, etc.

With these modifications you can now adjust all these same settings separately for:
  • Exterior Sunrise
  • Exterior Day
  • Exterior Night
  • Exterior Sunset
  • Interior Sunrise
  • Interior Day
  • Interior Night
  • Interior Sunset
This allows a much more powerful level of control over appearance.

To use this file simple copy the entire contents of "_ToSkyrimFolder" to your Skyrim folder AFTER installing ENB.

IMPORTANT: From the readme:
// Values for interior/exterior & day/night/sunrise/sunset separation by Phinix
// This assumes Skyrim standard climate values for sunrise/sunset time/duration.
// To calibrate properly, leave DetectorOldVersion=false in enbseries.ini and set
// the following values under the [TIMEOFDAY] section:
//
// Enable=true
// DawnDuration=4.5
// SunriseTime=7.75
// DayTime=13.0
// SunsetTime=18.25
// DuskDuration=4.5
// NightTime=1.0
The above values set the duration and peak times for sunrise and sunset to EXACTLY match Skyrim's default climate system, and will also synch the game's transitions to the curve established by this resource.

Feel free to use this in your own configurations, so long as you leave the credit line at the top intact. A mention on your page would be nice as well, and if you took the time to drop me a line to let me know it came in handy, all the better. I always enjoy checking out new ENB setups.


Download:

You can get the file "ENBSeparation" from the Miscellaneous section of the PNENB page on Skyrim Nexus.
Last edited by Phinix on 03 Aug 2015, 08:44, edited 1 time in total.

Offline
*sensei*
Posts: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

Re: [REL] Interior/Exterior and Day/Night Separation

B-umpity. :)

Offline
*sensei*
Posts: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

I've re-uploaded this resource to the PNENB page with full interior/exterior & day/night/sunrise/sunset separation.

Image

Offline
User avatar
*blah-blah-blah maniac*
Posts: 572
Joined: 23 Aug 2013, 21:59
Location: United States

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

Downloaded, thank you very much! I was trying to do this very thing with a mostly default pp2 enbeffect.fx file myself but could not get the thing to compile... probably because I'm miserable at code and repeatedly did something wrong. Many thanks!

Now, whenever I can get myself to work on my preset again I'll be set...
_________________
AMD Ryzen 5 3600 6C/12T @4.4GHz // 16GB G.Skill Ripjaws V DDR4 3600MHz // ASRock AMD Radeon 5700XT Taichi X 8GB OC+// Samsung 850 Evo 256GB and 500GB SSD // 4 TB Seagate Barracuda // Windows 10 x64
Lumen ENB
My Flickr

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

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

Very nice to see this kind of addition to the effect section. Functions as advertised :)

And just me being and feeling lazy, I did this to reduce the amount of code needed per variable;

Helper Function;

Code: Select all

// Time and Location separation for ENBSeries by Phinix
float3 DNSrSsEIFactor(float WthrTime, float3 EXTSunrise, float3 EXTDay, float3 EXTSunset, float3 EXTNight, float3 INTSunrise, float3 INTDay, float3 INTSunset, float3 INTNight)
{
///////////////////////////////////////////////////////////////////////////////////
/// This assumes Skyrim standard climate values for sunrise/sunset time/duration.
/// To calibrate properly, leave DetectorOldVersion=false in enbseries.ini and set
/// the following values under the [TIMEOFDAY] section:
///
/// 	Enable=true
/// 	DawnDuration=4.5
/// 	SunriseTime=7.75
/// 	DayTime=13.0
/// 	SunsetTime=18.25
/// 	DuskDuration=4.5
/// 	NightTime=1.0
///////////////////////////////////////////////////////////////////////////////////
  float Int = (1-EInteriorFactor);

  float NDDet      = 0;  /// Night/day detector, no interpolation.
  float IsSunrSuns = 0;  /// Set to 1 if currently sunrise or sunset.
  float SunrDet    = 0;  /// Sunrise detector.
  float SunrFade   = 0;  /// Sunrise in/out detector (0 is fade-in, 1 is fade-out).
  float SunsDet    = 0;  /// Sunset detector.
  float SunsFade   = 0;  /// Sunset in/out detector (0 is fade-in, 1 is fade-out).

  if (WthrTime >= 5.5  && WthrTime <= 10)   SunrDet = 1;     /// Calculate if currently sunrise.
  if (WthrTime >= 16   && WthrTime <= 20.5) SunsDet = 1;     /// Calculate if currently sunset.
  if (WthrTime > 7.75  && WthrTime <= 10)   SunrFade = 1;    /// Calculate if sunrise is fading out.
  if (WthrTime > 18.25 && WthrTime <= 20.5) SunsFade = 1;    /// Calculate if sunset is fading out.
  if (WthrTime >= 10   && WthrTime <= 16)   NDDet = 1;       /// Calculate if currently full day.
  if (SunrDet  == 1    || SunsDet  == 1)    IsSunrSuns = 1;  /// Calculate if currently sunrise/sunset.

  float SunrFactor = lerp((0.4444 * WthrTime) - 2.4444, (0.4 * WthrTime) - 3, SunrFade);          /// Sunrise fade factor.
  float SunsFactor = lerp((0.4444 * WthrTime) - 7.1111, (0.4444 * WthrTime) - 8.1111, SunsFade);  /// Sunset fade factor.

    return lerp( lerp( lerp( INTNight, INTDay, NDDet ), lerp( EXTNight, EXTDay, NDDet ), Int ), lerp( lerp( lerp( lerp( INTNight, INTSunrise, SunrFactor), lerp( INTSunrise, INTDay, SunrFactor), SunrFade), lerp( lerp( EXTNight, EXTSunrise, SunrFactor), lerp( EXTSunrise, EXTDay, SunrFactor), SunrFade), Int), lerp( lerp( lerp( INTDay, INTSunset, SunsFactor), lerp( INTSunset, INTNight, SunsFactor), SunsFade), lerp( lerp( EXTDay, EXTSunset, SunsFactor), lerp( EXTSunset, EXTNight, SunsFactor), SunsFade), Int), SunsDet), IsSunrSuns);
}
New per Variable Implementation;

Code: Select all

float fVariable = DNSrSsEIFactor(WeatherAndTime.w, EXTSunrise, EXTDay, EXTSunset, EXTNight, INTSunrise, INTDay, INTSunset, INTNight);  // WeatherAndTime is included because it's not present in the enbbloom.fx file
Instead of original implementation;

Code: Select all

float ECCGamma = lerp( lerp( lerp( ECCGIN, ECCGID, pnd ), lerp( ECCGN, ECCGD, pnd ), pi ), lerp( lerp( lerp( lerp( ECCGIN, ECCGISR, psrf), lerp( ECCGISR, ECCGID, psrf), psrd), lerp( lerp( ECCGN, ECCGSR, psrf), lerp( ECCGSR, ECCGD, psrf), psrd), pi), lerp( lerp( lerp( ECCGID, ECCGISS, pssf), lerp( ECCGISS, ECCGIN, pssf), pssd), lerp( lerp( ECCGD, ECCGSS, pssf), lerp( ECCGSS, ECCGN, pssf), pssd), pi), pss), psrss);

Phinix;
I'm wondering if it would be ok if I included this code snippet into a future revision of Modular Shader Library I have created, with full credits to you and a link here for users wanting more info about this particular code snippet?



EDIT;

And just because.
If you are using ELE - Lite you can use this to introduce a fake Dungeon Factor to alter Dungeons separately from the other "regular" interiors
Helper Function;

Code: Select all

// Time and Location separation for ENBSeries by Phinix, using "Hack" value to allow Dungeon separated control values.
// Only functional if using ELE - Lite or ELE - Interior Lighting!
float3 DNSrSsEIDFactor(float inReg, float WthrTime, float3 EXTSunrise, float3 EXTDay, float3 EXTSunset, float3 EXTNight, float3 INTSunrise, float3 INTDay, float3 INTSunset, float3 INTNight, float3 DUNSunrise, float3 DUNDay, float3 DUNSunset, float3 DUNNight)
{
///////////////////////////////////////////////////////////////////////////////////
/// This assumes Skyrim standard climate values for sunrise/sunset time/duration.
/// To calibrate properly, leave DetectorOldVersion=false in enbseries.ini and set
/// the following values under the [TIMEOFDAY] section:
///
/// 	Enable=true
/// 	DawnDuration=4.5
/// 	SunriseTime=7.75
/// 	DayTime=13.0
/// 	SunsetTime=18.25
/// 	DuskDuration=4.5
/// 	NightTime=1.0
///////////////////////////////////////////////////////////////////////////////////

/// Hack value used in Dungeon specific factor function
  float dunHackVal=0;
  if(inReg==1.000001) dunHackVal=1;

  float Int = (1-EInteriorFactor);

  float NDDet      = 0;  /// Night/day detector, no interpolation.
  float IsSunrSuns = 0;  /// Set to 1 if currently sunrise or sunset.
  float SunrDet    = 0;  /// Sunrise detector.
  float SunrFade   = 0;  /// Sunrise in/out detector (0 is fade-in, 1 is fade-out).
  float SunsDet    = 0;  /// Sunset detector.
  float SunsFade   = 0;  /// Sunset in/out detector (0 is fade-in, 1 is fade-out).

  if (WthrTime >= 5.5  && WthrTime <= 10)   SunrDet = 1;     /// Calculate if currently sunrise.
  if (WthrTime >= 16   && WthrTime <= 20.5) SunsDet = 1;     /// Calculate if currently sunset.
  if (WthrTime > 7.75  && WthrTime <= 10)   SunrFade = 1;    /// Calculate if sunrise is fading out.
  if (WthrTime > 18.25 && WthrTime <= 20.5) SunsFade = 1;    /// Calculate if sunset is fading out.
  if (WthrTime >= 10   && WthrTime <= 16)   NDDet = 1;       /// Calculate if currently full day.
  if (SunrDet  == 1    || SunsDet  == 1)    IsSunrSuns = 1;  /// Calculate if currently sunrise/sunset.

  float SunrFactor = lerp((0.4444 * WthrTime) - 2.4444, (0.4 * WthrTime) - 3, SunrFade);          /// Sunrise fade factor.
  float SunsFactor = lerp((0.4444 * WthrTime) - 7.1111, (0.4444 * WthrTime) - 8.1111, SunsFade);  /// Sunset fade factor.


      return lerp( lerp(lerp(lerp(INTNight, INTDay, NDDet), lerp(EXTNight, EXTDay, NDDet), Int), lerp(DUNNight, DUNDay, NDDet), dunHackVal), lerp( lerp(lerp(lerp(lerp(INTNight, INTSunrise, SunrFactor), lerp(INTSunrise, INTDay, SunrFactor), SunrFade), lerp(lerp(EXTNight, EXTSunrise, SunrFactor), lerp(EXTSunrise, EXTDay, SunrFactor), SunrFade), Int), lerp(DUNSunrise, DUNDay, NDDet), dunHackVal), lerp(lerp(lerp(lerp(INTDay, INTSunset, SunsFactor), lerp(INTSunset, INTNight, SunsFactor), SunsFade), lerp(lerp(EXTDay, EXTSunset, SunsFactor), lerp(EXTSunset, EXTNight, SunsFactor), SunsFade), Int), lerp(DUNSunset, DUNNight, NDDet), dunHackVal), SunsDet), IsSunrSuns);
}
New per Variable Implementation;

Code: Select all

float fVariablefloat = DNSrSsEIDFactor(_c3.z, WeatherAndTime.w, EXTSunrise, EXTDay, EXTSunset, EXTNight, INTSunrise, INTDay, INTSunset, INTNight, DUNSunrise, DUNDay, DUNSunset, DUNNight);  // WeatherAndTime is included because it's not present in the enbbloom.fx file

Offline
*sensei*
Posts: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

--JawZ-- wrote:I'm wondering if it would be ok if I included this code snippet into a future revision of Modular Shader Library
Sure thing. I have always appreciated the work you do and make public and have referenced your code examples numerous times in my own experimentation. ;)

Cutting down on the number of variables is probably a good idea. Something I ran into for the first time recently is the modifiable variable limit. Apparently there is a finite number of modifiable variables you can reference before the shader will fail to compile.

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

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

Hay guys,
Phinix,

not trying to steal your work here, (,,゚Д゚)
but here is a another version which I think might be more consistent to ENB's internal interpolation operation from the TOD factors in ingame statics.

the factors part was tested with debug mod by number6, but I didn't test on how exactly they were used.
I just assumed they are like: dot( factors, inputs). (≧∀≦)ゞ

Code: Select all

#define TOD_DAWN_DURATION   2
#define TOD_SUNRISE_TIME    6   
#define TOD_DAY_TIME        12
#define TOD_SUNSET_TIME     18
#define TOD_DUSK_DURATION   2
#define TOD_NIGHT_TIME      0

/*
    preprocessor to assemble parameters to save up typing.

    usage:

    Constant with uniform structure _time_exterior at the end,
    _time:      _Sr, _D, _Ss, _N
    _exterior:  _E, _I
    float3 test_color_Sr_E ={0,0,1};
    float3 test_color_D_E  ={0,1,0};
    float3 test_color_Ss_E ={1,0,0};
    float3 test_color_N_E  ={0,0,0};
    float3 test_color_Sr_I ={0,0,1};
    float3 test_color_D_I  ={0,1,0};
    float3 test_color_Ss_I ={1,0,0};
    float3 test_color_N_I  ={0,0,0};

    then to get interpolated value, just 

    TOD3(test_color)
    and voila!
    
   *** TOD3(parm) is for float3 input, TOD1(parm) is single float    
   *** input parm can not use with notations like .xyz or .rgb
*/

//for float parameter
#define TOD1(parm)    TODEI1( TODfactors(),parm##_Sr_E, parm##_D_E, parm##_Ss_E, parm##_N_E, parm##_Sr_I, parm##_D_I, parm##_Ss_I, parm##_N_I)
//for float3 parameter
#define TOD3(parm)    TODEI3( TODfactors(),parm##_Sr_E, parm##_D_E, parm##_Ss_E, parm##_N_E, parm##_Sr_I, parm##_D_I, parm##_Ss_I, parm##_N_I)

//returns (TOD factor sunrise, TOD factor day, TOD factor sunset, TOD factor night)
float4 TODfactors()
{
    float4 weight = WeatherAndTime.w ;
    weight.xy -= TOD_SUNRISE_TIME;
    weight.zw -= TOD_SUNSET_TIME;
    weight    /= float4(-TOD_DAWN_DURATION, TOD_DAY_TIME - TOD_SUNRISE_TIME, TOD_DAY_TIME - TOD_SUNSET_TIME, TOD_DUSK_DURATION); 
    weight     = saturate(weight);
    weight.yz  = sin(weight.yz * 1.57);// pi/2
    weight.xw  = 1 - weight.xw;
    return float4( weight.x*(1-weight.y), weight.y*weight.z, (1-weight.z)*weight.w, 1-weight.w*weight.x);
}


float TODEI1( float4 factors, float Sr_E, float D_E, float Ss_E, float N_E, float Sr_I, float D_I, float Ss_I, float N_I)
{
    return lerp( dot(factors, float4(Sr_E, D_E, Ss_E, N_E)), dot(factors, float4(Sr_I, D_I, Ss_I, N_I)), EInteriorFactor);
}

float3 TODEI3( float4 factors, float3 Sr_E, float3 D_E, float3 Ss_E, float3 N_E, float3 Sr_I, float3 D_I, float3 Ss_I, float3 N_I)
{
    return lerp( mul(factors, float4x3(Sr_E, D_E, Ss_E, N_E)), mul(factors, float4x3(Sr_I, D_I, Ss_I, N_I)), EInteriorFactor);
}
Also tested some preprocessor operation here, if that doesn't work out, just ignore them and use the functions straight.
ε٩(๑> ₃ <)۶з

PS, not sure the performance on calling TODfactors() every time when interpolating. might as well save the result at shader start?
_________________
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: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

Hi kingeric,

I love the idea of a function call to avoid having to type out the whole thing each use. I will definitely look into incorporating that into PNENB's implementation.

The main reason I did the interpolation as I did was to create a more defined curve. Rather than having sunrise/sunset be a percentage of day and night, based on the TOD interpolation, I wanted to set a transition start time equal to Skyrim's default, then have the values interpolate first from the current time of day cycle to the twilight value, then from completely twilight values to the next day/night cycle.

So, if it was daytime, at around 4pm I believe the values will start to blend between day and sunset. The closer you get to 7:45pm (peak sunset time) the more the sunset values will take weight, until at 7:45pm the values are 100% sunset. Then, they start fading from sunset to night the same way.

I don't know if that is the best way but it seemed most "natural" to me. If we had access to the TIMEOFDAY values from enbseries.ini from within the shader I could make an equation to calculate the trend line for interpolation dynamically based on the time values set, but as it is I have "hard coded" it to use Skyrim's time values (when sunrise actually starts in Skyrim by default, etc.) and put the note to make the changes to enbseries.ini to match.

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

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

Ahh, ok.
I knew what you are doing, which is exactly what the alternate function is doing...
I'm just trying to fit enb's internal mechanism so that ppl don't need to worry about difference in shader transition weight and enb's own calculation.

also in addition, enb's interpolation between day and sunrise/sunset is following sine curve, which is probably why you feels it start blending at 4pm.
_________________
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: 286
Joined: 20 Sep 2012, 00:20
Location: the perfect system

Re: [REL] Interior/Exterior/Day/Night/Sunrise/Sunset Separat

EDIT: I think I answered my own question. :p

So, how does the sunrise and sunset duration setting in [TIMEOFDAY] effect this? Am I correct in assuming the accuracy of the results depend on keeping these specific values?

Code: Select all

#define TOD_DAWN_DURATION   2
#define TOD_SUNRISE_TIME    6   
#define TOD_DAY_TIME        12
#define TOD_SUNSET_TIME     18
#define TOD_DUSK_DURATION   2
#define TOD_NIGHT_TIME      0
Does that not also mean we would have to set these values to match in enbseries.ini [TIMEOFDAY] section, since they are not the default values?

Thanks, BTW. This was very helpful and I learned a lot of syntax I didn't know before. :)
Post Reply