Converting SweetFX Effects To ENB

share shaders here
  • Author
  • Message
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

Actually ssil is not computed separately, it's tied to ssao in same computation cycle. Don't know the code, but for sure they are same, because ssgi cannot be computed without deferred rendering at all, see old demos for that, they where made much earlier than first ssao. I choosed ssil name for effect, because it do exactly what it says, while ssdo and ssgi are not. Anyway, it's the author choice how to name anything, unless it's not foolish people. And porting such complex algorithms to external shaders is very bad idea, impossible to optimize code even twice slower than best internal processing with various stages. Making them open for editing means no more room for new ideas and optimizations. So please leave the code where it works the best.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
User avatar
*blah-blah-blah maniac*
Posts: 3136
Joined: 27 Jan 2012, 13:42

Re: Converting SweetFX Effects To ENB

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.
Check where the function is called, that 'x' is the input. Most likely it's something like 'color.xyz = HaarmPeterDuikerFilmicToneMapping(color.xyz);' or whatever.

In other words, that 'x' can be anything, but it's a good coding principle to name it something little more descriptive than 'x'.

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

Re: Converting SweetFX Effects To ENB

i have to agree with Boris at the moment. Such performance-heavy shader as any kind of AO or even depth of field require decent understanding what are you doing. I've ported ssdo bcos there's no enb - AO, Skylightning (yet i had an idea that skylightning is same AO but for LOD texture with high sampling radius... or it could be approximated that way - i've tested SSDO with huge radius on downscaled texture - looked promising)
1st small radius AO with bounce souce scale texture
Image
2nd large (sever times bigger then previous) radius AO with bounce on 1/4 scale texture
Image
3rd multiply them to look like that (but it doesnt look gorgeous as skyrim ao + skylighning to my eye)
Image

saturation and bleeding amount were forced high for demonstration purposes

another problem - game "god rays", for and light sprites. Reshade AO draws on top of them, which results in some ugly shadowing over fog-covered or "god-rayed" objects. Grass...
well hell of a tonn problems appear
_________________
Image

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

Re: Converting SweetFX Effects To ENB

Marty, I'm sorry if it feels that way.

I just don't want to make ppl confuse the Screen Space Global Illumination approximation to actually computing GI in screen space, which is probably why non of the proposed SSGI approximation goes by the plain SSGI as aberration.
_________________
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
*sensei*
Posts: 316
Joined: 12 Aug 2013, 18:55
Location: Scotland

Re: Converting SweetFX Effects To ENB

mindflux wrote: Check where the function is called, that 'x' is the input. Most likely it's something like 'color.xyz = HaarmPeterDuikerFilmicToneMapping(color.xyz);' or whatever.

In other words, that 'x' can be anything, but it's a good coding principle to name it something little more descriptive than 'x'.
Aye, you were right.

Code: Select all

color.xyz = HaarmPeterDuikerFilmicToneMapping(color.xyz);
Since it uses "in float3 x", I assume that it's assigning x to Color.xyz? Another guess of mine is that it's taking the first float value (color.x), but then it wouldn't be calling float3, and it also has that "in" part. That would also limit it to the red channel, which isn't how it works.

Tried changing the code to this:

Code: Select all

if(bFiftyTiftyHPDTonemapping)
{	
	float3 xColor = color.xyz;
	float3 HPDColor = color.xyz;
	xColor = max((HPDColor)0.0f, xColor - 0.004f );
	color.xyz = pow(abs((xColor * (6.2f * xColor + 0.5f )) / (xColor * (6.2f * x + 1.7f) + 0.06 )), 2.2f);
}
But that yields this error:

(720, 25): Error x3000: syntax error: unexpected float constant

The float causing the error is HPDColor in the "xColor = max" function. That line of code looks really...Not-working, because max is supposed to take two values, resulting in a single float, no? https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

And the max function is doing max((float3)float), float3 - float), which would return a float3, but max results in a float.

Ergh. This is complicated.
_________________
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

Code: Select all

xColor = max((HPDColor)0.0f, xColor - 0.004f );
It's error in the code, but i don't understand what is it supposed to do. May be this this code to clip very low values:

Code: Select all

xColor = max(xColor, 0.004f);
Output of max/min functions can be vector or scalar, each component computed separately.
_________________
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

Did some more digging, and found that x is a float defined in this piece of code:

Code: Select all

float smootherstep(float edge0, float edge1, float x)
{
   	x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
   	return x*x*x*(x*(x*6 - 15) + 10);
}
Did a bit of googling, and supposedly this goes into the vertex shader? Sounds bollocks, as far as performance is concerned.

I guess it's possible that the x variable is derived from that Smootherstep code.

Not too sure how to add that in to ENB. I know that this piece of code designates the Pixel Shader:

Code: Select all

float4	PS_Draw(VS_OUTPUT_POST IN, float4 v0 : SV_Position0) : SV_Target
I take it that I should make this:

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;
	return OUT;
}
Look like this:

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;
	return OUT;

	float edge0; 
	float edge1;
	float x;
  x = clamp((x - edge0)/(edge1 - edge0), 0.0, 1.0);
  float SmootherStep = x*x*x*(x*(x*6 - 15) + 10);
	return SmootherStep;
        return x;
}
But I don't really want to edit something as low level as the vertex shader; that sounds like something I shouldnae touch. Is it alright to edit it, or is that ill-advised?
_________________
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

ENBSeries wrote:

Code: Select all

xColor = max((HPDColor)0.0f, xColor - 0.004f );
It's error in the code, but i don't understand what is it supposed to do. May be this this code to clip very low values:

Code: Select all

xColor = max(xColor, 0.004f);
Output of max/min functions can be vector or scalar, each component computed separately.
Ya glorious bastard, Boris. It works!

Before:

Image

After:

Image

Now I need to figure out how to add adjustable variables to it. Eeeeergh.
_________________
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

Alrighty. Been fuddling about with the tonemapping, and here's what I got:

Code: Select all

if(bFiftyTiftyHPDTonemapping)
{	
	float3 xColor = color.xyz;
	xColor = max(xColor, HPDTonemappingClipping);
	float3 HPDcolor = pow(abs((xColor * (6.2f * xColor + 0.5f )) / (xColor * (6.2f * xColor + 1.7f) + 0.06 )), HPDTonemappingExposure);
	
	if(bFiftyTiftyHPDTonemappingMethod)
	{
		color.xyz = lerp(pow(HPDcolor.xyz, 1.0/2.2), color.xyz, HPDTonemappingLerp);
	}
	else
	{
		color.xyz = lerp(HPDcolor.xyz, color.xyz, HPDTonemappingLerp);
	}
}
Boris was right; that xColor = max function was to deal with clipping.

The last float in the float3 HPDcolor function controls the exposure (proper term?).

And, correct me if I'm wrong, but it also seems that the "lerp" function can be used to control the intensity of the effect. It's in reverse, though. "HPTonemappingLerp = 1.000" renders the effect meaningless (looks the same as without the effect). Setting it to 0.0001 renders the tonemapping in all it's glory.

Is it acceptable to do

Code: Select all

Lerp(float,float,0);
or should you use 'practically zero', like:

Code: Select all

Lerp(float,float,0.0001);
?


Edit: Figured I would show how I've got the game to look. A bit washed out, but better than vanilla if ya ask me. Could do with some darker shadows. The sky is also fairly dark, but that's a vanilla issue.

The vanilla bloom is rearing it's ugly head as well. Totally need that depth bloom effect.

Image
_________________
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

This is what I did to that Filmic ALU

Code: Select all

return pow( abs( ( x * ( 6.2f * x + 0.5f ) ) / ( x * ( 6.2f * x + 1.7f ) + 0.06 ) ), 2.2f );

Code: Select all

return pow( abs( ( x * ( fUpperTone * x + fGreyTone ) ) / ( x * ( fUpperTone  * x + fMiddleTone ) + fLowerTone ) ), 2.2f );
OR

Code: Select all

color.rgb = (color.rgb * (fUpperTone * color.rgb + fGreyPoint)) / (color.rgb * (fUpperTone + fMiddleTone) + fLowerTone);
Or something like that.
Post Reply