// ---- Created with 3Dmigoto v1.3.16 on Mon Dec 13 17:05:07 2021
Texture2D<float4> t0 : register(t0);

SamplerState s0_s : register(s0);

cbuffer cb2 : register(b2)
{
  float4 cb2[5];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[122];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[3];
}




// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main(
  float4 v0 : SV_POSITION0,
  float4 v1 : COLOR0,
  float4 v2 : ORIGINAL_POSITION0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float Correction : TEXCOORD2,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float4 tex_filter = IniParams.Load(int2(2,0));




  r0.xy = v4.xy * v4.zw + float2(-0.5,-0.5);

  r0.x = dot(r0.xy, r0.xy);
  r0.x = sqrt(r0.x);
  r0.x = r0.x / cb2[3].w;
  r0.x = 1 + -r0.x;
  r0.y = cb2[4].x * r0.x;
  r0.y = r0.y * r0.y;
  r0.y = 1.44269514 * r0.y;
  r0.y = exp2(r0.y);
  r0.y = 1 / r0.y;
  r0.y = 1 + -r0.y;
  r0.z = cmp(r0.x >= 0);
  r0.x = cmp(9.99999975e-006 < abs(r0.x));
  r0.y = r0.z ? r0.y : 0;
  r0.x = r0.x ? r0.y : 0;
  r1.xyzw = -cb1[121].xyxy + v0.xyxy;
  r1.xyzw = r1.xyzw / cb2[3].xxyy;
  r0.y = t0.Sample(s0_s, r1.xy).x;
  r0.z = t0.Sample(s0_s, r1.zw).y;
  r0.y = r0.y * r0.z;
  r0.y = cb2[3].z * r0.y;
  r0.z = v4.x * v4.z;
  r0.z = 3.14159274 * r0.z;
  r0.z = sin(r0.z);
  r0.y = dot(r0.zz, r0.yy);
  r0.w = saturate(r0.y * r0.x + cb2[4].y);
  r0.xyz = max(float3(0,0,0), cb2[2].xyz);
  r0.xyzw = v1.xyzw * r0.xyzw;
  r1.xyz = log2(r0.xyz);
  r1.xyz = cb0[2].xxx * r1.xyz;
  r2.xyz = float3(0.416666657,0.416666657,0.416666657) * r1.xyz;
  r1.xyz = exp2(r1.xyz);
  r2.xyz = exp2(r2.xyz);
  r2.xyz = r2.xyz * float3(1.05499995,1.05499995,1.05499995) + float3(-0.0549999997,-0.0549999997,-0.0549999997);
  r3.xyz = float3(12.9200001,12.9200001,12.9200001) * r1.xyz;
  r1.xyz = cmp(r1.xyz >= float3(0.00313066994,0.00313066994,0.00313066994));
  r1.xyz = r1.xyz ? r2.xyz : r3.xyz;
  r1.w = cmp(cb0[2].y != 1.000000);
  o0.xyz = r1.www ? r1.xyz : r0.xyz;
  o0.w = r0.w;

float4 StatusBarsFixOn = IniParams.Load(int2(62,0));
float4 AutoDepthSwith = IniParams.Load(int2(22,0));
float4 LeftHUD_X_ScreenDepth = IniParams.Load(int2(13,0));
float4 RightHUD_X_ScreenDepth = IniParams.Load(int2(14,0));
float4 UpperHUD_Y_ScreenDepth = IniParams.Load(int2(15,0));
float4 LowerHUD_Y_ScreenDepth = IniParams.Load(int2(16,0));

if(StatusBarsFixOn.x==1.0)
{
//This base fix is made by DarkStarSword
float stereo_adjustment = Correction;
// Load the scissor rectangle and stereoise it. Note that since both
// SV_Position and the scissor rectange are in pixels, the adjustment needs to
// be divided by the render target size and again by 2:
float4 scissor_rect = IniParams[114].xyzw;
//if(AutoDepthSwith.x==1.0)
//{
//if(v0.y > -LowerHUD_Y_ScreenDepth.x && v0.y < UpperHUD_Y_ScreenDepth.x && v0.x > -LeftHUD_X_ScreenDepth.x && v0.x < RightHUD_X_ScreenDepth.x)
//{
//scissor_rect.xz += floor(stereo_adjustment * IniParams[112].x * 0.5);
//}
//else
//{
//scissor_rect.xz += floor(stereo_adjustment * IniParams[112].x);
//}
//}
//if(AutoDepthSwith.x==0.0)
//{
scissor_rect.xz += floor(stereo_adjustment * IniParams[112].x * 0.5);
//}
// Perform stereo adjusted scissor clipping:
if (any(v0.xy < scissor_rect.xy) || any(v0.xy >= scissor_rect.zw)) {
        discard;
        return;
}
}


  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.16 on Mon Dec 13 17:05:07 2021
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xy
// COLOR                    0   xyzw        1     NONE   float   xyzw
// ORIGINAL_POSITION        0   xyzw        2     NONE   float
// TEXCOORD                 0   xy          3     NONE   float
// TEXCOORD                 1   xyzw        4     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[3], immediateIndexed
dcl_constantbuffer cb1[122], immediateIndexed
dcl_constantbuffer cb2[5], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xyzw
dcl_input_ps linear v4.xyzw
dcl_output o0.xyzw
dcl_temps 4
mad r0.xy, v4.xyxx, v4.zwzz, l(-0.500000, -0.500000, 0.000000, 0.000000)
dp2 r0.x, r0.xyxx, r0.xyxx
sqrt r0.x, r0.x
div r0.x, r0.x, cb2[3].w
add r0.x, -r0.x, l(1.000000)
mul r0.y, r0.x, cb2[4].x
mul r0.y, r0.y, r0.y
mul r0.y, r0.y, l(1.44269514)
exp r0.y, r0.y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
add r0.y, -r0.y, l(1.000000)
ge r0.z, r0.x, l(0.000000)
lt r0.x, l(0.000010), |r0.x|
and r0.y, r0.y, r0.z
and r0.x, r0.y, r0.x
add r1.xyzw, v0.xyxy, -cb1[121].xyxy
div r1.xyzw, r1.xyzw, cb2[3].xxyy
sample_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t0.yxzw, s0
sample_indexable(texture2d)(float,float,float,float) r0.z, r1.zwzz, t0.xzyw, s0
mul r0.y, r0.z, r0.y
mul r0.y, r0.y, cb2[3].z
mul r0.z, v4.z, v4.x
mul r0.z, r0.z, l(3.14159274)
sincos r0.z, null, r0.z
dp2 r0.y, r0.zzzz, r0.yyyy
mad_sat r0.w, r0.y, r0.x, cb2[4].y
max r0.xyz, cb2[2].xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r0.xyzw, r0.xyzw, v1.xyzw
log r1.xyz, r0.xyzx
mul r1.xyz, r1.xyzx, cb0[2].xxxx
mul r2.xyz, r1.xyzx, l(0.416666657, 0.416666657, 0.416666657, 0.000000)
exp r1.xyz, r1.xyzx
exp r2.xyz, r2.xyzx
mad r2.xyz, r2.xyzx, l(1.055000, 1.055000, 1.055000, 0.000000), l(-0.055000, -0.055000, -0.055000, 0.000000)
mul r3.xyz, r1.xyzx, l(12.920000, 12.920000, 12.920000, 0.000000)
ge r1.xyz, r1.xyzx, l(0.00313066994, 0.00313066994, 0.00313066994, 0.000000)
movc r1.xyz, r1.xyzx, r2.xyzx, r3.xyzx
ne r1.w, cb0[2].y, l(1.000000)
movc o0.xyz, r1.wwww, r1.xyzx, r0.xyzx
mov o0.w, r0.w
ret
// Approximately 0 instruction slots used

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
