#line 1 "unknown"

#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\LightDoF.fx"
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShade.fxh"
#line 50
namespace ReShade
{
#line 61
static const float AspectRatio = 1984 * (1.0 / 1184);
static const float2 PixelSize = float2((1.0 / 1984), (1.0 / 1184));
static const float2 ScreenSize = float2(1984, 1184);
#line 67
texture BackBufferTex : COLOR;
texture DepthBufferTex : DEPTH;
#line 70
sampler BackBuffer { Texture = BackBufferTex; };
sampler DepthBuffer { Texture = DepthBufferTex; };
#line 74
float GetLinearizedDepth(float2 texcoord)
{
#line 79
texcoord.x /=  1;
texcoord.y /=  1;
#line 84
texcoord.x -=  0 / 2.000000001;
#line 89
texcoord.y +=  0 / 2.000000001;
#line 91
float depth = tex2Dlod(DepthBuffer, float4(texcoord, 0, 0)).x *  1;
#line 100
const float N = 1.0;
depth /= 1000.0 - depth * (1000.0 - N);
#line 103
return depth;
}
}
#line 108
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
#line 34 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\LightDoF.fx"
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShadeUI.fxh"
#line 38 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\LightDoF.fx"
#line 40
uniform float fLightDoF_Width <      ui_type = "slider"; 
ui_label = "Bokeh Width [Light DoF]";
ui_min = 1.0;
ui_max = 25.0;
> = 5.0;
#line 46
uniform float fLightDoF_Amount <      ui_type = "slider"; 
ui_label = "DoF Amount [Light DoF]";
ui_min = 0.0;
ui_max = 10.0;
> = 10.0;
#line 52
uniform bool bLightDoF_UseCA <
ui_label = "Use Chromatic Aberration [Light DoF]";
ui_tooltip = "Use color channel shifting.";
> = false;
#line 57
uniform float2 f2LightDoF_CA <      ui_type = "slider"; 
ui_label = "Chromatic Aberration [Light DoF]";
ui_tooltip = "Shifts color channels.\nFirst value controls far CA, second controls near CA.";
ui_min = 0.0;
ui_max = 1.0;
> = float2(0.0, 1.0);
#line 64
uniform bool bLightDoF_AutoFocus <
ui_label = "Use Auto Focus [Light DoF]";
> = true;
#line 68
uniform float fLightDoF_AutoFocusSpeed <
ui_label = "Auto Focus Speed [Light DoF]";
ui_type = "drag";
ui_min = 0.001;
ui_max = 1.0;
> = 0.1;
#line 75
uniform bool bLightDoF_UseMouseFocus <
ui_label = "Use Mouse for Auto Focus Center [Light DoF]";
ui_tooltip = "Use the mouse position as the auto focus center";
> = false;
#line 80
uniform float2 f2Bokeh_AutoFocusCenter <      ui_type = "slider"; 
ui_label = "Auto Focus Center [Light DoF]";
ui_tooltip = "Target for auto focus.\nFirst value is horizontal: Left<->Right\nSecond value is vertical: Up<->Down";
ui_min = 0.0;
ui_max = 1.0;
> = float2(0.5, 0.5);
#line 87
uniform float fLightDoF_ManualFocus <      ui_type = "slider"; 
ui_label = "Manual Focus [Light DoF]";
ui_min = 0.0;
ui_max = 1.0;
> = 0.0;
#line 96
uniform float2 f2LightDoF_MouseCoord <source="mousepoint";>;
#line 108
texture tFocus { Format = R16F; };
#line 110
texture tLastFocus { Format = R16F; };
#line 115
sampler sFocus { Texture=tFocus; };
#line 117
sampler sLastFocus { Texture=tLastFocus; };
#line 122
float getFocus(float2 coord, bool farOrNear) {
float depth = ReShade::GetLinearizedDepth(coord);
#line 125
depth -= bLightDoF_AutoFocus ? tex2D(sFocus, 0).x : fLightDoF_ManualFocus;
#line 127
if (farOrNear) {
depth = saturate(-depth * fLightDoF_Amount);
}
else {
depth = saturate(depth * fLightDoF_Amount);
}
#line 134
return depth;
}
#line 138
float2 rot2D(float2 pos, float angle) {
float2 source = float2(sin(angle), cos(angle));
return float2(dot(pos, float2(source.y, -source.x)), dot(pos, source));
}
#line 144
float3 poisson(sampler sp, float2 uv, float farOrNear, float CA) {
float2 poisson[12];
poisson[0]  = float2(-.326,-.406);
poisson[1]  = float2(-.840,-.074);
poisson[2]  = float2(-.696, .457);
poisson[3]  = float2(-.203, .621);
poisson[4]  = float2( .962,-.195);
poisson[5]  = float2( .473,-.480);
poisson[6]  = float2( .519, .767);
poisson[7]  = float2( .185,-.893);
poisson[8]  = float2( .507, .064);
poisson[9]  = float2( .896, .412);
poisson[10] = float2(-.322,-.933);
poisson[11] = float2(-.792,-.598);
#line 159
float3 col = 0;
float random = frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453);
float4 basis = float4(rot2D(float2(1, 0), random), rot2D(float2(0, 1), random));
[unroll]
for (int i = 0; i < 12; ++i) {
float2 offset = poisson[i];
offset = float2(dot(offset, basis.xz), dot(offset, basis.yw));
#line 167
if (bLightDoF_UseCA) {
float2 rCoord = uv + offset *  float2((1.0 / 1984), (1.0 / 1184)) * fLightDoF_Width * (1.0 + CA);
float2 gCoord = uv + offset *  float2((1.0 / 1984), (1.0 / 1184)) * fLightDoF_Width * (1.0 + CA * 0.5);
float2 bCoord = uv + offset *  float2((1.0 / 1984), (1.0 / 1184)) * fLightDoF_Width;
#line 172
rCoord = lerp(uv, rCoord, getFocus(rCoord, farOrNear));
gCoord = lerp(uv, gCoord, getFocus(gCoord, farOrNear));
bCoord = lerp(uv, bCoord, getFocus(bCoord, farOrNear));
#line 176
col += 	float3(
tex2Dlod(sp, float4(rCoord, 0, 0)).r,
tex2Dlod(sp, float4(gCoord, 0, 0)).g,
tex2Dlod(sp, float4(bCoord, 0, 0)).b
);
}
else {
float2 coord = uv + offset *  float2((1.0 / 1984), (1.0 / 1184)) * fLightDoF_Width;
coord = lerp(uv, coord, getFocus(coord, farOrNear));
col += tex2Dlod(sp, float4(coord, 0, 0)).rgb;
}
#line 188
}
return col * 0.083;
}
#line 195
float3 Far(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
return poisson(ReShade::BackBuffer, uv, false, f2LightDoF_CA.x);
}
#line 200
float3 Near(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
return poisson(ReShade::BackBuffer, uv, true, f2LightDoF_CA.y);
}
#line 205
float GetFocus(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
float2 linearMouse = f2LightDoF_MouseCoord *  float2((1.0 / 1984), (1.0 / 1184)); 
float2 focus = bLightDoF_UseMouseFocus ? linearMouse : f2Bokeh_AutoFocusCenter;
return lerp(tex2D(sLastFocus, 0).x, ReShade::GetLinearizedDepth(focus), fLightDoF_AutoFocusSpeed);
}
#line 212
float SaveFocus(float4 pos : SV_Position, float2 uv : TEXCOORD) : SV_Target {
return tex2D(sFocus, 0).x;
}
#line 220
technique LightDoF_AutoFocus {
pass GetFocus {
VertexShader=PostProcessVS;
PixelShader=GetFocus;
RenderTarget=tFocus;
}
pass SaveFocus {
VertexShader=PostProcessVS;
PixelShader=SaveFocus;
RenderTarget=tLastFocus;
}
}
#line 234
technique LightDoF_Far {
pass Far {
VertexShader=PostProcessVS;
PixelShader=Far;
}
}
#line 242
technique LightDoF_Near {
pass Near {
VertexShader=PostProcessVS;
PixelShader=Near;
}
}

