// VL aprox
Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

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

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

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




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


void main(
  float4 v0 : SV_Position0,
  float4 v1 : TEXCOORD0,
  float3 v2 : TEXCOORD1,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = float2(0.5,0.5) * v1.xy;
  r0.xy = r0.xy / v1.zz;
  r0.xy = float2(0.5,0.5) + r0.xy;
  r0.xyzw = t0.Sample(s1_s, r0.xy).xyzw;
  r0.x = cb1[7].x * r0.x + cb1[7].y;
  r0.x = 1 / r0.x;
  r0.y = cb1[5].z / v2.z;
  r0.yzw = v2.xyz * r0.yyy;
  r0.xyz = r0.yzw * r0.xxx;
  r0.w = 1;
  r0.w = dot(r0.xyzw, r0.xyzw);
  r1.x = sqrt(r0.w);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  
  //Fix
  float4 stereo = StereoParams.Load(0);
  r0.x -= stereo.x * (r0.z - stereo.y) * -0.25;
  
  r1.yzw = cb2[18].yyy * cb0[18].xyz;
  r1.yzw = cb0[17].xyz * cb2[18].xxx + r1.yzw;
  r1.yzw = cb0[19].xyz * cb2[18].zzz + r1.yzw;
  r1.yzw = cb0[20].xyz * cb2[18].www + r1.yzw;
  r2.xyz = cb2[19].yyy * cb0[18].xyz;
  
  r2.xyz = cb0[17].xyz * cb2[19].xxx + r2.xyz;
  r2.xyz = cb0[19].xyz * cb2[19].zzz + r2.xyz;
  r2.xyz = cb0[20].xyz * cb2[19].www + r2.xyz;
  
  r3.xyz = cb2[20].yyy * cb0[18].xyz;
  r3.xyz = cb0[17].xyz * cb2[20].xxx + r3.xyz;
  r3.xyz = cb0[19].xyz * cb2[20].zzz + r3.xyz;
  r3.xyz = cb0[20].xyz * cb2[20].www + r3.xyz;
  
  r4.xyz = cb2[21].yyy * cb0[18].xyz;
  r4.xyz = cb0[17].xyz * cb2[21].xxx + r4.xyz;
  r4.xyz = cb0[19].xyz * cb2[21].zzz + r4.xyz;
  r4.xyz = cb0[20].xyz * cb2[21].www + r4.xyz;
  
  r2.xyz = r2.xyz * r0.yyy;
  r0.xyw = r0.xxx * r1.yzw + r2.xyz;
  r0.xyz = r0.zzz * r3.xyz + r0.xyw;
  r0.w = dot(r0.xy, r0.xy);
  r0.w = -r0.z * r0.z + r0.w;
  r1.y = dot(r0.xxyy, r4.xxyy);
  r1.z = dot(r0.zz, r4.zz);
  r1.y = r1.y + -r1.z;
  r1.z = dot(r4.xy, r4.xy);
  r1.z = -r4.z * r4.z + r1.z;
  r1.z = r1.z * r0.w;
  r1.z = 4 * r1.z;
  r1.z = r1.y * r1.y + -r1.z;
  r1.z = sqrt(r1.z);
  r1.w = -r1.y + -r1.z;
  r0.w = r0.w + r0.w;
  r1.w = r1.w / r0.w;
  r2.x = r0.z * r1.w + r4.z;
  r2.y = cmp(0.00999999978 < r2.x);
  r2.x = cmp(r2.x < 1);
  r2.x = r2.x ? r2.y : 0;
  r2.xy = r2.xx ? r1.ww : float2(990000000,-990000000);
  r1.y = -r1.y + r1.z;
  r0.w = r1.y / r0.w;
  r1.y = r0.z * r0.w + r4.z;
  r1.z = cmp(0.00999999978 < r1.y);
  r1.y = cmp(r1.y < 1);
  r1.y = r1.y ? r1.z : 0;
  r3.x = min(r2.x, r0.w);
  r3.y = max(r2.y, r0.w);
  r1.yz = r1.yy ? r3.xy : r2.xy;
  r0.w = cmp(r0.z != 0.000000);
  r2.xyzw = float4(-0.00999999978,-0.00999999978,-1,-1) + r4.zzzz;
  r2.xyzw = -r2.xyzw / r0.zzzz;
  r3.xyzw = r0.xyxy * r2.xyzw + r4.xyxy;
  r1.w = dot(r3.xy, r3.xy);
  r1.w = cmp(r1.w < 9.99999975e-005);
  r3.x = min(r2.y, r1.y);
  r3.y = max(r2.y, r1.z);
  r2.xy = r1.ww ? r3.xy : r1.yz;
  r1.w = dot(r3.zw, r3.zw);
  r1.w = cmp(r1.w < 1);
  r3.x = min(r2.x, r2.w);
  r3.y = max(r2.y, r2.w);
  r2.xy = r1.ww ? r3.xy : r2.xy;
  r1.yz = r0.ww ? r2.xy : r1.yz;
  r0.w = cmp(r1.z < 0);
  if (r0.w != 0) discard;
  r0.w = r1.x + -r1.y;
  r0.w = cmp(r0.w < 0);
  if (r0.w != 0) discard;
  r0.w = max(0, r1.y);
  r1.x = min(r1.z, r1.x);
  r1.yzw = r0.www * r0.xyz + r4.xyz;
  r0.xyz = r1.xxx * r0.xyz + r4.xyz;
  r2.x = asint(cb0[25].y);
  r2.x = 1 / r2.x;
  r2.y = dot(v1.xy, float2(12.9898005,78.2330017));
  r2.y = sin(r2.y);
  r2.y = 43758.5469 * r2.y;
  r2.y = frac(r2.y);
  r2.y = cb0[25].x * r2.y;
  r0.xyz = r0.xyz + -r1.yzw;
  r2.z = asint(cb0[25].y) + 1;
  r2.z = (int)r2.z;
  r0.xyz = r0.xyz / r2.zzz;
  r1.yzw = r2.yyy * r0.xyz + r1.yzw;
  r3.y = 0;
  r2.yzw = float3(0,0,0);
  r3.xzw = r1.wyz;
  r4.xy = float2(0,0);
  while (true) {
    r4.z = cmp((int)r4.y >= asint(cb0[25].y));
    if (r4.z != 0) break;
    r4.zw = r3.zw / r3.xx;
    r4.zw = r4.zw * float2(0.5,0.5) + float2(0.5,0.5);
    r5.xyzw = t1.SampleLevel(s0_s, r3.xy, 0).xyzw;
    r4.zw = r4.zw * float2(2,2) + float2(-1,-1);
    r4.z = dot(r4.zw, r4.zw);
    r4.w = r4.z * r4.z;
    r4.z = -r4.z * r4.w + 1;
    r4.z = max(0, r4.z);
    r4.x = r5.x * r2.x + r4.x;
    r2.yzw = r4.zzz * r2.xxx + r2.yzw;
    r4.y = (int)r4.y + 1;
    r3.xzw = r3.xzw + r0.zxy;
  }
  r0.xyz = cb0[6].xyz * r2.yzw;
  r0.w = r1.x + -r0.w;
  r0.w = cb0[23].x * r0.w;
  r0.w = r4.x * r0.w;
  o0.xyz = r0.xyz * r0.www;
  o0.w = cb0[23].y * r0.w;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.12 on Thu Dec 06 17:27:15 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float
// TEXCOORD                 0   xyz         1     NONE   float   xyz
// TEXCOORD                 1   xyz         2     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[26], immediateIndexed
dcl_constantbuffer cb1[8], immediateIndexed
dcl_constantbuffer cb2[22], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xyz
dcl_input_ps linear v2.xyz
dcl_output o0.xyzw
dcl_temps 6
mul r0.xy, v1.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
div r0.xy, r0.xyxx, v1.zzzz
add r0.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
sample r0.xyzw, r0.xyxx, t0.xyzw, s1
mad r0.x, cb1[7].x, r0.x, cb1[7].y
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
div r0.y, cb1[5].z, v2.z
mul r0.yzw, r0.yyyy, v2.xxyz
mul r0.xyz, r0.xxxx, r0.yzwy
mov r0.w, l(1.000000)
dp4 r0.w, r0.xyzw, r0.xyzw
sqrt r1.x, r0.w
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.yzw, cb0[18].xxyz, cb2[18].yyyy
mad r1.yzw, cb0[17].xxyz, cb2[18].xxxx, r1.yyzw
mad r1.yzw, cb0[19].xxyz, cb2[18].zzzz, r1.yyzw
mad r1.yzw, cb0[20].xxyz, cb2[18].wwww, r1.yyzw
mul r2.xyz, cb0[18].xyzx, cb2[19].yyyy
mad r2.xyz, cb0[17].xyzx, cb2[19].xxxx, r2.xyzx
mad r2.xyz, cb0[19].xyzx, cb2[19].zzzz, r2.xyzx
mad r2.xyz, cb0[20].xyzx, cb2[19].wwww, r2.xyzx
mul r3.xyz, cb0[18].xyzx, cb2[20].yyyy
mad r3.xyz, cb0[17].xyzx, cb2[20].xxxx, r3.xyzx
mad r3.xyz, cb0[19].xyzx, cb2[20].zzzz, r3.xyzx
mad r3.xyz, cb0[20].xyzx, cb2[20].wwww, r3.xyzx
mul r4.xyz, cb0[18].xyzx, cb2[21].yyyy
mad r4.xyz, cb0[17].xyzx, cb2[21].xxxx, r4.xyzx
mad r4.xyz, cb0[19].xyzx, cb2[21].zzzz, r4.xyzx
mad r4.xyz, cb0[20].xyzx, cb2[21].wwww, r4.xyzx
mul r2.xyz, r0.yyyy, r2.xyzx
mad r0.xyw, r0.xxxx, r1.yzyw, r2.xyxz
mad r0.xyz, r0.zzzz, r3.xyzx, r0.xywx
dp2 r0.w, r0.xyxx, r0.xyxx
mad r0.w, -r0.z, r0.z, r0.w
dp4 r1.y, r0.xxyy, r4.xxyy
dp2 r1.z, r0.zzzz, r4.zzzz
add r1.y, -r1.z, r1.y
dp2 r1.z, r4.xyxx, r4.xyxx
mad r1.z, -r4.z, r4.z, r1.z
mul r1.z, r0.w, r1.z
mul r1.z, r1.z, l(4.000000)
mad r1.z, r1.y, r1.y, -r1.z
sqrt r1.z, r1.z
add r1.w, -r1.z, -r1.y
add r0.w, r0.w, r0.w
div r1.w, r1.w, r0.w
mad r2.x, r0.z, r1.w, r4.z
lt r2.y, l(0.010000), r2.x
lt r2.x, r2.x, l(1.000000)
and r2.x, r2.x, r2.y
movc r2.xy, r2.xxxx, r1.wwww, l(990000000.000000,-990000000.000000,0,0)
add r1.y, r1.z, -r1.y
div r0.w, r1.y, r0.w
mad r1.y, r0.z, r0.w, r4.z
lt r1.z, l(0.010000), r1.y
lt r1.y, r1.y, l(1.000000)
and r1.y, r1.y, r1.z
min r3.x, r0.w, r2.x
max r3.y, r0.w, r2.y
movc r1.yz, r1.yyyy, r3.xxyx, r2.xxyx
ne r0.w, r0.z, l(0.000000)
add r2.xyzw, r4.zzzz, l(-0.010000, -0.010000, -1.000000, -1.000000)
div r2.xyzw, -r2.xyzw, r0.zzzz
mad r3.xyzw, r0.xyxy, r2.xyzw, r4.xyxy
dp2 r1.w, r3.xyxx, r3.xyxx
lt r1.w, r1.w, l(0.000100)
min r3.x, r1.y, r2.y
max r3.y, r1.z, r2.y
movc r2.xy, r1.wwww, r3.xyxx, r1.yzyy
dp2 r1.w, r3.zwzz, r3.zwzz
lt r1.w, r1.w, l(1.000000)
min r3.x, r2.w, r2.x
max r3.y, r2.w, r2.y
movc r2.xy, r1.wwww, r3.xyxx, r2.xyxx
movc r1.yz, r0.wwww, r2.xxyx, r1.yyzy
lt r0.w, r1.z, l(0.000000)
discard_nz r0.w
add r0.w, -r1.y, r1.x
lt r0.w, r0.w, l(0.000000)
discard_nz r0.w
max r0.w, r1.y, l(0.000000)
min r1.x, r1.x, r1.z
mad r1.yzw, r0.wwww, r0.xxyz, r4.xxyz
mad r0.xyz, r1.xxxx, r0.xyzx, r4.xyzx
itof r2.x, cb0[25].y
div r2.x, l(1.000000, 1.000000, 1.000000, 1.000000), r2.x
dp2 r2.y, v1.xyxx, l(12.989800, 78.233002, 0.000000, 0.000000)
sincos r2.y, null, r2.y
mul r2.y, r2.y, l(43758.546875)
frc r2.y, r2.y
mul r2.y, r2.y, cb0[25].x
add r0.xyz, -r1.yzwy, r0.xyzx
iadd r2.z, cb0[25].y, l(1)
itof r2.z, r2.z
div r0.xyz, r0.xyzx, r2.zzzz
mad r1.yzw, r2.yyyy, r0.xxyz, r1.yyzw
mov r3.y, l(0)
mov r2.yzw, l(0,0,0,0)
mov r3.xzw, r1.wwyz
mov r4.xy, l(0,0,0,0)
loop
  ige r4.z, r4.y, cb0[25].y
  breakc_nz r4.z
  div r4.zw, r3.zzzw, r3.xxxx
  mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000), l(0.000000, 0.000000, 0.500000, 0.500000)
  sample_l r5.xyzw, r3.xyxx, t1.xyzw, s0, l(0.000000)
  mad r4.zw, r4.zzzw, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, -1.000000, -1.000000)
  dp2 r4.z, r4.zwzz, r4.zwzz
  mul r4.w, r4.z, r4.z
  mad r4.z, -r4.z, r4.w, l(1.000000)
  max r4.z, r4.z, l(0.000000)
  mad r4.x, r5.x, r2.x, r4.x
  mad r2.yzw, r4.zzzz, r2.xxxx, r2.yyzw
  iadd r4.y, r4.y, l(1)
  add r3.xzw, r0.zzxy, r3.xxzw
endloop
mul r0.xyz, r2.yzwy, cb0[6].xyzx
add r0.w, -r0.w, r1.x
mul r0.w, r0.w, cb0[23].x
mul r0.w, r0.w, r4.x
mul o0.xyz, r0.wwww, r0.xyzx
mul o0.w, r0.w, cb0[23].y
ret
// Approximately 0 instruction slots used

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