[SLE / SSE / FO4] Depth of Field

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: Skyrim SE Advanced Depth of Field

TreyM wrote:
Oyama wrote:TreyM
All right, and thank you ;) . But call me Barack please :lol:
LMAO that was a cell phone auto correct typo.
Tell me about it ! I hate those auto correct sheetes. :D
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
User avatar
*master*
Posts: 125
Joined: 09 Jul 2015, 16:13

Re: Skyrim SE Advanced Depth of Field

Oyama wrote:
TreyM wrote:
Oyama wrote:TreyM
All right, and thank you ;) . But call me Barack please :lol:
LMAO that was a cell phone auto correct typo.
Tell me about it ! I hate those auto correct sheetes. :D
PM with the modified DOF code sent.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: Skyrim SE Advanced Depth of Field

Got it. Thank you ;)
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: Skyrim SE Advanced Depth of Field

You guys can post your modifications here because I can update shaders only on weekend when I'm home anyways ;)

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: Skyrim SE Advanced Depth of Field

Copy that.
We will.
Thank you ;)
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
User avatar
*master*
Posts: 125
Joined: 09 Jul 2015, 16:13

Re: Skyrim SE Advanced Depth of Field

Simple Tilt Shift toggle mod for 1.3B:

Code on Pastebin

Should I put it in this post in "code" brackets?

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: Skyrim SE Advanced Depth of Field

That's why I made it as preprocessor definition instead of toggle at runtime: It needs dynamic branching inside the main loop of the DoF which heavily affects performance. Also there is a "string" annotation for adding text, no need to use an unused varaible.

Offline
User avatar
*master*
Posts: 125
Joined: 09 Jul 2015, 16:13

Re: Skyrim SE Advanced Depth of Field

Marty McFly wrote:That's why I made it as preprocessor definition instead of toggle at runtime: It needs dynamic branching inside the main loop of the DoF which heavily affects performance. Also there is a "string" annotation for adding text, no need to use an unused varaible.
Yeah I figured it causes a performance hit going by your comment at the top of the code about dynamic branching.

And the string annotation is handy info. Is there an example of proper syntax on that? I have almost no clue what I'm doing in HLSL/C++.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 530
Joined: 30 Jan 2012, 13:18

Re: Skyrim SE Advanced Depth of Field

Just researched, apparently I was mistaken, Skyrim SE ENB doesn't have that, although I can swear I saw it on Oldrim ENB.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: Skyrim SE Advanced Depth of Field

Marty
Generic question : would it be possible to implement MXAO (or another AO/IL algorythm combination) in this shader ?


While I'm here, for those interested, your modified last pixel shader with your original grain from ReShade :

Code: Select all

float4	PS_DoF_Smoothen(float2 texcoord : TEXCOORD0) : SV_Target
{
	float4 scenecolor = TextureColor.Sample(Sampler1, texcoord.xy);
	float outOfFocus = abs(scenecolor.w * 2.0 - 1.0);
	
	float centerDepth = scenecolor.w;
	float blurAmount = abs(centerDepth * 2.0 - 1.0);
	float blurFactor = smoothstep(0.0,0.15,blurAmount)*fADOF_SmootheningAmount;

	scenecolor = 0.0;

	float offsets[5] = {-3.2307692308, -1.3846153846, 0.0, 1.3846153846, 3.2307692308};
	float weights[3] = {0.2270270270, 0.3162162162, 0.0702702703};

	float chromaamount = 1.3;

	for(int x=-2; x<=2; x++)
	for(int y=-2; y<=2; y++)
	{
		float2 coord = float2(x,y);
		float2 actualoffset = float2(offsets[x+2],offsets[abs(y+2)])*blurFactor*PixelSize.xy;
		float weight = weights[abs(x)] * weights[abs(y)];

                float4 tap = TextureColor.SampleLevel(Sampler1, texcoord.xy + actualoffset,0);
                float tapblurAmount = abs(tap.w * 2.0 - 1.0);
                /* weight *= (tapblurAmount >= blurAmount*0.2) ? 1.0 : 0.0; */
                weight *= smoothstep(-0.0001,0.0,tapblurAmount-blurAmount);

                scenecolor.xyz += tap.xyz * weight;
                scenecolor.w += weight;
	}
	scenecolor.xyz /= scenecolor.w;
	
	if(bADOF_ImageGrainEnable)
	{
	float ImageGrain = frac(sin(texcoord.x + texcoord.y * 543.31) *  893013.0 + Timer.x * 0.001);

	float3 AnimGrain = 0.5;
	float2 GrainPixelSize = PixelSize/fADOF_ImageGrainScale;
	/* My emboss noise */
	AnimGrain += lerp(TextureNoise.Sample(SamplerNoise, texcoord.xy*fADOF_ImageGrainScale + float2(GrainPixelSize.x,0)).xyz,TextureNoise.Sample(SamplerNoise, texcoord.xy*fADOF_ImageGrainScale + 0.5 + float2(GrainPixelSize.x,0)).xyz,ImageGrain.x) * 0.1;
	AnimGrain -= lerp(TextureNoise.Sample(SamplerNoise, texcoord.xy*fADOF_ImageGrainScale + float2(0,GrainPixelSize.y)).xyz,TextureNoise.Sample(SamplerNoise, texcoord.xy*fADOF_ImageGrainScale + 0.5 + float2(0,GrainPixelSize.y)).xyz,ImageGrain.x) * 0.1;
	AnimGrain = dot(AnimGrain.xyz,0.333);

	/* Photoshop overlay mix mode */
	float3 graincolor = (scenecolor.xyz < 0.5 ? (2.0 * scenecolor.xyz * AnimGrain.xxx) : (1.0 - 2.0 * (1.0 - scenecolor.xyz) * (1.0 - AnimGrain.xxx)));
	scenecolor.xyz = lerp(scenecolor.xyz, graincolor.xyz, pow(outOfFocus,fADOF_ImageGrainCurve)*fADOF_ImageGrainAmount);
	}
	
	return scenecolor;
}
Without forgetting to declare texture :

Code: Select all

Texture2D 		TextureNoise
<
	string ResourceName = "enbseries/DoFNoise.png";
>;
(I used your own texture from ReShade)

And adding sampler :

Code: Select all

SamplerState SamplerNoise
{
	Texture = TextureNoise;
	Filter = MIN_MAG_MIP_LINEAR;
	AddressU = Wrap;
	AddressV = Wrap;
};
Of course, vars go on top of the file :

Code: Select all

/* Image grain */
bool bADOF_ImageGrainEnable
<
string UIName = "DOF: Enable Grain in Blurred Areas";
> = {false};
float	fADOF_ImageGrainScale	
< 
	string UIName="DOF: Grain Scale";	
	string UIWidget="Spinner";	
	float UIStep=0.001;	
	float UIMin=1.0;	
	float UIMax=2.0;	
> = {1.0};
float	fADOF_ImageGrainCurve		
< 
	string UIName="DOF: Grain Curve";	
	string UIWidget="Spinner";	
	float UIStep=0.001;	
	float UIMin=0.0;	
	float UIMax=2.0;	
> = {1.0};
float	fADOF_ImageGrainAmount	
< 
	string UIName="DOF: Grain Amount";	
	string UIWidget="Spinner";	
	float UIStep=0.001;	
	float UIMin=0.0;	
	float UIMax=5.0;	
> = {1.5};
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop
Post Reply