Converting SweetFX Effects To ENB

share shaders here
  • Author
  • Message
Offline
User avatar
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Converting SweetFX Effects To ENB

Uber-new edit:

Figured I might as well attach me current preset. Can't figure out why Nostalgia doesn't work, and the DOS shader is left in for posterity.

Been using it for the past week or so when playing...I think I got it looking rather nice. Uses kingeric1992's SMAA as well as MaxTheUniqueGamer's Natural Bloom. The latter is disabled by default, as it makes the game stutter like mad for me. That 2GB of vRAM is feeling awfully small.

Super-late edit:

With the release o' Fallout 4's ENBEffect.fx file, I've decided to go ahead and try converting some of ReShade's effects. Starting with a few simple ones from the SweetFX shaders first.

Got "Vibrance" working and added a lil' something to manage the brightness of the colours. Also got "Levels" working, which was easy 'cause it was, uh, a couple lines.

I've hit a rather large snag, however, in converting the "Nostalgia" effect. There are two main problems:

The color gui variables have values between 0.0000 and 1.0000; I've no idea how to convert RGB values, that range from 0-255, to ENB colour values.

The second problem, is that I've no idea if I've converted the float3[16] array properly. I'm going to assume I haven't, as I'm trying to jam my Pascal-shaped-knowledge-blocks into the HLSL-shaped holes, so to speak.

Any tips that can be given? I tried searching Microsoft's site for documentation on arrays, but it's...Sparse, to say the least.

Here's my port of the Nostalgia effect (the prefix "N" stands for Nostalgia):

Code: Select all

if(bFiftyTiftyNostalgia)
{
	float3 NColor = color.rgb;
	
	float3 NPalette[16];
	NPalette[0] = NBlack; //Black
	NPalette[1] = NBlue; //Blue
	NPalette[2] = NDYellowBrown; //Dark Yellow-Brown
	NPalette[3] = NDRed; //Dark Red
	NPalette[4] = NDGrey; //Dark Grey
	NPalette[5] = NPurple; //Purple
	NPalette[6] = NBrown; //Brown
	NPalette[7] = NLPurple; //Light Purple
	NPalette[8] = NPGrey; //Pale Grey
	NPalette[9] = NGreen; //Green
	NPalette[10] = NPRed; //Pale Red
	NPalette[11] = NPCyan; //Pale Cyan
	NPalette[12] = NLGrey; //Light Grey
	NPalette[13] = NSnotGreen; //Snot-Green
	NPalette[14] = NLimeGreen; //Lime-Green
	NPalette[15] = NWhite; //White

	
	float3 NDiff = NColor;
  float NDist = dot(NDiff,NDiff);
  float NClosestDist = NDist;
  float3 NClosestColor = float3(0.0,0.0,0.0);
	int Nint = 1;
	
	for (Nint = 1 ; Nint <= 15 ; Nint++) 
	{
		NDiff = NColor - (NPalette[Nint]/255.0); //difference
		NDist = dot(NDiff,NDiff); //squared distance

		if (NDist < NClosestDist) //ternary would also work here
		{
			NClosestDist = NDist;
			NClosestColor = NPalette[Nint]/255.0;
		}
	}

  color.rgb = NClosestColor; 
}
I've attached the .fx file, for those willin' to lend a hand.
Attachments
Fallout 4 ENB - Bit O' SweetFX.rar
Eh. I like it.
(28.29 KiB) Downloaded 185 times
enbeffect.fx
Updated for 0.288. Need to find some more cool effects to port.
(28.42 KiB) Downloaded 194 times
enbeffect.fx
Got HPD Tonemapping to work? Not sure if the effect is the exact same as it is in Reshade.
(21.48 KiB) Downloaded 114 times
enbeffect.fx
Nostalgia sort of works. Several colours missing...Might be due to incorrect loop? Or could just be due to Fallout 4's default colours.
(17.77 KiB) Downloaded 99 times
enbeffect.fx
Old version. Nostalgia is broken.
(17.03 KiB) Downloaded 98 times
Last edited by FiftyTifty on 21 Dec 2015, 18:56, edited 4 times in total.
_________________
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
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Converting SweetFX Effects To ENB

Lil' bump, to show that this is alive; completely edited the first post.
_________________
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: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Converting SweetFX Effects To ENB

Apply color.xyz = pow(color.xyz, 1.0/2.2); to the shader if required by recent update of 0.284 beta.
_________________
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:Apply color.xyz = pow(color.xyz, 1.0/2.2); to the shader if required by recent update of 0.284 beta.
Err. I take it that Color.xyz is the position of the pixel being shaded? If so, that might be why the Nostalgia shader seems to only apply three colours; black, one colour, white.

Don't know how to use that, though. My initial assumption is that it goes before color.rgb.

I'll see what happens.
_________________
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: 17427
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Converting SweetFX Effects To ENB

No, it's not position. .xyz is the same as .rgb - color channels in this case. pow(color, 1.0/2.2) is the gamma code which converts linear space to non linear, but which looks like linear to the eye when viewed with commonly used displays.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
Posts: 78
Joined: 08 Nov 2013, 07:42
Location: Taiwan

Re: Converting SweetFX Effects To ENB

Hi,
I am wondering is it possible to port the "SSGI" effect from the MasterEffect ReShade shadersuite?
That will be awesome if it should work! I haven't got time to test it out yet though
_________________
Observing the world with aesthetic taste.

Offline
User avatar
*sensei*
Posts: 267
Joined: 12 Oct 2012, 19:14

Re: Converting SweetFX Effects To ENB

abc75179778300 wrote:Hi,
I am wondering is it possible to port the "SSGI" effect from the MasterEffect ReShade shadersuite?
That will be awesome if it should work! I haven't got time to test it out yet though
i assume - no, its not possible, since any kind of ao requires at least 2-3 techniques and texture writes to work. All classic enbeffect.fx files had single technique.

however everything is possible, and one can "port" SSGI or any other reshade code, yet it wont work fast or percise at the same time.
_________________
Image

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

Re: Converting SweetFX Effects To ENB

the so called SSGI does the same thing as SSIL in ENB on different approach but lacks of additional engine resource input.
_________________
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: 530
Joined: 30 Jan 2012, 13:18

Re: Converting SweetFX Effects To ENB

Why always this negative subtone when it comes to stuff from me, kingeric? :p
I called it SSGI because I ported it from OBGE and it's called SSGI there, too. SSIL is not entirely correct because SSIL only does indirect lighting while the OBGE SSGI also has AO output. The name originates from its original authors, tomerk and Ethatron, better coders than you.
Porting is possible with latest Skyrim binaries due to SamplerOriginal. You just do the necessary stuff to generate what you want in the regular passes of enbeffectprepass.fx and when it comes to blending, take image color from SamplerOriginal. Older versions which don't have this "backup" can only do AO as you must preserve the source color in SamplerColor and carry AO in alpha channel. You can put GI in alpha channel but in lower resolution.

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

Re: Converting SweetFX Effects To ENB

Finally got Nostalgia sort of working; didn't notice that one of the floats had a / 255 equation.

Doesn't seem to be utilizing the whole palette. Something is wrong with the code (incorrect array loop?), or it just requires tweaking with ENB's colour variables.

Have a gander. The first image is using color.xyz=NClosestColor.rgb. The second is using the non-linear equation that Boris provided.

Image

Image

Here's the updated code:

Code: Select all

if(bFiftyTiftyNostalgia)
{
	float3 NColor = color.rgb;
	float3 NColorDiv = (NColor);
	
	float3 NPalette[16];
	NPalette[0] = NBlack; //Black
	NPalette[1] = NBlue; //Blue
	NPalette[2] = NDYellowBrown; //Dark Yellow-Brown
	NPalette[3] = NDRed; //Dark Red
	NPalette[4] = NDGrey; //Dark Grey
	NPalette[5] = NPurple; //Purple
	NPalette[6] = NBrown; //Brown
	NPalette[7] = NLPurple; //Light Purple
	NPalette[8] = NPGrey; //Pale Grey
	NPalette[9] = NGreen; //Green
	NPalette[10] = NPRed; //Pale Red
	NPalette[11] = NPCyan; //Pale Cyan
	NPalette[12] = NLGrey; //Light Grey
	NPalette[13] = NSnotGreen; //Snot-Green
	NPalette[14] = NLimeGreen; //Lime-Green
	NPalette[15] = NWhite; //White

	
	float3 NDiff = NColor;
  float NDist = dot(NDiff,NDiff);
  float NClosestDist = NDist;
  float3 NClosestColor = float3(0.0,0.0,0.0);
	int Nint = 1;
	
	for (Nint = 1 ; Nint <= 15 ; Nint++) 
	{
		NDiff = NColorDiv - (NPalette[Nint]); //difference
		NDist = dot(NDiff,NDiff); //squared distance

		if (NDist < NClosestDist) //ternary would also work here
		{
			NClosestDist = NDist;
			NClosestColor = NPalette[Nint];
		}
	}
	
	if(bFiftyTiftyNostalgiaMethod)
	{
		color.xyz = NClosestColor.rgb;
		color.xyz = pow(color.xyz, 1.0/2.2);
	}
	else
	{
		color.xyz = NClosestColor.rgb;
	}
}

I took a look at the HPD Tonemapping shader in Reshade...I've no bloody clue what it's doing.

Code: Select all

float3 HaarmPeterDuikerFilmicToneMapping(in float3 x)
{
    	x = max( (float3)0.0f, x - 0.004f );
    	return pow( abs( ( x * ( 6.2f * x + 0.5f ) ) / ( x * ( 6.2f * x + 1.7f ) + 0.06 ) ), 2.2f );
}
The first line can usually be removed, but that's the first time I've seen it have (in float3 x) instead of (float3 ColorInput), with ColorInput being equivalent to ENB's "color" float3.

Gonna go post on the ReShade forums. See if they can help with my ignorance.
_________________
Intel i7 6700k | AMD Vega 56 8GB | 2x16GB DDR4 @ 3000mhz | Windows 7 64bit | Creative Soundblaster X-Fi Titanium Fatal1ty Pro | Asus z170 Pro Gaming
Post Reply