#line 1 "unknown"

#line 1 "D:\Games\Kenshi\reshade-shaders\Shaders\Depth3D.fx"
#line 1 "D:\Games\Kenshi\reshade-shaders\Shaders\ReShadeUI.fxh"
#line 66 "D:\Games\Kenshi\reshade-shaders\Shaders\Depth3D.fx"
#line 1 "D:\Games\Kenshi\reshade-shaders\Shaders\ReShade.fxh"
#line 50
namespace ReShade
{
#line 61
static const float AspectRatio = 1360 * (1.0 / 768);
static const float2 PixelSize = float2((1.0 / 1360), (1.0 / 768));
static const float2 ScreenSize = float2(1360, 768);
#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 67 "D:\Games\Kenshi\reshade-shaders\Shaders\Depth3D.fx"
#line 70
uniform float Divergence <
ui_type = "drag";
ui_min = 10; ui_max = 60; ui_step = 0.25;
ui_label = "Divergence Slider";
ui_tooltip = "Divergence increases differences between the left and right retinal images and allows you to experience depth.\n"
"The process of deriving binocular depth information is called stereopsis.";
ui_category = "Divergence & Convergence";
> = 25;
#line 79
uniform float ZPD <
ui_type = "drag";
ui_min = 0.0; ui_max = 0.250;
ui_label = "Convergence";
ui_tooltip = "ZPD controls the focus distance for the screen Pop-out effect also known as ZPD.\n"
"For FPS Games keeps this low Since you don't want your gun to pop out of screen.\n"
"This is controled by Convergence Mode.\n"
"Default is 0.025, Zero is off.";
ui_category = "Divergence & Convergence";
> = 0.025;
#line 90
uniform int Auto_Balance_Ex <
ui_type = "slider";
ui_min = 0; ui_max = 2;
ui_label = "Auto Balance";
ui_tooltip = "Automatically Balance between ZPD Depth and Scene Depth.\n"
"Default is Off.";
ui_category = "Divergence & Convergence";
> = 0;
#line 99
uniform int ZPD_Boundary <
ui_type = "combo";
ui_items = "Off\0Normal\0FPS\0Edge\0";
ui_label = "Screen Boundary Detection";
ui_tooltip = "This selection menu gives extra boundary conditions to ZPD.\n"
"This treats your screen as a virtual wall.\n"
"Default is Off.";
ui_category = "Divergence & Convergence";
> = 0;
#line 109
uniform int View_Mode <
ui_type = "combo";
ui_items = "View Mode Normal\0View Mode Alpha\0";
ui_label = "View Mode";
ui_tooltip = "Changes the way the shader fills in the occlude section in the image.\n"
"Normal is default output and Alpha is used for higher ammounts of Semi-Transparent objects.\n"
"Default is Normal";
ui_category = "Occlusion Masking";
> = 0;
#line 119
uniform int Custom_Sidebars <
ui_type = "combo";
ui_items = "Mirrored Edges\0Black Edges\0Stretched Edges\0";
ui_label = "Edge Handling";
ui_tooltip = "Edges consideration selection for cropping.";
ui_category = "Occlusion Masking";
> = 1;
#line 127
uniform bool Performance_Mode <
ui_label = "Performance Mode";
ui_tooltip = "Performance Mode Lowers Occlusion Quality Processing so that there is a small boost to FPS.\n"
"Default is off.";
ui_category = "Occlusion Masking";
> = false;
#line 134
uniform int Depth_Map <
ui_type = "combo";
ui_items = "Depth Normal\0Depth Reversed\0";
ui_label = "Depth Map Selection";
ui_tooltip = "Linearization for the zBuffer also known as Depth Map.\n"
"DM0 is Z-Normal and DM1 is Z-Reversed.\n";
ui_category = "Depth Map";
> = 0;
#line 143
uniform float Depth_Map_Adjust <
ui_type = "drag";
ui_min = 1.0; ui_max = 250.0; ui_step = 0.125;
ui_label = "Depth Map Adjustment";
ui_tooltip = "This allows for you to adjust the DM precision.\n"
"Adjust this to keep it as low as possible.\n"
"Default is 7.5";
ui_category = "Depth Map";
> = 7.5;
#line 153
uniform float Offset <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_label = "Depth Map Offset";
ui_tooltip = "Depth Map Offset is for non conforming ZBuffer.\n"
"It's rare if you need to use this in any game.\n"
"Use this to make adjustments to DM 0 or DM 1.\n"
"Default and starts at Zero and it's Off.";
ui_category = "Depth Map";
> = 0.0;
#line 164
uniform bool Depth_Detection <
ui_label = "Depth Detection";
ui_tooltip = "Use this to dissable/enable in game Depth Detection.";
ui_category = "Depth Map";
> = false;
#line 170
uniform bool Depth_Map_Flip <
ui_label = "Depth Map Flip";
ui_tooltip = "Flip the depth map if it is upside down.";
ui_category = "Depth Map";
> = false;
#line 176
uniform bool Depth_View <
ui_label = "Depth View";
ui_tooltip = "Use this to to figure out if depth is working in your game.";
ui_category = "Depth Map";
> = false;
#line 182
uniform int WP <
ui_type = "combo";
ui_items = "Weapon Profile Off\0Custom WP\0";
ui_label = "Weapon Profiles";
ui_tooltip = "Make a Weapon Profile for your game.";
ui_category = "Weapon Hand Adjust";
> = 0;
#line 190
uniform float3 Weapon_Adjust <
ui_type = "drag";
ui_min = 0.0; ui_max = 250.0;
ui_label = "Weapon Hand Adjust";
ui_tooltip = "Adjust Weapon depth map for your games.\n"
"X, CutOff Point used to set a diffrent scale for first person hand apart from world scale.\n"
"Y, Precision is used to adjust the first person hand in world scale.\n"
"Default is float2(X 0.0, Y 0.0, Z 0.0)";
ui_category = "Weapon Hand Adjust";
> = float3(0.0,0.0,0.0);
#line 201
uniform int FPSDFIO <
ui_type = "combo";
ui_items = "Off\0Press\0Hold Down\0";
ui_label = "FPS Focus Depth";
ui_tooltip = "This lets the shader handle real time depth reduction for aiming down your sights.\n"
"This may induce Eye Strain so take this as an Warning.";
ui_category = "Weapon Hand Adjust";
> = 0;
#line 210
uniform int2 Eye_Fade_Reduction_n_Power <
ui_type = "slider";
ui_min = 0; ui_max = 2;
ui_label = "Eye Selection & Fade Reduction";
ui_tooltip = "Fade Reduction decresses the depth ammount by a current percentage.\n"
"One is Right Eye only, Two is Left Eye Only, and Zero Both Eyes.\n"
"Default is int( X 0 , Y 0 ).";
ui_category = "Weapon Hand Adjust";
> = int2(0,0);
#line 220
uniform float Weapon_ZPD_Boundary <
ui_type = "slider";
ui_min = 0; ui_max = 0.5;
ui_label = " Weapon Screen Boundary Detection";
ui_tooltip = "This selection menu gives extra boundary conditions to WZPD.";
ui_category = "Weapon Hand Adjust";
> = 0;
#line 228
uniform float2 HUD_Adjust <
ui_type = "drag";
ui_min = 0.0; ui_max = 1.0;
ui_label = "HUD Mode";
ui_tooltip = "Adjust HUD for your games.\n"
"X, CutOff Point used to set a seperation point bettwen world scale and the HUD also used to turn HUD MODE On or Off.\n"
"Y, Pushes or Pulls the HUD in or out of the screen if HUD MODE is on.\n"
"This is only for UI elements that show up in the Depth Buffer.\n"
"Default is float2(X 0.0, Y 0.5)";
ui_category = "Heads-Up Display";
> = float2(0.0,0.5);
#line 240
uniform int Stereoscopic_Mode <
ui_type = "combo";
ui_items = "Side by Side Half & VR Theater\0Top and Bottom\0Line Interlaced\0Anaglyph 3D Red/Cyan\0Anaglyph 3D Green/Magenta\0";
ui_label = "3D Display Modes";
ui_tooltip = "Stereoscopic 3D display output selection.\n"
"Use your favorite VR app to add the correct barrel distortion for VR.";
ui_category = "Stereoscopic Options";
> = 0;
#line 249
uniform int Perspective <
ui_type = "drag";
ui_min = -100; ui_max = 100;
ui_label = "Perspective Slider";
ui_tooltip = "Determines the perspective point of the two images this shader produces.\n"
"For an HMD, use Polynomial Barrel Distortion shader to adjust for IPD.\n"
"Do not use this perspective adjustment slider to adjust for IPD.\n"
"Default is Zero.";
ui_category = "Stereoscopic Options";
> = 0;
#line 260
uniform bool Theater_Mode <
ui_label = "Theater Mode";
ui_tooltip = "Sets the 3D Shader in to Theater mode for VR only Usable in Side By Side Half.";
ui_category = "Stereoscopic Options";
> = false;
#line 266
uniform bool Eye_Swap <
ui_label = "Swap Eyes";
ui_tooltip = "L/R to R/L.";
ui_category = "Stereoscopic Options";
> = false;
#line 272
uniform int Cursor_Type <
ui_type = "combo";
ui_items = "Off\0FPS\0ALL\0RTS\0";
ui_label = "Cursor Selection";
ui_tooltip = "Choose the cursor type you like to use.\n"
"Default is Zero.";
ui_category = "Cursor Adjustments";
> = 0;
#line 281
uniform int2 Cursor_SC <
ui_type = "drag";
ui_min = 0; ui_max = 5;
ui_label = "Cursor Adjustments";
ui_tooltip = "This controlls the Size & Color.\n"
"Defaults are ( X 1, Y 2 ).";
ui_category = "Cursor Adjustments";
> = int2(1,2);
#line 290
uniform bool Cursor_Lock <
ui_label = "Cursor Lock";
ui_tooltip = "Screen Cursor to Screen Crosshair Lock.";
ui_category = "Cursor Adjustments";
> = false;
#line 296
static const float Auto_Balance_Clamp = 0.5; 
static const float Auto_Depth_Adjust = 0.1; 
#line 299
uniform bool Mask_Cycle < source = "key"; keycode =  110 ; toggle = true; >;
uniform bool Trigger_Fade_A < source = "mousebutton"; keycode =  1 ; toggle = true; mode = "toggle";>;
uniform bool Trigger_Fade_B < source = "mousebutton"; keycode =  1 ;>;
uniform int ran < source = "random"; min = 0; max = 1; >;
uniform float2 Mousecoords < source = "mousepoint"; > ;
#line 305
uniform float frametime < source = "frametime";>;
uniform float timer < source = "timer"; >;
#line 312
float fmod(float a, float b)
{
float c = frac(abs(a / b)) * abs(b);
return a < 0 ? -c : c;
}
#line 318
sampler DepthBuffer
{
Texture = ReShade::DepthBufferTex;
AddressU = BORDER;
AddressV = BORDER;
AddressW = BORDER;
#line 325
};
#line 327
sampler BackBufferMIRROR
{
Texture = ReShade::BackBufferTex;
AddressU = MIRROR;
AddressV = MIRROR;
AddressW = MIRROR;
};
#line 335
sampler BackBufferBORDER
{
Texture = ReShade::BackBufferTex;
AddressU = BORDER;
AddressV = BORDER;
AddressW = BORDER;
};
#line 343
sampler BackBufferCLAMP
{
Texture = ReShade::BackBufferTex;
AddressU = CLAMP;
AddressV = CLAMP;
AddressW = CLAMP;
};
#line 351
texture texDM < pooled = true; > { Width = 1360; Height = 768; Format = RGBA16F; };
#line 353
sampler SamplerDM
{
Texture = texDM;
};
#line 358
texture texzBuffer < pooled = true; > { Width = 1360; Height = 768; Format = R16F; };
#line 360
sampler SamplerzBuffer
{
Texture = texzBuffer;
};
#line 370
texture texLum {Width = 256*0.5; Height = 256*0.5; Format = RGBA16F; MipLevels = 8;}; 
#line 372
sampler SamplerLum
{
Texture = texLum;
};
#line 377
float2 Lum(float2 texcoord)
{   
return saturate(tex2Dlod(SamplerLum,float4(texcoord,0,11)).xy);
}
#line 382
float4 CSB(float2 texcoords)
{
if(Custom_Sidebars == 0)
return tex2Dlod(BackBufferMIRROR,float4(texcoords,0,0));
else if(Custom_Sidebars == 1)
return tex2Dlod(BackBufferBORDER,float4(texcoords,0,0));
else
return tex2Dlod(BackBufferCLAMP,float4(texcoords,0,0));
}
#line 392
float4 MouseCursor(float2 texcoord )
{   float4 Out = CSB(texcoord),Color;
float Cursor, A = 0.9375, B = 1-A;
if(Cursor_Type > 0)
{
float CCA = 0.005, CCB = 0.00025, CCC = 0.25, CCD = 0.00125, Arrow_Size_A = 0.7, Arrow_Size_B = 1.3, Arrow_Size_C = 4.0;
float2 MousecoordsXY = Mousecoords *  float2((1.0 / 1360), (1.0 / 768)), center = texcoord, Screen_Ratio = float2(1.75,1.0), Size_Color = float2(1+Cursor_SC.x,Cursor_SC.y);
float THICC = (1.5+Size_Color.x) * CCB, Size = Size_Color.x * CCA, Size_Cubed = (Size_Color.x*Size_Color.x) * CCD;
#line 401
if (Cursor_Lock)
MousecoordsXY = float2(0.5,0.5);
if (Cursor_Type == 3)
Screen_Ratio = float2(1.6,1.0);
#line 406
float S_dist_fromHorizontal = abs((center.x - (Size* Arrow_Size_B) / Screen_Ratio.x) - MousecoordsXY.x) * Screen_Ratio.x, dist_fromHorizontal = abs(center.x - MousecoordsXY.x) * Screen_Ratio.x ;
float S_dist_fromVertical = abs((center.y - (Size* Arrow_Size_B)) - MousecoordsXY.y), dist_fromVertical = abs(center.y - MousecoordsXY.y);
#line 410
float B = min(max(THICC - dist_fromHorizontal,0),max(Size-dist_fromVertical,0)), A = min(max(THICC - dist_fromVertical,0),max(Size-dist_fromHorizontal,0));
float CC = A+B; 
#line 414
float SSC = min(max(Size_Cubed - dist_fromHorizontal,0),max(Size_Cubed-dist_fromVertical,0)); 
#line 416
if (Cursor_Type == 3)
{
dist_fromHorizontal = abs((center.x - Size / Screen_Ratio.x) - MousecoordsXY.x) * Screen_Ratio.x ;
dist_fromVertical = abs(center.y - Size - MousecoordsXY.y);
}
#line 422
float C = all(min(max(Size - dist_fromHorizontal,0),max(Size-dist_fromVertical,0)));
C -= all(min(max(Size - dist_fromHorizontal * Arrow_Size_C,0),max(Size - dist_fromVertical * Arrow_Size_C,0)));
C -= all(min(max((Size * Arrow_Size_A) - S_dist_fromHorizontal,0),max((Size * Arrow_Size_A)-S_dist_fromVertical,0)));
#line 426
if(Cursor_Type == 1)
Cursor = CC;
else if (Cursor_Type == 2)
Cursor = SSC;
else if (Cursor_Type == 3)
Cursor = C;
#line 434
float3 CCArray[6] = {
float3(1,1,1),
float3(0,0,1),
float3(0,1,0),
float3(1,0,0),
float3(1,0,1),
float3(0,0,0) 
};
int CSTT = clamp(Cursor_SC.y,0,5);
Color.rgb = CCArray[CSTT];
}
#line 446
if(Depth_View)
Out.rgb = tex2Dlod(SamplerzBuffer,float4(texcoord,0,0)).xxx;
#line 449
return Cursor ? Color : Out;
}
#line 453
float Depth(float2 texcoord)
{
if (Depth_Map_Flip)
texcoord.y =  1 - texcoord.y;
#line 458
float zBuffer = tex2Dlod(DepthBuffer, float4(texcoord,0,0)).x, Far = 1., Near = 0.125/Depth_Map_Adjust; 
#line 460
float2 Offsets = float2(1 + Offset,1 - Offset), Z = float2( zBuffer, 1-zBuffer );
#line 462
if (Offset > 0)
Z = min( 1, float2( Z.x * Offsets.x , Z.y / Offsets.y  ));
#line 465
if (Depth_Map == 0) 
zBuffer = Far * Near / (Far + Z.x * (Near - Far));
else if (Depth_Map == 1) 
zBuffer = Far * Near / (Far + Z.y * (Near - Far));
return saturate(zBuffer);
}
#line 472
float Fade_in_out(float2 texcoord)
{
float Trigger_Fade, AA = (1- 0.5625 )*1000, PStoredfade = tex2D(SamplerLum,texcoord - 1).z;
#line 476
if(FPSDFIO == 1)
Trigger_Fade = Trigger_Fade_A;
else if(FPSDFIO == 2)
Trigger_Fade = Trigger_Fade_B;
#line 481
return PStoredfade + (Trigger_Fade - PStoredfade) * (1.0 - exp(-frametime/AA)); 
}
#line 484
float Fade(float2 texcoord)
{
#line 487
float CD, Detect, RArrayA[2] = {0.375,0.625}, RArrayB[2] = {0.25,0.75};
if(ZPD_Boundary > 0)
{
float CDArrayX[4] = {0.25,0.5,0.75,RArrayA[ran]};
float CDArrayY[4] = {0.125,0.25,0.375,0.5};
float CDArrayA[4] = {0.25,0.5,0.75,RArrayA[ran]};
float CDArrayB[4] = {0.05,0.5,0.95,RArrayB[ran]};
#line 495
[loop]
for( int i = 0 ; i < 4; i++ )
{
for( int j = 0 ; j < 4; j++ )
{
if(ZPD_Boundary == 1)
CD = 1 - ZPD / Depth( float2( CDArrayA[i], CDArrayA[j]) );
else if(ZPD_Boundary == 2)
CD = 1 - ZPD / Depth( float2( CDArrayX[i], CDArrayY[j]) );
else if(ZPD_Boundary == 3)
CD = 1 - ZPD / Depth( float2( CDArrayB[i], CDArrayB[j]) );
#line 507
if( CD < 0)
Detect = 1;
}
}
}
float Trigger_Fade = Detect, AA = (1- 0.5625 )*1000, PStoredfade = tex2Dlod(SamplerLum,float4(texcoord + 1,0,0)).z;
#line 514
return PStoredfade + (Trigger_Fade - PStoredfade) * (1.0 - exp(-frametime/AA)); 
}
#line 518
float2 WeaponDepth(float2 texcoord)
{ 
#line 521
float3 WA_XYZ = float3(Weapon_Adjust.x,Weapon_Adjust.y,Weapon_Adjust.z);
#line 525
if (Depth_Map_Flip)
texcoord.y =  1 - texcoord.y;
#line 528
float zBufferWH = tex2Dlod(DepthBuffer, float4(texcoord,0,0)).x, Far = 1.0, Near = 0.125/WA_XYZ.y;  
#line 530
float2 Offsets = float2(1 + WA_XYZ.z,1 - WA_XYZ.z), Z = float2( zBufferWH, 1-zBufferWH );
#line 532
if (WA_XYZ.z > 0)
Z = min( 1, float2( Z.x * Offsets.x , Z.y / Offsets.y  ));
#line 535
[branch] if (Depth_Map == 0)
zBufferWH = Far * Near / (Far + Z.x * (Near - Far));
else if (Depth_Map == 1)
zBufferWH = Far * Near / (Far + Z.y * (Near - Far));
#line 540
return float2(saturate(zBufferWH), WA_XYZ.x);
}
#line 543
float3 DepthMap(in float4 position : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
float4 DM = Depth(texcoord).xxxx;
float R, G, B, WD = WeaponDepth(texcoord).x, CoP = WeaponDepth(texcoord).y, CutOFFCal = (CoP/Depth_Map_Adjust) * 0.5; 
CutOFFCal = step(DM.x,CutOFFCal);
#line 549
if (!WP)
{
DM.x = DM.x;
}
else
{
DM.x = lerp(DM.x,WD,CutOFFCal);
DM.y = lerp(0.0,WD,CutOFFCal);
DM.z = lerp(0.5,WD,CutOFFCal);
}
#line 560
R = DM.x; 
G = DM.y > smoothstep(0,2.5,DM.w); 
B = DM.z; 
#line 565
if(texcoord.x <  float2((1.0 / 1360), (1.0 / 768)).x * 2 && texcoord.y <  float2((1.0 / 1360), (1.0 / 768)).y * 2)
R = Fade_in_out(texcoord);
if(1-texcoord.x <  float2((1.0 / 1360), (1.0 / 768)).x * 2 && 1-texcoord.y <  float2((1.0 / 1360), (1.0 / 768)).y * 2)
R = Fade(texcoord);
#line 570
return saturate(float3(R,G,B));
}
#line 573
float AutoDepthRange(float d, float2 texcoord )
{
float LumAdjust_ADR = smoothstep(-0.0175,Auto_Depth_Adjust,Lum(texcoord).x);
return min(1,( d - 0 ) / ( LumAdjust_ADR - 0));
}
#line 579
float2 Conv(float D,float2 texcoord)
{
float Z = ZPD, WZP = 0.5, ZP = 0.5, ALC = abs(Lum(texcoord).x), W_Convergence =  0.025 ;
#line 583
if (Weapon_ZPD_Boundary > 0)
{   
float WZPDB = 1 -  0.025  / tex2Dlod(SamplerDM,float4(float2(0.5,0.9375),0,0)).x;
if (WZPDB < -0.1)
W_Convergence *= 0.5-Weapon_ZPD_Boundary;
}
#line 590
W_Convergence = 1 - W_Convergence / D;
#line 592
if (Auto_Depth_Adjust > 0)
D = AutoDepthRange(D,texcoord);
#line 595
if(Auto_Balance_Ex > 0 )
ZP = saturate(ALC);
#line 598
Z *= lerp( 1, 0.5, smoothstep(0,1,tex2Dlod(SamplerLum,float4(texcoord + 1,0,0)).z));
#line 600
float Convergence = 1 - Z / D;
if (ZPD == 0)
ZP = 1;
#line 604
if ( 0.025  <= 0)
WZP = 1;
#line 607
if (ALC <= 0.025)
WZP = 1;
#line 610
ZP = min(ZP,Auto_Balance_Clamp);
#line 612
return float2(lerp(Convergence,D, ZP),lerp(W_Convergence,D,WZP));
}
#line 615
float zBuffer(in float4 position : SV_Position, in float2 texcoord : TEXCOORD) : SV_Target
{
float3 DM = tex2Dlod(SamplerDM,float4(texcoord,0,0)).xyz;
#line 619
if (WP == 0 ||  0.025  == 0)
DM.y = 0;
#line 622
DM.y = lerp(Conv(DM.x,texcoord).x, Conv(DM.z,texcoord).y, DM.y);
#line 624
if ( Depth_Detection )
{   
float D_A = tex2Dlod(SamplerDM,float4(float2(0.5,0.0),0,0)).x, D_B = tex2Dlod(SamplerDM,float4(float2(0.0,1.0),0,0)).x;
#line 628
if (D_A != 1 && D_B != 1)
{
if (D_A == D_B)
DM = 0.0625;
}
}
#line 635
return DM.y;
}
#line 638
float2 Parallax(float Diverge, float2 Coordinates) 
{   float2 ParallaxCoord = Coordinates;
float Perf = 1, MS = Diverge *  float2((1.0 / 1360), (1.0 / 768)).x;
#line 642
if(Performance_Mode)
Perf = .5;
#line 645
float D = abs(Diverge), Cal_Steps = (D * Perf) + (D * 0.04), Steps = clamp(Cal_Steps,0,255);
#line 647
float LayerDepth = rcp(Steps);
#line 649
float deltaCoordinates = MS * LayerDepth, CurrentDepthMapValue = tex2Dlod(SamplerzBuffer,float4(ParallaxCoord,0,0)).x, CurrentLayerDepth = 0, DepthDifference;
float2 DB_Offset = float2(Diverge * 0.03, 0) *  float2((1.0 / 1360), (1.0 / 768));
#line 652
if(View_Mode == 1)
DB_Offset = 0;
#line 658
[loop]
while ( CurrentDepthMapValue > CurrentLayerDepth) 
{   
ParallaxCoord.x -= deltaCoordinates;
#line 663
CurrentDepthMapValue = tex2Dlod(SamplerzBuffer,float4(ParallaxCoord - DB_Offset,0,0)).x;
#line 665
CurrentLayerDepth += LayerDepth;
continue;
}
#line 669
float2 PrevParallaxCoord = float2(ParallaxCoord.x + deltaCoordinates, ParallaxCoord.y);
float beforeDepthValue = tex2Dlod(SamplerzBuffer,float4( ParallaxCoord ,0,0)).x + LayerDepth - CurrentLayerDepth, afterDepthValue = CurrentDepthMapValue - CurrentLayerDepth;
#line 672
float weight = afterDepthValue / (afterDepthValue - beforeDepthValue);
ParallaxCoord = PrevParallaxCoord * weight + ParallaxCoord * (1. - weight);
#line 675
if(View_Mode == 0)
ParallaxCoord += DB_Offset * 0.625;
#line 678
DepthDifference = (afterDepthValue-beforeDepthValue) * MS;
if(View_Mode == 1)
ParallaxCoord.x -= DepthDifference;
#line 682
return ParallaxCoord;
}
#line 685
float3 HUD(float3 HUD, float2 texcoord )
{
float Mask_Tex, CutOFFCal = ((HUD_Adjust.x * 0.5)/Depth_Map_Adjust) * 0.5, COC = step(Depth(texcoord).x,CutOFFCal); 
#line 690
if (HUD_Adjust.x > 0)
HUD = COC > 0 ? tex2D(BackBufferCLAMP,texcoord).rgb : HUD;
#line 701
return saturate(HUD);
}
#line 704
float3 PS_calcLR(float2 texcoord)
{
float2 TCL, TCR, TexCoords = texcoord;
#line 708
[branch] if (Stereoscopic_Mode == 0)
{
TCL = float2(texcoord.x*2,texcoord.y);
TCR = float2(texcoord.x*2-1,texcoord.y);
}
else if(Stereoscopic_Mode == 1)
{
TCL = float2(texcoord.x,texcoord.y*2);
TCR = float2(texcoord.x,texcoord.y*2-1);
}
else
{
TCL = float2(texcoord.x,texcoord.y);
TCR = float2(texcoord.x,texcoord.y);
}
#line 724
TCL +=  float2( (Perspective *  float2((1.0 / 1360), (1.0 / 768)).x) * 0.5, 0) ;
TCR -=  float2( (Perspective *  float2((1.0 / 1360), (1.0 / 768)).x) * 0.5, 0) ;
#line 727
float D = Divergence;
if (Eye_Swap)
D = -Divergence;
#line 731
float FadeIO = smoothstep(0,1,1-Fade_in_out(texcoord).x), FD = D, FD_Adjust = 0.1;
#line 733
if( Eye_Fade_Reduction_n_Power.y == 1)
FD_Adjust = 0.2;
else if( Eye_Fade_Reduction_n_Power.y == 2)
FD_Adjust = 0.3;
#line 738
if (FPSDFIO == 1 || FPSDFIO == 2)
FD = lerp(FD * FD_Adjust,FD,FadeIO);
#line 741
float2 DLR = float2(FD,FD);
#line 743
if( Eye_Fade_Reduction_n_Power.x == 1)
DLR = float2(D,FD);
else if( Eye_Fade_Reduction_n_Power.x == 2)
DLR = float2(FD,D);
#line 748
float4 image = 1, accum, color, Left = MouseCursor(Parallax(-DLR.x, TCL)), Right = MouseCursor(Parallax(DLR.y, TCR));
#line 750
float HUD_Adjustment = ((0.5 - HUD_Adjust.y)*25.) *  float2((1.0 / 1360), (1.0 / 768)).x;
Left.rgb = HUD(Left.rgb,float2(TCL.x - HUD_Adjustment,TCL.y));
Right.rgb = HUD(Right.rgb,float2(TCR.x + HUD_Adjustment,TCR.y));
#line 754
float2 gridxy = floor(float2(TexCoords.x * 1360, TexCoords.y * 768)); 
#line 756
if(Stereoscopic_Mode == 0)
color = TexCoords.x < 0.5 ? Left : Right;
else if(Stereoscopic_Mode == 1)
color = TexCoords.y < 0.5 ? Left : Right;
else if(Stereoscopic_Mode == 2)
color = fmod(gridxy.y,2.0) ? Right : Left;
else if(Stereoscopic_Mode >= 3)
{
float3 HalfLA = dot(Left.rgb,float3(0.299, 0.587, 0.114)), HalfRA = dot(Right.rgb,float3(0.299, 0.587, 0.114));
float3 LMA = lerp(HalfLA,Left.rgb,0.75), RMA = lerp(HalfRA,Right.rgb,0.75);
#line 767
float4 cA = float4(LMA,1);
float4 cB = float4(RMA,1);
#line 770
if (Stereoscopic_Mode == 3) 
{
float4 LeftEyecolor = float4(1.0,0.0,0.0,1.0);
float4 RightEyecolor = float4(0.0,1.0,1.0,1.0);
#line 775
color =  (cA*LeftEyecolor) + (cB*RightEyecolor);
}
else if (Stereoscopic_Mode == 4) 
{
float4 LeftEyecolor = float4(0.0,1.0,0.0,1.0);
float4 RightEyecolor = float4(1.0,0.0,1.0,1.0);
#line 782
color =  (cA*LeftEyecolor) + (cB*RightEyecolor);
}
}
#line 786
return color.rgb;
}
#line 789
float3 Average_Luminance(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float4 ABEA, ABEArray[3] = {
float4(0.0,1.0,0.0, 1.0),           
float4(0.375, 0.250, 0.4375, 0.125),
float4(0.375, 0.250, 0.0, 1.0)      
};
ABEA = ABEArray[clamp(Auto_Balance_Ex,0,2)];
#line 798
float Average_Lum_ZPD = Depth(float2(ABEA.x + texcoord.x * ABEA.y, ABEA.z + texcoord.y * ABEA.w)), Average_Lum_Bottom = Depth( texcoord );
#line 800
float Storage = texcoord < 0.5 ? tex2D(SamplerDM,0).x : tex2D(SamplerDM,1).x;
#line 802
return float3(Average_Lum_ZPD,Average_Lum_Bottom,Storage);
}
#line 805
float4 Out(float4 position : SV_Position, float2 texcoord : TEXCOORD) : SV_Target
{
float2 Z_A = float2(1.0,0.5); 
if(Theater_Mode && Stereoscopic_Mode == 0)
{
Z_A = float2(1.0,1.0); 
}
#line 813
float X = Z_A.x;
float Y = Z_A.y * Z_A.x * 2;
float midW = (X - 1)*(1360*0.5)* float2((1.0 / 1360), (1.0 / 768)).x;
float midH = (Y - 1)*(768*0.5)* float2((1.0 / 1360), (1.0 / 768)).y;
#line 818
float2 TM = float2((texcoord.x*X)-midW,(texcoord.y*Y)-midH);
#line 820
float PosX = 0.9525f*1360* float2((1.0 / 1360), (1.0 / 768)).x,PosY = 0.975f*768* float2((1.0 / 1360), (1.0 / 768)).y;
float4 Color = float4(PS_calcLR(TM).rgb,1.0),D,E,P,T,H,Three,DD,Dot,I,N,F,O;
#line 823
if(timer <= 12500)
{
#line 827
float PosXD = -0.035+PosX, offsetD = 0.001;
float OneD = all( abs(float2( texcoord.x -PosXD, texcoord.y-PosY)) < float2(0.0025,0.009));
float TwoD = all( abs(float2( texcoord.x -PosXD-offsetD, texcoord.y-PosY)) < float2(0.0025,0.007));
D = OneD-TwoD;
#line 833
float PosXE = -0.028+PosX, offsetE = 0.0005;
float OneE = all( abs(float2( texcoord.x -PosXE, texcoord.y-PosY)) < float2(0.003,0.009));
float TwoE = all( abs(float2( texcoord.x -PosXE-offsetE, texcoord.y-PosY)) < float2(0.0025,0.007));
float ThreeE = all( abs(float2( texcoord.x -PosXE, texcoord.y-PosY)) < float2(0.003,0.001));
E = (OneE-TwoE)+ThreeE;
#line 840
float PosXP = -0.0215+PosX, PosYP = -0.0025+PosY, offsetP = 0.001, offsetP1 = 0.002;
float OneP = all( abs(float2( texcoord.x -PosXP, texcoord.y-PosYP)) < float2(0.0025,0.009*0.775));
float TwoP = all( abs(float2( texcoord.x -PosXP-offsetP, texcoord.y-PosYP)) < float2(0.0025,0.007*0.680));
float ThreeP = all( abs(float2( texcoord.x -PosXP+offsetP1, texcoord.y-PosY)) < float2(0.0005,0.009));
P = (OneP-TwoP) + ThreeP;
#line 847
float PosXT = -0.014+PosX, PosYT = -0.008+PosY;
float OneT = all( abs(float2( texcoord.x -PosXT, texcoord.y-PosYT)) < float2(0.003,0.001));
float TwoT = all( abs(float2( texcoord.x -PosXT, texcoord.y-PosY)) < float2(0.000625,0.009));
T = OneT+TwoT;
#line 853
float PosXH = -0.0072+PosX;
float OneH = all( abs(float2( texcoord.x -PosXH, texcoord.y-PosY)) < float2(0.002,0.001));
float TwoH = all( abs(float2( texcoord.x -PosXH, texcoord.y-PosY)) < float2(0.002,0.009));
float ThreeH = all( abs(float2( texcoord.x -PosXH, texcoord.y-PosY)) < float2(0.00325,0.009));
H = (OneH-TwoH)+ThreeH;
#line 860
float offsetFive = 0.001, PosX3 = -0.001+PosX;
float OneThree = all( abs(float2( texcoord.x -PosX3, texcoord.y-PosY)) < float2(0.002,0.009));
float TwoThree = all( abs(float2( texcoord.x -PosX3 - offsetFive, texcoord.y-PosY)) < float2(0.003,0.007));
float ThreeThree = all( abs(float2( texcoord.x -PosX3, texcoord.y-PosY)) < float2(0.002,0.001));
Three = (OneThree-TwoThree)+ThreeThree;
#line 867
float PosXDD = 0.006+PosX, offsetDD = 0.001;
float OneDD = all( abs(float2( texcoord.x -PosXDD, texcoord.y-PosY)) < float2(0.0025,0.009));
float TwoDD = all( abs(float2( texcoord.x -PosXDD-offsetDD, texcoord.y-PosY)) < float2(0.0025,0.007));
DD = OneDD-TwoDD;
#line 873
float PosXDot = 0.011+PosX, PosYDot = 0.008+PosY;
float OneDot = all( abs(float2( texcoord.x -PosXDot, texcoord.y-PosYDot)) < float2(0.00075,0.0015));
Dot = OneDot;
#line 879
float PosXI = 0.0155+PosX, PosYI = 0.004+PosY, PosYII = 0.008+PosY;
float OneI = all( abs(float2( texcoord.x - PosXI, texcoord.y - PosY)) < float2(0.003,0.001));
float TwoI = all( abs(float2( texcoord.x - PosXI, texcoord.y - PosYI)) < float2(0.000625,0.005));
float ThreeI = all( abs(float2( texcoord.x - PosXI, texcoord.y - PosYII)) < float2(0.003,0.001));
I = OneI+TwoI+ThreeI;
#line 886
float PosXN = 0.0225+PosX, PosYN = 0.005+PosY,offsetN = -0.001;
float OneN = all( abs(float2( texcoord.x - PosXN, texcoord.y - PosYN)) < float2(0.002,0.004));
float TwoN = all( abs(float2( texcoord.x - PosXN, texcoord.y - PosYN - offsetN)) < float2(0.003,0.005));
N = OneN-TwoN;
#line 892
float PosXF = 0.029+PosX, PosYF = 0.004+PosY, offsetF = 0.0005, offsetF1 = 0.001;
float OneF = all( abs(float2( texcoord.x -PosXF-offsetF, texcoord.y-PosYF-offsetF1)) < float2(0.002,0.004));
float TwoF = all( abs(float2( texcoord.x -PosXF, texcoord.y-PosYF)) < float2(0.0025,0.005));
float ThreeF = all( abs(float2( texcoord.x -PosXF, texcoord.y-PosYF)) < float2(0.0015,0.00075));
F = (OneF-TwoF)+ThreeF;
#line 899
float PosXO = 0.035+PosX, PosYO = 0.004+PosY;
float OneO = all( abs(float2( texcoord.x -PosXO, texcoord.y-PosYO)) < float2(0.003,0.005));
float TwoO = all( abs(float2( texcoord.x -PosXO, texcoord.y-PosYO)) < float2(0.002,0.003));
O = OneO-TwoO;
#line 904
return D+E+P+T+H+Three+DD+Dot+I+N+F+O ? 1-texcoord.y*50.0+48.35f : Color;
}
else
return Color;
}
#line 911
technique Depth3D 
< ui_tooltip = "This Shader should be the VERY LAST Shader in your master shader list.\n"
"You can always Drag shaders around by clicking them and moving them.\n"
"For more help you can always contact me at DEPTH3D.info or my Github."; >
{
pass DepthBuffer
{
VertexShader = PostProcessVS;
PixelShader = DepthMap;
RenderTarget = texDM;
}
pass zbufferLM
{
VertexShader = PostProcessVS;
PixelShader = zBuffer;
RenderTarget = texzBuffer;
}
pass AverageLuminance
{
VertexShader = PostProcessVS;
PixelShader = Average_Luminance;
RenderTarget = texLum;
}
pass StereoOut
{
VertexShader = PostProcessVS;
PixelShader = Out;
}
}

