Converting SweetFX Effects To ENB

share shaders here
  • Author
  • Message
Offline
User avatar
*master*
Posts: 136
Joined: 08 Nov 2012, 15:24

Re: Converting SweetFX Effects To ENB

For lazy people, here are some shaders I've converted from ReShade; LumaSharpen and film grain.
I should note that film grain has a particularly interesting application, as on the lowest intensity (0.01) it makes banding vanish while being nearly invisible. Example. I guess you could say it's meant to do that, but it works exceptionally well...
Also, LumaSharpen actually works pretty well with the TAA applied after. However, at high intensities distant objects acquire outlines.
No guarantees about the code quality. I'm no master.
Last edited by roxahris on 04 Dec 2015, 12:26, edited 2 times in total.

Offline
User avatar
Posts: 84
Joined: 21 Nov 2015, 14:15

Re: Converting SweetFX Effects To ENB

roxahris wrote:I should note that film grain has a particularly interesting application, as on the lowest intensity (0.01) it makes banding vanish while being nearly invisible.
Yup, it's one of the benefit of Grain in general picture application. =) It helps fight the banding by simulating a higher range of colors thanks to patterns made with a lower range of colors. It's quite necessary to visually exceed the technical limitation of 8bit monitors. The - more or less - same kind of technique exist in print, simulating various shades of grey with only black and white dots and using different sizes / gaps.

Thanks a lot for the shaders - I really need lumasharpen and I'm too busy and ignorant to do it myself !

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

Re: Converting SweetFX Effects To ENB

I guess no one has seen this;
http://www.nexusmods.com/fallout4/mods/4088/?

And I'm currently implementing effects into the enbeffectpostpass instead of the enbeffect.fx.
Two sharpening methods, one with depth based sharpening and the other without it (courtesy of Prod80). And then there is Vignette, Dither(3 methods), Interlace, animated Grain and Letterbox. Other additions will be made in the future.

Offline
User avatar
Posts: 84
Joined: 21 Nov 2015, 14:15

Re: Converting SweetFX Effects To ENB

--JawZ-- wrote:I guess no one has seen this;
http://www.nexusmods.com/fallout4/mods/4088/?

And I'm currently implementing effects into the enbeffectpostpass instead of the enbeffect.fx.
Two sharpening methods, one with depth based sharpening and the other without it (courtesy of Prod80). And then there is Vignette, Dither(3 methods), Interlace, animated Grain and Letterbox. Other additions will be made in the future.
Yeah I totally did ! I just put it aside and switched back to classic ENB to try and follow the progress for now. I jumped on the Skyrim ENB train quite late and felt I was pushing buttons at random rather than actually knowing what I was doing :p

Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Converting SweetFX Effects To ENB

Been looking into making the effects time-dependent. Dear lord does it make my brain hurt.

So far, I've defined floats that pertain to the time.

Code: Select all

float4	PS_Draw(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
{
	float4	res;
	float4	color;
	color=TextureColor.Sample(Sampler0, IN.txcoord0.xy); //hdr scene color
	
	float fDawn = TimeOfDay1.x;
	float fSunrise = TimeOfDay1.y;
	float fDay = TimeOfDay1.z;
	float fSunset = TimeOfDay1.w;
	float fDusk = TimeOfDay2.x;
	float fNight = TimeOfDay2.y;
	
But, uh, I've no clue how to make the an effect change depending on the time. Took a look at a Skyrim enbeffect.fx file, but it uses some odd _c3.w variable, that is provided by ENB. It then uses clamp() to change the value between day and night.

The resulting float is then used in some bizarre math that just makes my eyes sore. And it doesn't even account for dawn, sunrise, sunset and dusk.

Eeeeeergh.


Also, is there an interior/exterior boolean that we can use in the shaders? I've got a pretty good result for the exteriors, but interiors look...Not so great.

Or is that something we have to wait further down the line for due to Bethesda updating and releasing DLC?
_________________
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
User avatar
*blah-blah-blah maniac*
Posts: 1938
Joined: 05 Mar 2012, 02:08

Re: Converting SweetFX Effects To ENB

TimeOfDay has yet to be implemented in the shader files. So you will have to wait for Boris to do so to have any use of that.

And what code did you look at that used clamp(Var, minVal, maxVal) to change between Day and Night? Better opt it for lerp(1stfloatVal, 2ndfloatVal, LinearInterpolateVar)

Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Converting SweetFX Effects To ENB

--JawZ-- wrote:TimeOfDay has yet to be implemented in the shader files. So you will have to wait for Boris to do so to have any use of that.

And what code did you look at that used clamp(Var, minVal, maxVal) to change between Day and Night? Better opt it for lerp(1stfloatVal, 2ndfloatVal, LinearInterpolateVar)

TimeOfDay isn't there, but TimeofDay1 & TimeOfDay2 is.
//+++++++++++++++++++++++++++++
//external enb parameters, do not modify
//+++++++++++++++++++++++++++++
//x = generic timer in range 0..1, period of 16777216 ms (4.6 hours), y = average fps, w = frame time elapsed (in seconds)
float4 Timer;
//x = Width, y = 1/Width, z = aspect, w = 1/aspect, aspect is Width/Height
float4 ScreenSize;
//changes in range 0..1, 0 means full quality, 1 lowest dynamic quality (0.33, 0.66 are limits for quality levels)
float AdaptiveQuality;
//x = current weather index, y = outgoing weather index, z = weather transition, w = time of the day in 24 standart hours. Weather index is value from weather ini file, for example WEATHER002 means index==2, but index==0 means that weather not captured.
float4 Weather;
//x = dawn, y = sunrise, z = day, w = sunset. Interpolators range from 0..1
float4 TimeOfDay1;
//x = dusk, y = night. Interpolators range from 0..1
float4 TimeOfDay2;


I shoulda posted the code I was looking at; it was from the enbeffect.fx from that Natural Lighting And Atmospherics preset.

Code: Select all

		float2 unwarpedTxCoord = _v0.xy;

		// The _c3.w value is from the game needs to be manipulated as
		// below to get a value from 0 (night eye off) to 1 (night eye on).
		// The Day, Night, and Interior GUI controls can be used to tune this.
		float3 nightEyeDayFactor = clamp(_c3.w + nightEyeDayOffset, 0.0, 1.0) * nightEyeDayMult;
		float3 nightEyeNightFactor = clamp(_c3.w + nightEyeNightOffset, 0.0, 1.0) * nightEyeNightMult;
		float3 nightEyeInteriorFactor = clamp(_c3.w + nightEyeInteriorOffset, 0.0, 1.0) * nightEyeInteriorMult;

		// Interpolate night/day/interior
		float nightEyeT;;
		nightEyeT = nightEyeDayFactor * ENightDayFactor + 
			nightEyeNightFactor * (1.0 - ENightDayFactor);
		nightEyeT = nightEyeInteriorFactor * EInteriorFactor + 
			nightEyeT * (1.0 - EInteriorFactor);
		float aspectRatio = ScreenSize.z;

I guess there would have to be a bunch of if statements that check each lerp() combination:

Code: Select all

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);
But that sounds pretty...Inefficient.
_________________
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
User avatar
*blah-blah-blah maniac*
Posts: 17562
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Converting SweetFX Effects To ENB

Isn't it faster to compute time factors in vertex shader? And time of the day with weather index are not yet implemented.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Converting SweetFX Effects To ENB

ENBSeries wrote:Isn't it faster to compute time factors in vertex shader?
I've no clue. I just assumed that the vertex shader is for pros only. That, and I don't even know what I'd use it for, nor where it is in enbeffect.fx

Why would it be faster in the vertex shader, might I ask? Latency or something?
And time of the day with weather index are not yet implemented.
Ah well. Turns out I was wrong. Saves me the effort, anyhow.
_________________
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
User avatar
*blah-blah-blah maniac*
Posts: 17562
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Converting SweetFX Effects To ENB

Vertex shader is faster, because it have only 6 vertices of two triangles for computing anything, instead of each pixel on the screen for pixel shader. For example:

Code: Select all

struct VS_OUTPUT_POST
{
	float4 pos		: SV_POSITION;
	float2 txcoord0	: TEXCOORD0;
	float4 timefactors1	: TEXCOORD1;//added output vector
	float4 timefactors2	: TEXCOORD2;//added output vector
};

VS_OUTPUT_POST	VS_PostProcess(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;

//added code
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);
OUT.timefactors1.x=fDawnToSunrise;
OUT.timefactors1.y=fSunriseToDay;
OUT.timefactors1.z=fDayToSunset;
OUT.timefactors1.w=fSunsetToDusk;
OUT.timefactors1.x=fDuskToNight;
OUT.timefactors1.y=fNightToSunrise;
OUT.timefactors1.z=0.0;
OUT.timefactors1.w=0.0;

	return OUT;
}


float4	PS_PostProcess(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
{
	float4	res;
	res=TextureColor.Sample(Sampler0, IN.txcoord0.xy);

//added code
float fDawnToSunrise=IN.timefactors1.x;
//...

	res.w=1.0;
	return res;
}
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply