// Model Batch DHR
// ---- Created with 3Dmigoto v1.2.65 on Wed Sep 20 21:35:18 2017
Texture2D<float4> t0 : register(t0);

SamplerState s0_s : register(s0);

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

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

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




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



void main( 
  linear centroid float4 v0 : TEXCOORD10,
  linear centroid float4 v1 : TEXCOORD11,
  float4 v2 : TEXCOORD0,
  float4 v3 : TEXCOORD7,
  float4 v4 : SV_Position0,
  uint v5 : SV_IsFrontFace0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = v1.zxy * v0.yzx;
  r0.xyz = v1.yzx * v0.zxy + -r0.xyz;
  r0.xyz = v1.www * r0.xyz;
  r1.xyzw = cb0[37].xyzw * v4.yyyy;
  r1.xyzw = v4.xxxx * cb0[36].xyzw + r1.xyzw;
  r1.xyzw = v4.zzzz * cb0[38].xyzw + r1.xyzw;
  r1.xyzw = cb0[39].xyzw + r1.xyzw;
  r1.xyz = r1.xyz / r1.www;
  
  // Common SVPositionToTranslatedWorld fix:
float4 s = StereoParams.Load(0);
matrix TranslatedWorldToClip = MATRIX(cb0, 0);
matrix ClipToTranslatedWorld = MATRIX(cb0, 32);
float4 t = mul(r1.xyz, TranslatedWorldToClip);
t.x -= s.x * (t.w - s.y);
r1.xyz = mul(t, ClipToTranslatedWorld);
  
  r0.w = dot(-r1.xyz, -r1.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = -r1.xyz * r0.www;
  r3.xyz = cb0[122].www * float3(0,0,1) + cb0[122].xyz;
  r0.w = dot(r3.xyz, r3.xyz);
  r0.w = rsqrt(r0.w);
  r3.xyz = r3.xyz * r0.www;
  r0.xyz = r3.yyy * r0.xyz;
  r0.xyz = r3.xxx * v0.xyz + r0.xyz;
  r0.xyz = r3.zzz * v1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.x = dot(r0.xyz, r2.xyz);
  r0.x = max(0, r0.x);
  r0.x = 1 + -r0.x;
  r0.x = max(9.99999997e-007, abs(r0.x));
  r0.x = r0.x * r0.x;
  r0.y = r0.x * 0.980000019 + 0.0199999996;
  r2.xyz = r0.xxx * float3(0.980000019,0.980000019,0.980000019) + cb2[1].xyz;
  r2.xyz = float3(0.549409986,2.7651,5.01999998) + r2.xyz;
  r0.zw = float2(0,2) * v2.xy;
  r0.zw = cb0[126].zz * float2(1,-0.100000001) + r0.zw;
  r0.z = t0.Sample(s0_s, r0.zw).y;
  r0.w = r0.x * r0.x;
  r0.x = r0.x * r0.w;
  r0.x = r0.x * 0.949999988 + 0.0500000007;
  r0.y = 0.0500000007 * r0.y;
  r0.x = r0.z * r0.x + r0.y;
  r0.x = 0.0500000007 + r0.x;
  r0.w = saturate(cb2[4].x * r0.x);
  r0.xyz = max(float3(0,0,0), r2.xyz);
  r1.w = cmp(0 < cb0[124].x);
  if (r1.w != 0) {
    r1.xyz = -cb0[58].xyz + r1.xyz;
    r2.xyz = -cb1[8].xyz + r1.xyz;
    r3.xyz = float3(1,1,1) + cb1[9].xyz;
    r2.xyz = cmp(r3.xyz < abs(r2.xyz));
    r1.w = (int)r2.y | (int)r2.x;
    r1.w = (int)r2.z | (int)r1.w;
    r1.x = dot(r1.xyz, float3(0.577000022,0.577000022,0.577000022));
    r1.x = 0.00200000009 * r1.x;
    r1.x = frac(r1.x);
    r1.x = cmp(0.5 < r1.x);
    r2.yzw = r1.xxx ? float3(0,1,1) : float3(1,1,0);
    r2.x = 1;
    r0.xyzw = r1.wwww ? r2.yzwx : r0.xyzw;
  }
  r0.xyz = v3.www * r0.xyz;
  o0.xyz = r0.xyz * r0.www;
  o0.w = 0;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                10   xyzw        0     NONE   float   xyz 
// TEXCOORD                11   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xy  
// TEXCOORD                 7   xyzw        3     NONE   float      w
// SV_Position              0   xyzw        4      POS   float   xyz 
// SV_IsFrontFace           0   x           5    FFACE    uint       
//
//
// 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[127], immediateIndexed
dcl_constantbuffer cb1[10], immediateIndexed
dcl_constantbuffer cb2[5], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear centroid v0.xyz
dcl_input_ps linear centroid v1.xyzw
dcl_input_ps linear v2.xy
dcl_input_ps linear v3.w
dcl_input_ps_siv linear noperspective v4.xyz, position
dcl_output o0.xyzw
dcl_temps 4
mul r0.xyz, v0.yzxy, v1.zxyz
mad r0.xyz, v1.yzxy, v0.zxyz, -r0.xyzx
mul r0.xyz, r0.xyzx, v1.wwww
mul r1.xyzw, v4.yyyy, cb0[37].xyzw
mad r1.xyzw, v4.xxxx, cb0[36].xyzw, r1.xyzw
mad r1.xyzw, v4.zzzz, cb0[38].xyzw, r1.xyzw
add r1.xyzw, r1.xyzw, cb0[39].xyzw
div r1.xyz, r1.xyzx, r1.wwww
dp3 r0.w, -r1.xyzx, -r1.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, -r1.xyzx
mad r3.xyz, cb0[122].wwww, l(0.000000, 0.000000, 1.000000, 0.000000), cb0[122].xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
mul r0.xyz, r0.xyzx, r3.yyyy
mad r0.xyz, r3.xxxx, v0.xyzx, r0.xyzx
mad r0.xyz, r3.zzzz, v1.xyzx, r0.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r0.x, r0.xyzx, r2.xyzx
max r0.x, r0.x, l(0.000000)
add r0.x, -r0.x, l(1.000000)
max r0.x, |r0.x|, l(0.000001)
mul r0.x, r0.x, r0.x
mad r0.y, r0.x, l(0.980000), l(0.020000)
mad r2.xyz, r0.xxxx, l(0.980000, 0.980000, 0.980000, 0.000000), cb2[1].xyzx
add r2.xyz, r2.xyzx, l(0.549410, 2.765100, 5.020000, 0.000000)
mul r0.zw, v2.xxxy, l(0.000000, 0.000000, 0.000000, 2.000000)
mad r0.zw, cb0[126].zzzz, l(0.000000, 0.000000, 1.000000, -0.100000), r0.zzzw
sample_indexable(texture2d)(float,float,float,float) r0.z, r0.zwzz, t0.xzyw, s0
mul r0.w, r0.x, r0.x
mul r0.x, r0.w, r0.x
mad r0.x, r0.x, l(0.950000), l(0.050000)
mul r0.y, r0.y, l(0.050000)
mad r0.x, r0.z, r0.x, r0.y
add r0.x, r0.x, l(0.050000)
mul_sat r0.w, r0.x, cb2[4].x
max r0.xyz, r2.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
lt r1.w, l(0.000000), cb0[124].x
if_nz r1.w
  add r1.xyz, r1.xyzx, -cb0[58].xyzx
  add r2.xyz, r1.xyzx, -cb1[8].xyzx
  add r3.xyz, cb1[9].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  lt r2.xyz, r3.xyzx, |r2.xyzx|
  or r1.w, r2.y, r2.x
  or r1.w, r2.z, r1.w
  dp3 r1.x, r1.xyzx, l(0.577000, 0.577000, 0.577000, 0.000000)
  mul r1.x, r1.x, l(0.002000)
  frc r1.x, r1.x
  lt r1.x, l(0.500000), r1.x
  movc r2.yzw, r1.xxxx, l(0,0,1.000000,1.000000), l(0,1.000000,1.000000,0)
  mov r2.x, l(1.000000)
  movc r0.xyzw, r1.wwww, r2.yzwx, r0.xyzw
endif 
mul r0.xyz, r0.xyzx, v3.wwww
mul o0.xyz, r0.wwww, r0.xyzx
mov o0.w, l(0)
ret 
// Approximately 0 instruction slots used

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