// Model 4 Batch DHR
// ---- Created with 3Dmigoto v1.2.65 on Sat Sep 23 18:51:46 2017
Texture3D<float4> t2 : register(t2);

Texture3D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerState s2_s : register(s2);

SamplerState s1_s : register(s1);

SamplerState s0_s : register(s0);

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

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

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




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


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

  r0.xy = -cb0[116].xy + v4.xy;
  r0.xy = r0.xy * cb0[117].zw + float2(-0.5,-0.5);
  r0.xy = v4.ww * r0.xy;
  r0.z = v4.w;
  r0.xyw = float3(2,-2,1) * 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);
  
  r1.xyz = -cb0[58].xyz + r1.xyz;
  r2.xyz = cb2[6].xxx * cb2[2].xyz + cb2[3].xyz;
  r3.xyz = cb2[6].yyy * cb2[2].xyz;
  r3.xyz = saturate(cb2[4].xyz * r3.xyz);
  r0.xy = r0.xy / r0.ww;
  r0.xy = r0.xy * cb0[54].xy + cb0[54].wz;
  r0.x = t0.SampleLevel(s0_s, r0.xy, 0).x;
  r0.y = r0.x * cb0[53].x + cb0[53].y;
  r0.x = r0.x * cb0[53].z + -cb0[53].w;
  r0.x = 1 / r0.x;
  r0.x = r0.y + r0.x;
  r0.x = -r0.z * 1 + r0.x;
  r0.y = saturate(r0.x / cb2[6].w);
  r0.x = saturate(r0.x / cb2[7].y);
  r0.w = r0.y * r0.x;
  r1.w = cmp(0.00100000005 < abs(v2.w));
  r4.xy = floor(v4.xy);
  r2.w = dot(r4.xy, float2(347.834503,3343.28369));
  r2.w = cos(r2.w);
  r2.w = 1000 * r2.w;
  r2.w = frac(r2.w);
  r3.w = cmp(v2.w < 0);
  r4.x = 1 + v2.w;
  r4.x = cmp(r2.w < r4.x);
  r2.w = cmp(v2.w < r2.w);
  r2.w = r3.w ? r4.x : r2.w;
  r2.w = cmp((int)r2.w == 0);
  r1.w = r1.w ? r2.w : 0;
  if (r1.w != 0) discard;
  r3.xyz = r3.xyz * cb0[120].www + cb0[120].xyz;
  r4.xyz = cb0[121].www * float3(0.0399999991,0.0399999991,0.0399999991) + cb0[121].xyz;
  r5.xyz = -cb0[131].xyz + r1.xyz;
  r6.xyz = cb0[133].xyz * r5.xyz;
  r7.xyz = -cb0[132].xyz + r1.xyz;
  r7.xyz = cb0[134].xyz * r7.xyz;
  r5.xyz = r5.xyz * cb0[133].xyz + float3(-0.5,-0.5,-0.5);
  r5.xyz = float3(0.5,0.5,0.5) + -abs(r5.xyz);
  r5.xyz = saturate(float3(6,6,6) * r5.xyz);
  r1.w = r5.x * r5.y;
  r1.w = r1.w * r5.z;
  r5.xyz = t1.SampleLevel(s1_s, r6.xyz, 0).xyz;
  r6.xyz = t2.SampleLevel(s2_s, r7.xyz, 0).xyz;
  r5.xyz = -r6.xyz + r5.xyz;
  r5.xyz = r1.www * r5.xyz + r6.xyz;
  r5.xyz = r5.xyz * r3.xyz;
  r6.xyz = float3(0.886227548,0.886227548,0.886227548) * r5.xyz;
  r3.xyz = r4.xyz * float3(0.449999988,0.449999988,0.449999988) + r3.xyz;
  r3.xyz = -r5.xyz * float3(0.886227548,0.886227548,0.886227548) + r3.xyz;
  r3.xyz = cb0[128].xxx * r3.xyz + r6.xyz;
  r0.xyz = max(float3(0,0,0), r2.xyz);
  r1.w = cmp(0 < cb0[124].x);
  if (r1.w != 0) {
    r2.xyz = -cb1[8].xyz + r1.xyz;
    r4.xyz = float3(1,1,1) + cb1[9].xyz;
    r2.xyz = cmp(r4.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;
    o0.w = r0.w;
  } else {
    o0.w = r0.w;
  }
  r0.xyz = r3.xyz + r0.xyz;
  o0.xyz = r0.xyz * v3.www + v3.xyz;
  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       
// TEXCOORD                11   xyzw        1     NONE   float       
// COLOR                    1   xyzw        2     NONE   float      w
// TEXCOORD                 7   xyzw        3     NONE   float   xyzw
// SV_Position              0   xyzw        4      POS   float   xyzw
// 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[135], immediateIndexed
dcl_constantbuffer cb1[10], immediateIndexed
dcl_constantbuffer cb2[8], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture3d (float,float,float,float) t1
dcl_resource_texture3d (float,float,float,float) t2
dcl_input_ps linear v2.w
dcl_input_ps linear v3.xyzw
dcl_input_ps_siv linear noperspective v4.xyzw, position
dcl_output o0.xyzw
dcl_temps 8
add r0.xy, v4.xyxx, -cb0[116].xyxx
mad r0.xy, r0.xyxx, cb0[117].zwzz, l(-0.500000, -0.500000, 0.000000, 0.000000)
mul r0.xy, r0.xyxx, v4.wwww
mov r0.z, v4.w
mul r0.xyw, r0.xyxz, l(2.000000, -2.000000, 0.000000, 1.000000)
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
add r1.xyz, r1.xyzx, -cb0[58].xyzx
mad r2.xyz, cb2[6].xxxx, cb2[2].xyzx, cb2[3].xyzx
mul r3.xyz, cb2[2].xyzx, cb2[6].yyyy
mul_sat r3.xyz, r3.xyzx, cb2[4].xyzx
div r0.xy, r0.xyxx, r0.wwww
mad r0.xy, r0.xyxx, cb0[54].xyxx, cb0[54].wzww
sample_l_indexable(texture2d)(float,float,float,float) r0.x, r0.xyxx, t0.xyzw, s0, l(0.000000)
mad r0.y, r0.x, cb0[53].x, cb0[53].y
mad r0.x, r0.x, cb0[53].z, -cb0[53].w
div r0.x, l(1.000000, 1.000000, 1.000000, 1.000000), r0.x
add r0.x, r0.x, r0.y
mad r0.x, -r0.z, l(1.000000), r0.x
div_sat r0.y, r0.x, cb2[6].w
div_sat r0.x, r0.x, cb2[7].y
mul r0.w, r0.x, r0.y
lt r1.w, l(0.001000), |v2.w|
round_ni r4.xy, v4.xyxx
dp2 r2.w, r4.xyxx, l(347.834503, 3343.283691, 0.000000, 0.000000)
sincos null, r2.w, r2.w
mul r2.w, r2.w, l(1000.000000)
frc r2.w, r2.w
lt r3.w, v2.w, l(0.000000)
add r4.x, v2.w, l(1.000000)
lt r4.x, r2.w, r4.x
lt r2.w, v2.w, r2.w
movc r2.w, r3.w, r4.x, r2.w
ieq r2.w, r2.w, l(0)
and r1.w, r1.w, r2.w
discard_nz r1.w
mad r3.xyz, r3.xyzx, cb0[120].wwww, cb0[120].xyzx
mad r4.xyz, cb0[121].wwww, l(0.040000, 0.040000, 0.040000, 0.000000), cb0[121].xyzx
add r5.xyz, r1.xyzx, -cb0[131].xyzx
mul r6.xyz, r5.xyzx, cb0[133].xyzx
add r7.xyz, r1.xyzx, -cb0[132].xyzx
mul r7.xyz, r7.xyzx, cb0[134].xyzx
mad r5.xyz, r5.xyzx, cb0[133].xyzx, l(-0.500000, -0.500000, -0.500000, 0.000000)
add r5.xyz, -|r5.xyzx|, l(0.500000, 0.500000, 0.500000, 0.000000)
mul_sat r5.xyz, r5.xyzx, l(6.000000, 6.000000, 6.000000, 0.000000)
mul r1.w, r5.y, r5.x
mul r1.w, r5.z, r1.w
sample_l_indexable(texture3d)(float,float,float,float) r5.xyz, r6.xyzx, t1.xyzw, s1, l(0.000000)
sample_l_indexable(texture3d)(float,float,float,float) r6.xyz, r7.xyzx, t2.xyzw, s2, l(0.000000)
add r5.xyz, r5.xyzx, -r6.xyzx
mad r5.xyz, r1.wwww, r5.xyzx, r6.xyzx
mul r5.xyz, r3.xyzx, r5.xyzx
mul r6.xyz, r5.xyzx, l(0.886228, 0.886228, 0.886228, 0.000000)
mad r3.xyz, r4.xyzx, l(0.450000, 0.450000, 0.450000, 0.000000), r3.xyzx
mad r3.xyz, -r5.xyzx, l(0.886228, 0.886228, 0.886228, 0.000000), r3.xyzx
mad r3.xyz, cb0[128].xxxx, r3.xyzx, r6.xyzx
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 r2.xyz, r1.xyzx, -cb1[8].xyzx
  add r4.xyz, cb1[9].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  lt r2.xyz, r4.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
  mov o0.w, r0.w
else 
  mov o0.w, r0.w
endif 
add r0.xyz, r0.xyzx, r3.xyzx
mad o0.xyz, r0.xyzx, v3.wwww, v3.xyzx
ret 
// Approximately 0 instruction slots used

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