First, Vertex Shaders calculate where the vertices are for texcoord mapping per vertex. Pretty much like to define where our canvas are.
for a full screen quad, it only execute 4 or 6 times per frame(either a quad or count as two triangle)
vpos texcoord
(-1, 1) --> (0, 0)
(-1, -1) --> (0, 1)
( 1, -1) --> (1, 1)
( 1, 1) --> (1, 0)
postpass is using full screen triangle. A huge, out of border triangle that we only use the square part in its full coverage.
vpos texcoord
(-1, 1) --> (0, 0)
(-3, -1) --> (0, 2)
( 3, 1) --> (2, 0)
and then, the texcoord of vertices will be interpolated internally for pixel shader in rasterizer stage
so back to the case, what it does here is a per-pixel operation, returning different coordinate for different pixel and not just linear interpolation, so the Vertex Shader can't do much here. Frame constants however (like "xs"), being the same value for every vertices, can be put into vertex shader because interpolation to same value only returns the same.
ENBEffect.fx and effect.txt are different to each others in many aspect, and those difference make them suit for different scenario.
the main reason you can't use enbeffect here is that it doesn't support multipass, and shaders that scrambled coord requires output from previous stage on full frame instead of just current pixel. Such as Gaussian, DoF, Artistic effects.
the only way to put it in enbeffect.fx is to put it before anything else, before any other color ops including tonemapping. but that is not recommended.
(like prod80's GIVE ME MY POISON effect)
Converting SweetFX Effects To ENB
- Author
- Message
-
Offline
- *blah-blah-blah maniac*
- Posts: 565
- Joined: 05 Apr 2014, 10:29
- Location: Taiwan
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
...Hoo-boy. That is a bit too technical for my blood; I can hear the gears grinding in my skull.kingeric1992 wrote:-snip-
So, basically, the image of the game scene is finally rendered on either a screen-size quad or a large triangle, and the effect needs the data from that quad/triangle, but that gets lost/made unusable by previous color shaders?
Anyhow, since Boris just released an update bringing time-based settings, I figured I'd try and get them working.
This is how the vertex shader looks:
Code: Select all
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VS_OUTPUT_POST VS_Draw(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
float4 pos;
pos.xyz=IN.pos.xyz;
pos.w=1.0;
OUT.pos=pos;
OUT.txcoord0.xy=IN.txcoord.xy;
//Begin FiftyTifty TimeOfDay
float fDawn = TimeOfDay1.x;
float fSunrise = TimeOfDay1.y;
float fDay = TimeOfDay1.z;
float fSunset = TimeOfDay1.w;
float fDusk = TimeOfDay2.x;
float fNight = TimeOfDay2.y;
float fDawnToSunrise = lerp(Dawn, Sunrise, DaySunriseLerp);
float fSunriseToDay = lerp(Sunrise, Day, SunriseDayLerp);
float fDayToSunset = lerp(Day, Sunset, DaySunsetLerp);
float fSunsetToDusk = lerp(Sunset, Dusk, SunsetDuskLerp);
float fDuskToNight = lerp(Dusk, Night, DuskNightLerp);
float fNightToSunrise = lerp(Night, Sunrise, NightSunriseLerp);
//End FiftyTifty TimeOfDay
return OUT;
}
What I've done, is used clamp(dot()); to calculate the lerps. But is this really the best way to get a time of day Lerp? And how do I calculate the lerp counting backwards from noon to midnight (1 -> 0)?
Here's what I've come up with, sticking as close as possible to Boston's dawn, sunrise, sunset, dusk and night hours.
Code: Select all
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
VS_OUTPUT_POST VS_Draw(VS_INPUT_POST IN)
{
VS_OUTPUT_POST OUT;
float4 pos;
pos.xyz=IN.pos.xyz;
pos.w=1.0;
OUT.pos=pos;
OUT.txcoord0.xy=IN.txcoord.xy;
//Begin FiftyTifty TimeOfDay
/*
//Calculate Lerps
//24 hours = 1440 minutes
float fDawnSunriseMin = 0.2652; //382 (6:38) minutes divided by 1440
float fDawnSunriseMax = 0.4260; //426 (7:10) minutes divided
float fDawnSunriseLerp = clamp(dot(fDawnSunriseMin, fDawnSunriseMax), 0, 1);
float fSunriseDayMin = 0.4261; //Just after sunrise
float fSunriseDayMax = 0.9999; //Want the time riiiiiight before noon
float fSunriseDayLerp = clamp(dot(fSunriseDayMin, fSunriseDayMax), 0, 1);
float fDaySunsetMin = 1.0000; //Noon = 12:00, 12 * 60 = 720. Noon @ ENightDayFactor = 1.0000, midnight = 0.0000
float fDaySunsetMax = 0.6725; //968.4 (16:14) minutes divided
float fDaySunsetLerp = clamp(dot(fDaySunsetMax, fDaySunsetMin), 0, 1);
float fSunsetDuskMin = 0.6724; //Juuust after sunset. Midnight -> Noon = Count forwards (0 -> 1), Noon -> Midnight = Count backwards (1 -> 0)
float fSunsetDuskMax = 0.2516; //362.4 (17:56 = 6:04, Counting backwards from 1.0) minutes divided
float fDaySunsetLerp = clamp(dot(fSunsetDuskMax, fSunsetDuskMin), 0, 1);
//Almost finished With lerps, decided to take a break and ask questions @ the forum
float fDawn = TimeOfDay1.x;
float fSunrise = TimeOfDay1.y;
float fDay = TimeOfDay1.z;
float fSunset = TimeOfDay1.w;
float fDusk = TimeOfDay2.x;
float fNight = TimeOfDay2.y;
float fDawnToSunrise = lerp(Dawn, Sunrise, DawnSunriseLerp);
float fSunriseToDay = lerp(Sunrise, Day, SunriseDayLerp);
float fDayToSunset = lerp(Day, Sunset, DaySunsetLerp);
float fSunsetToDusk = lerp(Sunset, Dusk, SunsetDuskLerp);
float fDuskToNight = lerp(Dusk, Night, DuskNightLerp);
float fNightToSunrise = lerp(Night, Sunrise, NightDawnLerp);
*/
//End FiftyTifty TimeOfDay
return OUT;
}
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *blah-blah-blah maniac*
- Posts: 565
- Joined: 05 Apr 2014, 10:29
- Location: Taiwan
Re: Converting SweetFX Effects To ENB
and by doing so, it will ruin the unsaved color change in current shader.FiftyTifty wrote: So, basically, the image of the game scene is finally rendered on either a screen-size quad or a large triangle, and the effect needs the data from that quad/triangle
about timed values, can't say much before knowing how TimeOfDay behave.
if similar to skyrim, then probably just need to add them altogether.
VariableA =
TimeOfDay1.x * VariableA_dawn
+TimeOfDay1.y * VariableA_sunrise
+TimeOfDay1.z * VariableA_day
+TimeOfDay1.w * VariableA_sunset
+TimeOfDay2.x * VariableA_dusk
+TimeOfDay2.y * VariableA_night
currently, .289 only enables DNI separations.
correction: TOD works now.
also, TODlerp is more likely to be some value driven from TimeOfDay external parameters defined in enbseries.ini
or you can do your own weight by Weather.w (current game hour) same as here.
viewtopic.php?f=7&t=2582
update:
the TOD factors shown in Statistics are indeed sum up to 1, you can use those as weight for variables like I mentioned above.
Last edited by kingeric1992 on 22 Dec 2015, 15:45, edited 4 times in total.
-
Offline
- *blah-blah-blah maniac*
- Posts: 17440
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: Converting SweetFX Effects To ENB
Nope. Time of day works too. I forgot to modify string in enbeffect.fx, only weather index do not work.currently, .289 only enables DNI separations.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *blah-blah-blah maniac*
- Posts: 565
- Joined: 05 Apr 2014, 10:29
- Location: Taiwan
Re: Converting SweetFX Effects To ENB
That is wonderful. and any suggestion upon using it?
-
Offline
- *blah-blah-blah maniac*
- Posts: 17440
- Joined: 27 Dec 2011, 08:53
- Location: Rather not to say
Re: Converting SweetFX Effects To ENB
The only one suggestion is to look at statistics of editor to understand what values are for TimeOfDay. And you need to clearly understand what is dawn, dusk and other parameters in time of the day category. Increase game time by console and carefully watch what is happening with parameters at certain time.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
-
Offline
- *master*
- Posts: 112
- Joined: 30 Jan 2016, 11:26
- Location: France
Re: Converting SweetFX Effects To ENB
If someone is kind enough to help me with this, because I really suck with everything about coding; I would like to merge this sweetFX for Enbs into the same postpass shaders from JawZ's Modular shaders library (I'm not using its latest version but the one he did for 0.288), in order to be able to use boths of them at the same time.
But I don't know how to do it and each time I try to merge them I have red lines at launch. Is it even possible ? Can someone teach me how to do it ?
(just to be sure, I'm not talking about activating the sweetFx by adding a line at the bottom of the postpass.fx, but to make it work with the MLS's postpassfx without having to choose between them.)
But I don't know how to do it and each time I try to merge them I have red lines at launch. Is it even possible ? Can someone teach me how to do it ?
(just to be sure, I'm not talking about activating the sweetFx by adding a line at the bottom of the postpass.fx, but to make it work with the MLS's postpassfx without having to choose between them.)
-
Offline
- *sensei*
- Posts: 316
- Joined: 12 Aug 2013, 18:55
- Location: Scotland
Re: Converting SweetFX Effects To ENB
I'm not familiar with the Modular Shader Library, as it seems awfully counter intuitive, especially in regards to it's aim; surely supplying snippets of shader code, to be integrated with the .fx files, is a much better (performance, organization/readability) alternative?
You'd best post on the forum for it, to get advice on how to add shader code.
You'd best post on the forum for it, to get advice on how to add shader code.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
-
Offline
- *master*
- Posts: 112
- Joined: 30 Jan 2016, 11:26
- Location: France
Re: Converting SweetFX Effects To ENB
Ok, I'm gonna make a topic for this. Thank you !
-
Offline
- *blah-blah-blah maniac*
- Posts: 1938
- Joined: 05 Mar 2012, 02:08
Re: Converting SweetFX Effects To ENB
Why is MSL so counter-intuitive?
Each effect has it's own file, so there won't be any misleading on what parts are associated with a particular effect. Apart from certain helper functions located in the msHelpers.fxh file. It's a easy copy & paste to any given .fx file from the get go.
So it is doing what you say, "supplying snippets of shader code, to be integrated with the .fx files".
It's better than having one file with 4933 lines of code in a row (That's just the enbeffect.fx related effect codes), quite messy to go through. If you doubt me go look in Oyama's shader files and see if the "all-snippets-in-one-file" really is a good idea.
Each effect has it's own file, so there won't be any misleading on what parts are associated with a particular effect. Apart from certain helper functions located in the msHelpers.fxh file. It's a easy copy & paste to any given .fx file from the get go.
So it is doing what you say, "supplying snippets of shader code, to be integrated with the .fx files".
It's better than having one file with 4933 lines of code in a row (That's just the enbeffect.fx related effect codes), quite messy to go through. If you doubt me go look in Oyama's shader files and see if the "all-snippets-in-one-file" really is a good idea.