#line 1 "unknown"

#line 1 "D:\The.Elder.Scrolls.V.Skyrim.VR.v1.4.0.15.8\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FineSharp.fx"
#line 1 "D:\The.Elder.Scrolls.V.Skyrim.VR.v1.4.0.15.8\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShadeUI.fxh"
#line 15 "D:\The.Elder.Scrolls.V.Skyrim.VR.v1.4.0.15.8\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FineSharp.fx"
#line 17
uniform float sstr <      ui_type = "slider"; 
ui_min = 0.00; ui_max = 8.00;
ui_label = "Sharpening Strength";
> = 2.00;
#line 22
uniform float cstr <
ui_type = "drag";
ui_min = 0.00; ui_max = 1.249;
ui_label = "Equalization Strength";
ui_tooltip = "Suggested settings for cstr based on sstr value: sstr=0->cstr=0, sstr=0.5->cstr=0.1, 1.0->0.6, 2.0->0.9, 2.5->1.00, 3.0->1.09, 3.5->1.15, 4.0->1.19, 8.0->1.249";
> = 0.90;
#line 29
uniform float xstr <      ui_type = "slider"; 
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Strength of XSharpen-style final sharpening.";
> = 0.19;
#line 34
uniform float xrep <      ui_type = "slider"; 
ui_min = 0.00; ui_max = 1.00;
ui_tooltip = "Repair artefacts from final sharpening. (-Vit- addition to original script)";
> = 0.25;
#line 39
uniform float lstr <
ui_type = "input";
ui_tooltip = "Modifier for non-linear sharpening";
> = 1.49;
#line 44
uniform float pstr <
ui_type = "input";
ui_tooltip = "Exponent for non-linear sharpening";
> = 1.272;
#line 1 "D:\The.Elder.Scrolls.V.Skyrim.VR.v1.4.0.15.8\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShade.fxh"
#line 50
namespace ReShade
{
#line 61
static const float AspectRatio = 2656 * (1.0 / 1584);
static const float2 PixelSize = float2((1.0 / 2656), (1.0 / 1584));
static const float2 ScreenSize = float2(2656, 1584);
#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 55 "D:\The.Elder.Scrolls.V.Skyrim.VR.v1.4.0.15.8\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\FineSharp.fx"
#line 59
float4 Src(float a, float b, float2 tex) {
return tex2D(ReShade::BackBuffer, mad( float2((1.0 / 2656), (1.0 / 1584)), float2(a, b), tex));
}
#line 63
float3x3 RGBtoYUV(float Kb, float Kr) {
return float3x3(float3(Kr, 1.0 - Kr - Kb, Kb), float3(-Kr, Kr + Kb - 1.0, 1.0 - Kb) / (2.0 * (1.0 - Kb)), float3(1.0 - Kr, Kr + Kb - 1.0, -Kb) / (2.0 * (1.0 - Kr)));
}
#line 67
float3x3 YUVtoRGB(float Kb, float Kr) {
return float3x3(float3(1.0, 0.0, 2.0 * (1.0 - Kr)), float3(Kb + Kr - 1.0, 2.0 * (1.0 - Kb) * Kb, 2 * Kr * (1.0 - Kr)) / (Kb + Kr - 1.0), float3(1.0, 2.0 * (1.0 - Kb), 0.0));
}
#line 71
void sort(inout float a1, inout float a2) {
float t = min(a1, a2);
a2 = max(a1, a2);
a1 = t;
}
#line 77
float median3(float a1, float a2, float a3) {
sort(a2, a3);
sort(a1, a2);
#line 81
return min(a2, a3);
}
#line 84
float median5(float a1, float a2, float a3, float a4, float a5) {
sort(a1, a2);
sort(a3, a4);
sort(a1, a3);
sort(a2, a4);
#line 90
return median3(a2, a3, a5);
}
#line 93
float median9(float a1, float a2, float a3, float a4, float a5, float a6, float a7, float a8, float a9) {
sort(a1, a2);
sort(a3, a4);
sort(a5, a6);
sort(a7, a8);
sort(a1, a3);
sort(a5, a7);
sort(a1, a5);
#line 102
sort(a3, a5);
sort(a3, a7);
sort(a2, a4);
sort(a6, a8);
sort(a4, a8);
sort(a4, a6);
sort(a2, a6);
#line 110
return median5(a2, a4, a5, a7, a9);
}
#line 113
void sort_min_max7(inout float a1, inout float a2, inout float a3, inout float a4, inout float a5, inout float a6, inout float a7) {
sort(a1, a2);
sort(a3, a4);
sort(a5, a6);
#line 118
sort(a1, a3);
sort(a1, a5);
sort(a2, a6);
#line 122
sort(a4, a5);
sort(a1, a7);
sort(a6, a7);
}
#line 127
void sort_min_max9(inout float a1, inout float a2, inout float a3, inout float a4, inout float a5, inout float a6, inout float a7, inout float a8, inout float a9) {
sort(a1, a2);
sort(a3, a4);
sort(a5, a6);
sort(a7, a8);
#line 133
sort(a1, a3);
sort(a5, a7);
sort(a1, a5);
sort(a2, a4);
#line 138
sort(a6, a7);
sort(a4, a8);
sort(a1, a9);
sort(a8, a9);
}
#line 144
void sort9_partial2(inout float a1, inout float a2, inout float a3, inout float a4, inout float a5, inout float a6, inout float a7, inout float a8, inout float a9) {
sort_min_max9(a1,a2,a3,a4,a5,a6,a7,a8,a9);
sort_min_max7(a2,a3,a4,a5,a6,a7,a8);
}
#line 150
float SharpDiff(float4 c) {
float t = c.a - c.x;
return sign(t) * (sstr / 255.0) * pow(abs(t) / (lstr / 255.0), 1.0 / pstr) * ((t * t) / mad(t, t,  (sstr+0.1)	 / 65025.0));
}
#line 157
float4 PS_FineSharp_P0(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float3 yuv = mul(RGBtoYUV(0.0722, 0.2126), Src(0.0, 0.0, texcoord).rgb ) + float3(0.0, 0.5, 0.5);
return float4(yuv, yuv.x);
}
#line 162
float4 PS_FineSharp_P1(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 o = Src(0.0, 0.0, texcoord);
#line 165
o.x += o.x;
o.x += Src( 0.0, -1.0, texcoord).x + Src(-1.0,  0.0, texcoord).x + Src( 1.0, 0.0, texcoord).x + Src(0.0, 1.0, texcoord).x;
o.x += o.x;
o.x += Src(-1.0, -1.0, texcoord).x + Src( 1.0, -1.0, texcoord).x + Src(-1.0, 1.0, texcoord).x + Src(1.0, 1.0, texcoord).x;
o.x *= 0.0625;
#line 171
return o;
}
#line 174
float4 PS_FineSharp_P2(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 o = Src(0.0, 0.0, texcoord);
#line 177
float t1 = Src(-1.0, -1.0, texcoord).x;
float t2 = Src( 0.0, -1.0, texcoord).x;
float t3 = Src( 1.0, -1.0, texcoord).x;
float t4 = Src(-1.0,  0.0, texcoord).x;
float t5 = o.x;
float t6 = Src( 1.0,  0.0, texcoord).x;
float t7 = Src(-1.0,  1.0, texcoord).x;
float t8 = Src( 0.0,  1.0, texcoord).x;
float t9 = Src( 1.0,  1.0, texcoord).x;
o.x = median9(t1,t2,t3,t4,t5,t6,t7,t8,t9);
#line 188
return o;
}
#line 191
float4 PS_FineSharp_P3(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 o = Src(0.0, 0.0, texcoord);
#line 194
float sd = SharpDiff(o);
o.x = o.a + sd;
sd += sd;
sd += SharpDiff(Src( 0.0, -1.0, texcoord)) + SharpDiff(Src(-1.0,  0.0, texcoord)) + SharpDiff(Src( 1.0, 0.0, texcoord)) + SharpDiff(Src( 0.0, 1.0, texcoord));
sd += sd;
sd += SharpDiff(Src(-1.0, -1.0, texcoord)) + SharpDiff(Src( 1.0, -1.0, texcoord)) + SharpDiff(Src(-1.0, 1.0, texcoord)) + SharpDiff(Src( 1.0, 1.0, texcoord));
sd *= 0.0625;
o.x -= cstr * sd;
o.a = o.x;
#line 204
return o;
}
#line 207
float4 PS_FineSharp_P4(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 o = Src(0.0, 0.0, texcoord);
#line 210
float t1 = Src(-1.0, -1.0, texcoord).a;
float t2 = Src( 0.0, -1.0, texcoord).a;
float t3 = Src( 1.0, -1.0, texcoord).a;
float t4 = Src(-1.0,  0.0, texcoord).a;
float t5 = o.a;
float t6 = Src( 1.0,  0.0, texcoord).a;
float t7 = Src(-1.0,  1.0, texcoord).a;
float t8 = Src( 0.0,  1.0, texcoord).a;
float t9 = Src( 1.0,  1.0, texcoord).a;
#line 220
o.x += t1 + t2 + t3 + t4 + t6 + t7 + t8 + t9;
o.x /= 9.0;
o.x = mad(9.9, (o.a - o.x), o.a);
#line 224
sort9_partial2(t1, t2, t3, t4, t5, t6, t7, t8, t9);
o.x = max(o.x, min(t2, o.a));
o.x = min(o.x, max(t8, o.a));
#line 228
return o;
}
#line 231
float4 PS_FineSharp_P5(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 o = Src(0.0, 0.0, texcoord);
#line 234
float edge = abs(Src(0.0, -1.0, texcoord).x + Src(-1.0, 0.0, texcoord).x + Src(1.0, 0.0, texcoord).x + Src(0.0, 1.0, texcoord).x - 4 * o.x);
o.x = lerp(o.a, o.x, xstr * (1.0 - saturate(edge * xrep)));
#line 237
return o;
}
#line 240
float4 PS_FineSharp_P6(float4 vpos : SV_Position, float2 texcoord : TexCoord) : SV_Target {
float4 rgb = Src(0.0, 0.0, texcoord);
rgb.xyz = mul(YUVtoRGB(0.0722,0.2126), rgb.xyz - float3(0.0, 0.5, 0.5));
return rgb;
}
#line 246
technique Mode1
{
pass ToYUV
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P0;
}
#line 254
pass RemoveGrain11
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P1;
}
#line 260
pass RemoveGrain4
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P2;
}
#line 266
pass FineSharpA
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P3;
}
#line 272
pass FineSharpB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P4;
}
#line 278
pass FineSharpC
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P5;
}
#line 284
pass ToRGB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P6;
}
}
#line 291
technique Mode2
{
pass ToYUV
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P0;
}
#line 299
pass RemoveGrain4
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P2;
}
#line 305
pass RemoveGrain11
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P1;
}
#line 311
pass FineSharpA
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P3;
}
#line 317
pass FineSharpB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P4;
}
#line 323
pass FineSharpC
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P5;
}
#line 329
pass ToRGB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P6;
}
}
#line 336
technique Mode3
{
pass ToYUV
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P0;
}
#line 344
pass RemoveGrain4_1
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P2;
}
#line 350
pass RemoveGrain11
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P1;
}
#line 356
pass RemoveGrain4_2
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P2;
}
#line 362
pass FineSharpA
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P3;
}
#line 368
pass FineSharpB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P4;
}
#line 374
pass FineSharpC
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P5;
}
#line 380
pass ToRGB
{
VertexShader = PostProcessVS;
PixelShader = PS_FineSharp_P6;
}
}

