#line 1 "unknown"

#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\VRToolkit.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 = 1674 * (1.0 / 1001);
static const float2 PixelSize = float2((1.0 / 1674), (1.0 / 1001));
static const float2 ScreenSize = float2(1674, 1001);
#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 10 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\VRToolkit.fx"
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\ReShadeUI.fxh"
#line 98 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\VRToolkit.fx"
#line 100
uniform int VRT_Advanced_help <
ui_type = "radio";
ui_category = "(?) VRToolkit Modes & Settings Help";
ui_category_closed = true;
ui_label = " ";
ui_text =
" Open the \"Preprocess definitions\" section to change the folowing modes.\n"
"\n"
" Sharpening:        0 - Disabled\n"
"                    1 - Filmic Anamorph Sharpening\n"
"                    2 - CAS (Contrast Adaptive Sharpening)\n"
"\n"
" Color Correction:  0 - Disabled\n"
"                    1 - LUT (Look up table)\n"
"                    2 - Contrast & Saturation\n"
"\n"
" Circular Masking:  0 - Disabled\n"
"                    1 - Enabled to improve performance\n"
"\n"
" Dithering:         0 - Disabled\n"
"                    1 - Enabled to reduce banding on gradients.\n"
"\n"
" Antialiasing:      0 - Disabled\n"
"                    1 - FXAA\n"
"";
#line 126
>;
#line 132
static const float GAMMA_SRGB_FACTOR = 1/2.2;
#line 139
sampler backBufferSampler {
Texture = ReShade::BackBufferTex;
#line 142
MagFilter = POINT; MinFilter = POINT;
#line 146
};
#line 149
sampler backBufferSamplerScalable {
Texture = ReShade::BackBufferTex;
MagFilter = LINEAR; MinFilter = LINEAR;
#line 155
};
#line 1 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\VRToolkitShaders.fxh"
#line 15
float3 ApplySRGBCurve( float3 x )
{
#line 18
return x < 0.0031308 ? 12.92 * x : 1.055 * pow(x, 1.0 / 2.4) - 0.055;
}
#line 22
float3 ApplySRGBCurve_Fast( float3 x )
{
return x < 0.0031308 ? 12.92 * x : 1.13005 * sqrt(x - 0.00228) - 0.13448 * x + 0.005719;
}
#line 58
uniform int _CircularMaskHelp <
ui_category = "Circular Masking Mask";
ui_type = "radio";
ui_label = " ";
ui_text = "NOTE: Adjust \"Circle Radius\" for your VR headset below";
>;
#line 65
uniform float CircularMaskSize <
ui_category = "Circular Masking Mask";
ui_type = "slider";
ui_label = "Circle Radius (?)";
ui_tooltip = "Adjusts the size of the circle from the center of the screen towards the edges.\n"
"This can slightly improve the performance the smaller the radius is.\n\n"
"";
ui_min = 0.0; ui_max = 1.0; ui_step = 0.01;
> = 0.30;
#line 76
uniform float CircularMaskSmoothness <
ui_category = "Circular Masking Mask";
ui_type = "slider";
ui_label = "Edge Sharpness";
ui_tooltip = "Adjusts the edge of the circular mask to allow smaller radius while reducing the prominence of the edge";
ui_min = 1.0; ui_max = 10; ui_step = 0.1;
> = 5.0;
#line 85
uniform float CircularMaskHorizontalOffset <
ui_category = "Circular Masking Mask";
ui_type = "slider";
ui_label = "Horizional offset";
ui_tooltip = "Adjusts the mask offset from the center horizontally";
ui_min = 0.3; ui_max = 0.5; ui_step = 0.001;
> = 0.3;
#line 93
uniform bool CircularMaskPreview <       ui_type = "input"; 
ui_category = "Circular Masking Mask";
ui_label = "Mask Preview";
ui_tooltip = "Preview circular mask for easy adjustments.";
> = false;
#line 100
float CircularMask( float2 texcoord )
{
float2 fromCenter;
#line 105
fromCenter = float2(texcoord.x < 0.5 ? CircularMaskHorizontalOffset :  1 - CircularMaskHorizontalOffset, 0.5) - texcoord;
#line 111
fromCenter.x *= ReShade::AspectRatio;
#line 113
float distSqr = dot(fromCenter, fromCenter);
#line 116
float maskSizeSqr = CircularMaskSize * CircularMaskSize;
if (distSqr < maskSizeSqr){
#line 119
float diff = (distSqr/maskSizeSqr);
return 1 - pow(diff,CircularMaskSmoothness);
#line 124
} else{
return 0;
}
}
#line 145
uniform float FAS_Strength <      ui_type = "slider"; 
ui_label = "Strength";
ui_category = "Sharpening (MODE 1: Filmic Anamorph Sharpen)";
ui_category_closed = false;
ui_min = 0.0; ui_max = 250; ui_step = 1;
> = 125;
#line 152
uniform float FAS_Radius <      ui_type = "slider"; 
ui_label = "Radius";
ui_tooltip = "High-pass cross offset in pixels";
ui_category = "Sharpening (MODE 1: Filmic Anamorph Sharpen)";
ui_min = 0.0; ui_max = 2.0; ui_step = 0.01;
> = 0.10;
#line 159
uniform float FAS_Clamp <      ui_type = "slider"; 
ui_label = "Clamping";
ui_category = "Sharpening (MODE 1: Filmic Anamorph Sharpen)";
ui_min = 0.5; ui_max = 1.0; ui_step = 0.001;
> = 0.525;
#line 165
uniform bool FAS_Preview <       ui_type = "input"; 
ui_label = "Preview sharpen layer";
ui_category = "Sharpening (MODE 1: Filmic Anamorph Sharpen)";
ui_tooltip = "Preview sharpen layer and mask for adjustment.\n";
#line 170
> = false;
#line 175
static const float3 LumaCoefficient = float3(0.2126, 0.7152, 0.0722);
#line 178
float Overlay(float LayerA, float LayerB)
{
float MinA = min(LayerA, 0.5);
float MinB = min(LayerB, 0.5);
float MaxA = max(LayerA, 0.5);
float MaxB = max(LayerB, 0.5);
return 2.0 * (MinA * MinB + MaxA + MaxB - MaxA * MaxB) - 1.5;
}
#line 189
float3 Overlay3(float3 LayerA, float3 LayerB)
{
float3 MinA = min(LayerA, 0.5);
float3 MinB = min(LayerB, 0.5);
float3 MaxA = max(LayerA, 0.5);
float3 MaxB = max(LayerB, 0.5);
return 2.0 * (MinA * MinB + MaxA + MaxB - MaxA * MaxB) - 1.5;
}
#line 200
float Overlay(float LayerAB)
{
float MinAB = min(LayerAB, 0.5);
float MaxAB = max(LayerAB, 0.5);
return 2.0 * (MinAB * MinAB + MaxAB + MaxAB - MaxAB * MaxAB) - 1.5;
}
#line 208
float3 FilmicAnamorphSharpenPS(float4 backBuffer, float4 pos : SV_Position, float2 UvCoord : TEXCOORD0) : COLOR
{
#line 213
float2 Pixel =  float2((1.0 / 1674), (1.0 / 1001)) * FAS_Radius;
#line 215
float2 NorSouWesEst[4] = {
float2(UvCoord.x, UvCoord.y + Pixel.y),
float2(UvCoord.x, UvCoord.y - Pixel.y),
float2(UvCoord.x + Pixel.x, UvCoord.y),
float2(UvCoord.x - Pixel.x, UvCoord.y)
};
#line 223
float3 neighborPixelSamples = float3(0,0,0);
#line 225
[unroll]
for(int s = 0; s < 4; s++)
neighborPixelSamples += tex2D(backBufferSamplerScalable, NorSouWesEst[s]).rgb;
#line 230
float HighPassColor = dot((neighborPixelSamples * 0.25) - backBuffer.rgb, LumaCoefficient);
#line 233
HighPassColor *= FAS_Strength;
#line 236
HighPassColor = 0.5 - HighPassColor;
#line 239
HighPassColor = max(min(HighPassColor, FAS_Clamp), 1.0 - FAS_Clamp);
#line 242
return FAS_Preview ? HighPassColor : saturate(Overlay3(backBuffer.rgb,HighPassColor.rrr));
}
#line 161 "D:\Games\The Elder Scrolls V Skyrim VR\reshade-shaders\Shaders\VRToolkit.fx"
#line 165
float3 SharpeningStep(float4 backBuffer, float4 position , float2 texcoord ){
#line 170
return FilmicAnamorphSharpenPS(backBuffer, position, texcoord);
#line 176
}
#line 210
float4 CombineVRShaderPS(in float4 position : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target {
#line 213
float4 backBuffer = float4(tex2D(backBufferSampler, texcoord.xy).rgb, 1.0);
#line 217
if (!any(backBuffer.rgb))
{
discard;
#line 221
}
#line 225
float circularMask = CircularMask(texcoord);
#line 260
if(circularMask != 0){
#line 262
float3 sharpeningResult = SharpeningStep(backBuffer,position,texcoord);
#line 264
backBuffer.rgb = lerp(backBuffer.rgb,sharpeningResult,circularMask);
#line 269
}
#line 292
if(CircularMaskPreview){
#line 294
backBuffer.gb += circularMask * 0.20;
}
#line 299
return backBuffer;
}
#line 305
technique VRToolkit  <ui_tooltip = "This shader combines multiple shaders tailored to be usable in VR into one render pass"; >
{
pass
{
VertexShader = PostProcessVS;
PixelShader = CombineVRShaderPS;
#line 316
}
}

