// DEcals Double + Swizzle
Texture2D<float4> t3 : register(t3);

Texture2D<float4> t2 : register(t2);

Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s3_s : register(s3);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

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

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

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




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

void main( 
  float4 v0 : SV_Position0,
  uint v1 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0,
  out float4 o2 : SV_Target2,
  out float4 o3 : SV_Target3)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyzw = cb0[1].xyzw * v0.yyyy;
  r0.xyzw = v0.xxxx * cb0[0].xyzw + r0.xyzw;
  r1.xy = cb1[118].zw * v0.xy;
  r1.x = t3.SampleLevel(s3_s, r1.xy, 0).x;
  r0.xyzw = r1.xxxx * cb0[2].xyzw + r0.xyzw;
  r0.xyzw = cb0[3].xyzw + r0.xyzw;
  r0.xyz = r0.xyz / r0.www;
  
  float4 s = StereoParams.Load(0);
matrix m = MATRIX(cb0, 0);
matrix im = inverse(m);
float4 t = mul(float4(r0.xyz, 1), im);
t.x -= s.x * (t.w - s.y) * cb1[118].x / 2;
r0.xyz = mul(t, m);
  
  r1.yzw = float3(1,1,1) + r0.xyz;
  r1.yzw = cmp(r1.yzw < float3(0,0,0));
  r0.w = (int)r1.z | (int)r1.y;
  r0.w = (int)r1.w | (int)r0.w;
  if (r0.w != 0) discard;
  r1.yzw = float3(1,1,1) + -r0.xyz;
  r0.xyz = r0.xyz * float3(0.5,0.5,0.5) + float3(0.5,0.5,0.5);
  r1.yzw = cmp(r1.yzw < float3(0,0,0));
  r0.w = (int)r1.z | (int)r1.y;
  r0.w = (int)r1.w | (int)r0.w;
  if (r0.w != 0) discard;
  r0.y = t2.Sample(s2_s, r0.zy).x;
  r0.x = r0.x * 2 + -1;
  r0.x = saturate(-abs(r0.x) * 4 + 4);
  r0.y = cb2[9].y * r0.y;
  r0.y = max(0, r0.y);
  r0.y = min(0.800000012, r0.y);
  r0.x = r0.y * r0.x;
  r0.x = cb0[12].x * r0.x;
  o0.w = r0.x;
  o0.xyz = max(float3(0,0,0), cb2[2].xyz);
  o2.w = r0.x;
  o3.w = r0.x;
  o2.z = cb1[123].y * 0.5 + cb1[123].x;
  o2.xy = float2(0,0);
  r0.xyzw = cb1[37].xyzw * v0.yyyy;
  r0.xyzw = v0.xxxx * cb1[36].xyzw + r0.xyzw;
  r0.xyzw = r1.xxxx * cb1[38].xyzw + r0.xyzw;
  r0.xyzw = cb1[39].xyzw + r0.xyzw;
  r0.xyzw = r0.xzyz / r0.wwww;
  
  // Common SVPositionToTranslatedWorld fix:
matrix TranslatedWorldToClip = MATRIX(cb1, 0);
matrix ClipToTranslatedWorld = MATRIX(cb1, 32);
float4 t2 = mul(r0.xzyz, TranslatedWorldToClip);
t2.x -= s.x * (t2.w - s.y);
r0.xyzw = mul(t2, ClipToTranslatedWorld).xzyz;
  
  r0.xyzw = -cb1[58].xzyz + r0.xyzw;
  r1.xy = r0.xz / cb2[8].xy;
  r0.xyzw = r0.xyzw / cb2[8].xzyz;
  r1.x = t1.Sample(s1_s, r1.xy).x;
  r0.z = t1.Sample(s1_s, r0.zw).x;
  r0.xyw = t1.Sample(s1_s, r0.xy).xyz;
  r1.yzw = r0.zzz + -r0.xyw;
  r2.xy = -cb1[116].xy + v0.xy;
  r2.xy = r2.xy * cb1[117].zw + float2(-0.5,-0.5);
  r2.xy = v0.ww * r2.xy;
  r2.z = v0.w;
  r2.xyz = float3(2,-2,1) * r2.xyz;
  r2.xy = r2.xy / r2.zz;
  r2.xy = r2.xy * cb1[54].xy + cb1[54].wz;
  r2.xy = t0.SampleLevel(s0_s, r2.xy, 0).xz;
  r2.xy = r2.xy * float2(2,2) + float2(-1,-1);
  r0.xyz = abs(r2.xxx) * r1.yzw + r0.xyw;
  r1.xyz = r1.xxx + -r0.xyz;
  r0.xyz = abs(r2.yyy) * r1.xyz + r0.xyz;
  r0.xyz = cb2[3].xyz * r0.xyz;
  o3.xyz = saturate(float3(0.0799999982,0.0564399995,0.0428000018) * r0.xyz);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.65 on Thu Sep 21 18:46:57 2017
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy w
// SV_IsFrontFace           0   x           1    FFACE    uint       
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
// SV_Target                2   xyzw        2   TARGET   float   xyzw
// SV_Target                3   xyzw        3   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[13], immediateIndexed
dcl_constantbuffer cb1[124], immediateIndexed
dcl_constantbuffer cb2[10], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_sampler s3, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps_siv linear noperspective v0.xyw, position
dcl_output o0.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_temps 3
mul r0.xyzw, v0.yyyy, cb0[1].xyzw
mad r0.xyzw, v0.xxxx, cb0[0].xyzw, r0.xyzw
mul r1.xy, v0.xyxx, cb1[118].zwzz
sample_l_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t3.xyzw, s3, l(0.000000)
mad r0.xyzw, r1.xxxx, cb0[2].xyzw, r0.xyzw
add r0.xyzw, r0.xyzw, cb0[3].xyzw
div r0.xyz, r0.xyzx, r0.wwww
add r1.yzw, r0.xxyz, l(0.000000, 1.000000, 1.000000, 1.000000)
lt r1.yzw, r1.yyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
or r0.w, r1.z, r1.y
or r0.w, r1.w, r0.w
discard_nz r0.w
add r1.yzw, -r0.xxyz, l(0.000000, 1.000000, 1.000000, 1.000000)
mad r0.xyz, r0.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000)
lt r1.yzw, r1.yyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
or r0.w, r1.z, r1.y
or r0.w, r1.w, r0.w
discard_nz r0.w
sample_indexable(texture2d)(float,float,float,float) r0.y, r0.zyzz, t2.yxzw, s2
mad r0.x, r0.x, l(2.000000), l(-1.000000)
mad_sat r0.x, -|r0.x|, l(4.000000), l(4.000000)
mul r0.y, r0.y, cb2[9].y
max r0.y, r0.y, l(0.000000)
min r0.y, r0.y, l(0.800000)
mul r0.x, r0.x, r0.y
mul r0.x, r0.x, cb0[12].x
mov o0.w, r0.x
max o0.xyz, cb2[2].xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
mov o2.w, r0.x
mov o3.w, r0.x
mad o2.z, cb1[123].y, l(0.500000), cb1[123].x
mov o2.xy, l(0,0,0,0)
mul r0.xyzw, v0.yyyy, cb1[37].xyzw
mad r0.xyzw, v0.xxxx, cb1[36].xyzw, r0.xyzw
mad r0.xyzw, r1.xxxx, cb1[38].xyzw, r0.xyzw
add r0.xyzw, r0.xyzw, cb1[39].xyzw
div r0.xyzw, r0.xzyz, r0.wwww
add r0.xyzw, r0.xyzw, -cb1[58].xzyz
div r1.xy, r0.xzxx, cb2[8].xyxx
div r0.xyzw, r0.xyzw, cb2[8].xzyz
sample_indexable(texture2d)(float,float,float,float) r1.x, r1.xyxx, t1.xyzw, s1
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t1.yzxw, s1
sample_indexable(texture2d)(float,float,float,float) r0.xyw, r0.xyxx, t1.xywz, s1
add r1.yzw, -r0.xxyw, r0.zzzz
add r2.xy, v0.xyxx, -cb1[116].xyxx
mad r2.xy, r2.xyxx, cb1[117].zwzz, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r2.xy, r2.xyxx, v0.wwww
mov r2.z, v0.w
mul r2.xyz, r2.xyzx, l(2.000000, -2.000000, 1.000000, 0.000000)
div r2.xy, r2.xyxx, r2.zzzz
mad r2.xy, r2.xyxx, cb1[54].xyxx, cb1[54].wzww
sample_l_indexable(texture2d)(float,float,float,float) r2.xy, r2.xyxx, t0.xzyw, s0, l(0.000000)
mad r2.xy, r2.xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mad r0.xyz, |r2.xxxx|, r1.yzwy, r0.xywx
add r1.xyz, -r0.xyzx, r1.xxxx
mad r0.xyz, |r2.yyyy|, r1.xyzx, r0.xyzx
mul r0.xyz, r0.xyzx, cb2[3].xyzx
mul_sat o3.xyz, r0.xyzx, l(0.080000, 0.056440, 0.042800, 0.000000)
ret 
// Approximately 0 instruction slots used

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