//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.67 on Mon Jan 01 13:11:45 2018
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4 g_vDitherSettings;          // Offset:    0 Size:    16 [unused]
//   float4 g_vKSettings;               // Offset:   16 Size:    16
//   float4x4 g_mPrevObjViewProj;       // Offset:   32 Size:    64
//   float4 specColor;                  // Offset:   96 Size:    16 [unused]
//   float4 ControlData;                // Offset:  112 Size:    16 [unused]
//   float4 difColor;                   // Offset:  128 Size:    16 [unused]
//   float4 ambient;                    // Offset:  144 Size:    16 [unused]
//   float4 lightCount;                 // Offset:  160 Size:    16
//   float4 g_avLightPos[4];            // Offset:  176 Size:    64
//   float4 g_avLightColor[4];          // Offset:  240 Size:    64
//   float4 g_avConeDir[4];             // Offset:  304 Size:    64
//   float4 g_vAmbientSettings;         // Offset:  368 Size:    16 [unused]
//   float4 g_vScreenDepthRect;         // Offset:  384 Size:    16 [unused]
//   
//   struct
//   {
//       
//       float4 vDesc;                  // Offset:  400
//       float4 vFogLayerPlane;         // Offset:  416
//       float4 vFogLayerColor;         // Offset:  432
//       float4 vFogLayerSettings;      // Offset:  448
//       float4 vFogColor;              // Offset:  464
//       float4 vFogDistance;           // Offset:  480
//
//   } g_FogDesc;                       // Offset:  400 Size:    96
//   float4 g_avVolumeSpheres[40];      // Offset:  496 Size:   640
//   float4 g_vCamPos;                  // Offset: 1136 Size:    16
//   float4x4 g_mProj;                  // Offset: 1152 Size:    64 [unused]
//   float4x4 g_mView;                  // Offset: 1216 Size:    64 [unused]
//   float4x4 g_mIView;                 // Offset: 1280 Size:    64
//   float4x4 g_mViewProj;              // Offset: 1344 Size:    64
//   float4 g_vMaskCoord;               // Offset: 1408 Size:    16
//   float4 g_vTerrainNormCoord;        // Offset: 1424 Size:    16
//   float4 g_vOffset;                  // Offset: 1440 Size:    16
//   float4 g_vPixelOffset;             // Offset: 1456 Size:    16 [unused]
//   float4 g_avFaceK[2];               // Offset: 1472 Size:    32 [unused]
//   float4 g_vConstraints;             // Offset: 1504 Size:    16
//   float4 g_vExclusionMask;           // Offset: 1520 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_vOrientAxis;              // Offset: 1536 Size:    16
//      = 0x00000000 0x00000000 0x00000000 0x00000000 
//   float4 g_avTreeCenter[128];        // Offset: 1552 Size:  2048
//   float4x4 g_mCloudsShadowsSpace;    // Offset: 3600 Size:    64
//   float4 g_vCloudsShadowDesc;        // Offset: 3664 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// LerpSampler                       sampler      NA          NA    0        1
// g_tTerrainNormTexture             texture  float4          2d    0        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// POSITION                 1   xyz         1     NONE   float   xyz 
// POSITION                 2   xyzw        2     NONE   float   xy w
// TEXCOORD                 0   xyzw        3     NONE   float   xyz 
// TEXCOORD                 1   xy          4     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyzw        2     NONE   float   xyzw
// TEXCOORD                 2   xyz         3     NONE   float   xyz 
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// COLOR                    0   xyzw        5     NONE   float   xyzw
// COLOR                    1   xyzw        6     NONE   float   xyzw
// TEXCOORD                 4   xyzw        7     NONE   float   xyzw
// TEXCOORD                 5   xy          8     NONE   float   xy  
//
vs_4_0
dcl_constantbuffer cb0[228], dynamicIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input v0.xyzw
dcl_input v1.xyz
dcl_input v2.xyw
dcl_input v3.xyz
dcl_input v4.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyz
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output o8.xy
// dcl_temps updated : previous = dcl_temps 11
dcl_temps 14
// added 3dmigoto declaration
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture1d)(float,float,float,float) r12.xyzw, l(0, 0, 0, 0), t120.xyzw
mov r13.x, r12.w
mov r13.y, r12.w
mov r13.zw, l(1.0, 1.0)
// end of 3dmigoto declaration
ftou r0.x, v2.w
add r1.xz, v1.xxzx, -v2.xxyx
mov r1.y, v1.y
add r0.yzw, r1.xxyz, cb0[r0.x + 97].xxyz
add r1.xyz, r0.yzwy, cb0[90].xyzx
add r0.yzw, cb0[90].xxyz, cb0[r0.x + 97].xxyz
add r2.xyz, r1.xyzx, -cb0[71].xyzx
dp3 r2.w, r2.xyzx, r2.xyzx
rsq r3.x, r2.w
mul r2.xyz, r2.xyzx, r3.xxxx
add r3.xyz, r0.yzwy, -cb0[71].xyzx
dp3 r3.x, r3.xyzx, r3.xyzx
sqrt r3.x, r3.x
lt r3.y, cb0[96].w, l(0.500000)
if_nz r3.y
// replacing matrix usage :  mov r4.xyz, cb0[80].xyzx
mov r11.xyz, cb0[80].xyzx
// replacing matrix usage :  mov r5.xyz, cb0[81].xyzx
mov r11.xyz, cb0[81].xyzx
  mov r6.xyz, cb0[82].xyzx
else 
  mul r3.yzw, r2.yyzx, cb0[96].xxyz
  mad r3.yzw, r2.xxyz, cb0[96].yyzx, -r3.yyzw
  dp3 r4.w, r3.yzwy, r3.yzwy
  rsq r4.w, r4.w
  mul r6.xyz, r3.yzwy, r4.wwww
  mul r3.yzw, r2.yyzx, r6.xxyz
  mad r3.yzw, r6.zzxy, r2.zzxy, -r3.yyzw
  mov r4.x, r6.y
  mov r5.x, r6.z
  mov r4.y, r3.y
  mov r5.y, r3.z
  mov r6.y, r3.w
  mov r4.z, r2.x
  mov r5.z, r2.y
  mov r6.z, r2.z
endif 
lt r3.y, r3.x, cb0[94].x
if_nz r3.y
  dp3 r7.x, v0.xyzx, r4.xyzx
  dp3 r7.y, v0.xyzx, r5.xyzx
  dp3 r7.z, v0.xyzx, r6.xyzx
  add r7.xyz, r1.xyzx, r7.xyzx
else 
  mov r7.xyz, r1.xyzx
endif 
mov r7.w, l(1.000000)
// replacing matrix usage :dp4 r8.x, r7.xyzw, cb0[84].xyzw
dp4 r11.x, r7.xyzw, cb0[84].xyzw
mul r8.x, r11.x, r13.x
// replacing matrix usage :dp4 r8.y, r7.xyzw, cb0[85].xyzw
dp4 r11.y, r7.xyzw, cb0[85].xyzw
mul r8.y, r11.y, r13.y
dp4 r8.z, r7.xyzw, cb0[86].xyzw
dp4 r8.w, r7.xyzw, cb0[87].xyzw
lt r3.y, cb0[1].x, l(0.500000)
if_nz r3.y
  mov o8.xy, l(0,0,0,0)
else 
  div r3.yz, r8.xxyx, r8.wwww
// replacing matrix usage :  dp4 r9.x, r7.xyzw, cb0[2].xyzw
dp4 r11.x, r7.xyzw, cb0[2].xyzw
mul r9.x, r11.x, r13.x
// replacing matrix usage :  dp4 r9.y, r7.xyzw, cb0[3].xyzw
dp4 r11.y, r7.xyzw, cb0[3].xyzw
mul r9.y, r11.y, r13.y
  dp4 r3.w, r7.xyzw, cb0[5].xyzw
  div r9.xy, r9.xyxx, r3.wwww
  add r9.xy, r3.yzyy, -r9.xyxx
  mul r9.z, -r9.y, cb0[1].y
  dp2 r3.y, r9.xzxx, r9.xzxx
  sqrt r3.y, r3.y
  lt r3.z, l(2.000000), r3.y
  if_nz r3.z
    div r3.y, l(2.000000), r3.y
    mul o8.xy, r3.yyyy, r9.xzxx
  else 
    mov o8.xy, r9.xzxx
  endif 
endif 
add r3.x, -r3.x, cb0[94].x
mul_sat o1.w, r3.x, l(0.010000)
mov r1.w, l(1.000000)
dp4 o2.z, r1.xyzw, cb0[225].xyzw
dp4 o2.w, r1.xyzw, cb0[227].xyzw
mul r3.xyz, r8.xwyx, l(0.500000, 0.500000, -0.500000, 0.000000)
add o4.xy, r3.yyyy, r3.xzxx
sqrt r2.w, r2.w
mul r2.w, r2.w, cb0[30].x
min r2.w, r2.w, l(1.000000)
dp4 r1.w, r1.xyzw, cb0[26].xyzw
add r1.xyz, -r1.xyzx, cb0[71].xyzx
ge r3.x, cb0[25].z, l(0.000000)
if_nz r3.x
  lt r3.x, r1.w, -cb0[28].y
  if_nz r3.x
    mov r1.w, -cb0[28].y
  endif 
  ge r3.x, r1.w, l(0.000000)
  if_nz r3.x
    mov o7.w, l(0)
    mov r3.xy, l(0,-1,0,0)
  else 
    dp3 r3.z, r1.xyzx, r1.xyzx
    rsq r3.z, r3.z
    mul r9.xyz, r1.xyzx, r3.zzzz
    dp3 r3.z, cb0[26].xyzx, r9.xyzx
    lt r3.w, l(0.000100), |r3.z|
    if_nz r3.w
      div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z
      add r3.w, -r1.w, cb0[25].z
      mul r4.w, r3.z, cb0[25].z
      mad r3.x, r3.w, r3.z, -r4.w
    else 
      mov r3.x, l(0)
    endif 
    lt r3.y, r3.x, l(0.000100)
    if_nz r3.y
      mov o7.w, l(0)
    endif 
  endif 
  if_z r3.y
    mul r3.x, r3.x, cb0[28].x
    mul r3.x, r3.x, l(1.44254541)
    exp r3.x, r3.x
    div r3.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.x
    add o7.w, -r3.x, l(1.000000)
  endif 
else 
  ge r1.w, r1.w, l(0.000000)
  if_nz r1.w
    dp3 r1.w, r1.xyzx, r1.xyzx
    rsq r1.w, r1.w
    mul r3.xyz, r1.wwww, r1.xyzx
    dp3 r1.w, cb0[26].xyzx, r3.xyzx
    lt r3.x, l(0.000100), |r1.w|
    if_nz r3.x
      div r1.w, cb0[25].z, r1.w
    endif 
    lt r3.x, r1.w, l(0.000100)
    if_nz r3.x
      mov o7.w, l(0)
    endif 
  else 
    dp3 r1.x, r1.xyzx, r1.xyzx
    sqrt r1.w, r1.x
    mov r3.x, l(0)
  endif 
  if_z r3.x
    mul r1.x, r1.w, cb0[28].x
    mul r1.x, r1.x, l(1.44254541)
    exp r1.x, r1.x
    div r1.x, l(1.000000, 1.000000, 1.000000, 1.000000), r1.x
    add r1.x, r1.x, l(-1.000000)
    mov o7.w, -r1.x
  endif 
endif 
dp3 r1.x, cb0[29].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r1.x, l(0.001000), r1.x
lt r1.y, r2.w, cb0[25].x
if_nz r1.y
  mul r1.y, r2.w, cb0[25].y
  div r1.y, r1.y, cb0[25].x
else 
  add r1.zw, -cb0[25].yyyx, l(0.000000, 0.000000, 1.000000, 1.000000)
  add r3.x, r2.w, -cb0[25].x
  mul r1.z, r1.z, r3.x
  div r1.z, r1.z, r1.w
  add r1.y, r1.z, cb0[25].y
endif 
mul r1.yzw, r1.yyyy, cb0[29].xxyz
log r1.yzw, r1.yyzw
mul r1.yzw, r1.yyzw, cb0[29].wwww
exp r1.yzw, r1.yyzw
mul r1.yzw, r1.yyzw, l(0.000000, -1.442695, -1.442695, -1.442695)
exp r1.yzw, r1.yyzw
add r1.yzw, -r1.yyzw, l(0.000000, 1.000000, 1.000000, 1.000000)
lt r3.x, l(0.800000), r2.w
and r1.x, r1.x, r3.x
if_nz r1.x
  add r1.x, r2.w, l(-0.800000)
  mul r1.x, r1.x, l(5.000000)
  add r3.xyz, -r1.yzwy, l(1.000000, 1.000000, 1.000000, 0.000000)
  mad r1.yzw, r1.xxxx, r3.xxyz, r1.yyzw
endif 
add r1.x, cb0[30].w, l(-0.250000)
add r1.x, r1.x, r1.x
dp3 r2.w, r1.yzwy, l(0.333300, 0.333300, 0.333300, 0.000000)
add r3.xyz, -r1.yzwy, r2.wwww
mad o7.xyz, r1.xxxx, r3.xyzx, r1.yzwy
sincos r1.x, r3.x, v0.w
mov r9.x, r4.x
mov r9.y, r5.x
mov r9.z, r6.x
dp3 r1.y, cb0[11].xyzx, r9.xyzx
mov r9.x, r4.y
mov r9.y, r5.y
mov r9.z, r6.y
dp3 r1.z, cb0[11].xyzx, r9.xyzx
mov r6.x, r4.z
mov r6.y, r5.z
dp3 r4.z, cb0[11].xyzx, r6.xyzx
lt r1.w, v3.x, l(0.000000)
if_nz r1.w
  mov r2.w, l(1.000000)
endif 
if_z r1.w
  add r0.yzw, -r0.yyzw, r7.xxyz
  ftoi r1.w, v3.x
  imul null, r1.w, r1.w, l(5)
  dp3 r3.y, -cb0[11].xyzx, -cb0[11].xyzx
  rsq r3.y, r3.y
  mul r3.yzw, r3.yyyy, -cb0[11].xxyz
  sincos r5.x, r9.x, v3.z
  mov r5.yz, l(0,99999.000000,0,0)
  mov r4.w, l(0)
  mov r5.w, r1.w
  loop 
    ige r6.w, r4.w, l(5)
    breakc_nz r6.w
    iadd r6.w, r5.w, l(1)
    lt r7.w, cb0[r5.w + 31].w, l(0.100000)
    if_nz r7.w
      break 
    else 
      mul r10.xyzw, v3.yyyy, cb0[r5.w + 31].xyzw
      mul r9.yz, r5.xxxx, r10.zzxz
      mad r10.x, r10.x, r9.x, -r9.y
      mad r10.z, r10.z, r9.x, r9.z
      add r9.yzw, -r0.yyzw, r10.xxyz
      dp3 r7.w, r3.yzwy, r9.yzwy
      mul r10.x, r10.w, r10.w
      dp3 r9.y, r9.yzwy, r9.yzwy
      mad r9.y, -r7.w, r7.w, r9.y
      lt r9.z, r9.y, r10.x
      if_nz r9.z
        mad r9.y, r10.w, r10.w, -r9.y
        sqrt r9.y, r9.y
        lt r9.z, -r9.y, r7.w
        if_nz r9.z
          add r9.z, r7.w, -r9.y
          max r9.z, r9.z, l(0.000000)
          min r5.y, r5.y, r9.z
          add r7.w, r7.w, r9.y
          max r5.z, r5.z, r7.w
        endif 
      endif 
    endif 
    iadd r4.w, r4.w, l(1)
    mov r5.w, r6.w
  endloop 
  lt r0.y, r5.y, r5.z
  if_nz r0.y
    add r0.y, -r5.y, r5.z
    mad_sat r2.w, -r0.y, l(0.250000), l(1.000000)
  else 
    mov r2.w, l(1.000000)
  endif 
endif 
ftoi r0.y, cb0[10].x
mov r5.xyzw, l(0,0,0,0)
loop 
  ige r0.z, r5.w, r0.y
  breakc_nz r0.z
  ge r0.zw, cb0[r5.w + 15].xxxy, l(0.000000, 0.000000, 100.000000, 100.000000)
  if_nz r0.z
    add r0.z, l(-100.000000), cb0[r5.w + 15].x
  else 
    mov r0.z, cb0[r5.w + 15].x
  endif 
  if_nz r0.w
    add r0.w, l(-100.000000), cb0[r5.w + 15].y
  else 
    mov r0.w, cb0[r5.w + 15].y
  endif 
  lt r1.w, l(1.000000), cb0[r5.w + 11].w
  if_nz r1.w
    add r3.yzw, -r7.xxyz, cb0[r5.w + 11].xxyz
    dp3 r1.w, r3.yzwy, r3.yzwy
    sqrt r4.w, r1.w
    div r3.yzw, r3.yyzw, r4.wwww
    mad r1.w, r1.w, cb0[r5.w + 15].w, l(1.000000)
    div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.w
    add r1.w, r1.w, l(-0.100000)
    mul_sat r1.w, r1.w, l(1.11111116)
    lt r4.w, l(2.000000), cb0[r5.w + 11].w
    if_nz r4.w
      add r4.w, l(-3.000000), cb0[r5.w + 11].w
      dp3 r6.w, r3.yzwy, cb0[r5.w + 19].xyzx
      add r7.w, -|r6.w|, l(1.000000)
      sqrt r7.w, r7.w
      mad r9.x, |r6.w|, l(-0.0187292993), l(0.074261)
      mad r9.x, r9.x, |r6.w|, l(-0.212114394)
      mad r9.x, r9.x, |r6.w|, l(1.57072878)
      mul r9.y, r7.w, r9.x
      mad r9.y, r9.y, l(-2.000000), l(3.14159274)
      lt r6.w, r6.w, -r6.w
      and r6.w, r6.w, r9.y
      mad r6.w, r9.x, r7.w, r6.w
      lt r7.w, r6.w, r4.w
      if_nz r7.w
        frc r7.w, cb0[r5.w + 19].w
        div r4.w, r6.w, r4.w
        add r4.w, -r7.w, r4.w
        add r6.w, -r7.w, l(1.000000)
        div_sat r4.w, r4.w, r6.w
        add r4.w, -r4.w, l(1.000000)
      else 
        mov r4.w, l(0)
      endif 
      mul r1.w, r1.w, r4.w
    endif 
  else 
    mov r3.yzw, -cb0[r5.w + 11].xxyz
    mov r1.w, l(1.000000)
  endif 
  if_nz r5.w
    dp3 r3.y, r3.yzwy, -r6.xyzx
    max r3.y, r3.y, l(0.000000)
    mul r9.xy, r0.zwzz, r3.yyyy
    mul r9.z, r3.y, cb0[r5.w + 15].z
    mad r5.xyz, r9.xyzx, r1.wwww, r5.xyzx
  endif 
  iadd r5.w, r5.w, l(1)
endloop 
mov r5.w, l(0)
mul o6.xyzw, r5.xyzw, l(0.250000, 0.250000, 0.250000, 0.250000)
mul r0.y, r1.x, r1.z
mad r4.x, r1.y, r3.x, -r0.y
mul r0.y, r3.x, r1.z
mad r4.y, r1.y, r1.x, r0.y
mad r0.xy, cb0[r0.x + 97].zxzz, cb0[89].zwzz, cb0[89].xyxx
sample_l r0.xyzw, r0.xyxx, t0.xyzw, s0, l(0.000000)
mad r0.xyz, r0.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3_sat r0.x, r0.xyzx, -cb0[11].xyzx
dp3 r0.y, cb0[11].xyzx, r2.xyzx
add_sat r0.y, r0.y, l(0.500000)
mul r0.z, r0.x, r0.y
mul r1.xyz, r0.zzzz, r4.xyzx
mad o5.xyz, r1.xyzx, l(-0.500000, -0.500000, 0.500000, 0.000000), l(0.500000, 0.500000, 0.500000, 0.000000)
add r0.y, -r0.y, l(1.000000)
mul r0.y, r0.y, r2.w
mul o5.w, r0.x, r0.y
mad o3.x, v2.x, cb0[88].w, cb0[88].y
mad r0.x, -v2.y, cb0[88].w, cb0[88].z
add o3.y, r0.x, cb0[88].x
mov o0.xyzw, r8.xyzw
mov o1.xy, v4.xyxx
mov o1.z, l(0)
mov o2.xy, v4.xyxx
mov o4.zw, r8.zzzw
mov o3.z, r8.w
ret 
// Approximately 343 instruction slots used
