//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//   using 3Dmigoto v1.2.67 on Mon Jan 01 13:11:46 2018
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   float4 g_vDitherSettings;          // Offset:    0 Size:    16 [unused]
//   float4 g_vKSettings;               // Offset:   16 Size:    16 [unused]
//   float4x4 g_mPrevObjViewProj;       // Offset:   32 Size:    64 [unused]
//   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
//   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
//   float4x4 g_mViewProj;              // Offset:  496 Size:    64
//   float4x4 g_mView;                  // Offset:  560 Size:    64
//   float4 g_vOffset;                  // Offset:  624 Size:    16
//   float4 g_vPixelOffset;             // Offset:  640 Size:    16
//   float4 g_vMaskCoord;               // Offset:  656 Size:    16
//   float4 g_vTerrainNormCoord;        // Offset:  672 Size:    16
//   float4 g_vExclusionMask;           // Offset:  688 Size:    16
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_avFaceK[2];               // Offset:  704 Size:    32
//   float4 g_vCamPos;                  // Offset:  736 Size:    16
//   float4 g_vConstraints;             // Offset:  752 Size:    16
//   float4 g_avTreeCenter[128];        // Offset:  768 Size:  2048 [unused]
//   float4x4 g_mCloudsShadowsSpace;    // Offset: 2816 Size:    64
//   float4 g_vCloudsShadowDesc;        // Offset: 2880 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// LerpSampler                       sampler      NA          NA    0        1
// g_tMaskTexture                    texture  float4          2d    0        1
// g_tTerrainNormTexture             texture  float4          2d    1        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyz         0     NONE   float   xyz 
// POSITION                 1   xyzw        1     NONE   float   xyz 
// NORMAL                   0   xyz         2     NONE   float   xyz 
// TEXCOORD                 0   xy          3     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   xyzw        3     NONE   float   xyzw
// 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   xyz         8     NONE   float   xyz 
//
vs_4_0
dcl_constantbuffer cb0[179], dynamicIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input v0.xyz
dcl_input v1.xyz
dcl_input v2.xyz
dcl_input v3.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output o8.xyz
// dcl_temps updated : previous = dcl_temps 10
dcl_temps 13
// added 3dmigoto declaration
dcl_resource_texture1d (float,float,float,float) t120
ld_indexable(texture1d)(float,float,float,float) r11.xyzw, l(0, 0, 0, 0), t120.xyzw
mov r12.x, r11.w
mov r12.y, r11.w
mov r12.zw, l(1.0, 1.0)
// end of 3dmigoto declaration
mad r0.x, v1.x, cb0[41].w, cb0[41].y
mad r0.z, -v1.y, cb0[41].w, cb0[41].z
add r0.y, r0.z, cb0[41].x
sample_l r1.xyzw, r0.xyxx, t0.xyzw, s0, l(0.000000)
mul r0.zw, r1.yyyz, cb0[43].yyyz
ge r0.z, l(0.500000), r0.z
ge r0.w, r0.w, l(0.500000)
or r0.z, r0.w, r0.z
if_nz r0.z
  mov o0.xyzw, l(0,0,0,0)
  mov o1.xyzw, l(0,0,0,0)
  mov o2.xyzw, l(0,0,0,0)
  mov o3.xyzw, l(0,0,0,0)
  mov o4.xyzw, l(0,0,0,0)
  mov o5.xyzw, l(0,0,0,0)
  mov o6.xyzw, l(0,0,0,0)
  mov o7.xyzw, l(0,0,0,0)
  mov o8.xyz, l(0,0,0,0)
  ret 
endif 
add r0.zw, v1.zzzy, -cb0[40].wwwy
ftou r0.z, r0.z
add r1.x, -v1.x, cb0[40].x
mad r1.x, cb0[r0.z + 44].x, r1.x, cb0[r0.z + 44].z
mad r0.z, cb0[r0.z + 44].y, r0.w, r1.x
mov r1.xz, v1.xxyx
mov r1.yw, l(0,0,0,1.000000)
add r1.xyzw, r1.xyzw, cb0[39].xyzw
mov r2.xyz, v0.xyzx
mov r2.w, l(1.000000)
add r2.xyzw, r2.xyzw, cb0[39].xyzw
mad r2.y, r0.z, cb0[44].w, r2.y
mad r1.y, r0.z, cb0[44].w, r1.y
// replacing matrix usage :dp4 r3.x, r2.xyzw, cb0[31].xyzw
dp4 r10.x, r2.xyzw, cb0[31].xyzw
mul r3.x, r10.x, r12.x
// replacing matrix usage :dp4 r3.y, r2.xyzw, cb0[32].xyzw
dp4 r10.y, r2.xyzw, cb0[32].xyzw
mul r3.y, r10.y, r12.y
dp4 r4.z, r2.xyzw, cb0[33].xyzw
dp4 r3.w, r2.xyzw, cb0[34].xyzw
mov r2.w, l(1.000000)
dp4 o2.z, r2.xyzw, cb0[176].xyzw
dp4 o2.w, r2.xyzw, cb0[178].xyzw
lt r0.z, l(0.500000), cb0[23].y
if_nz r0.z
// replacing matrix usage :  dp3 r5.x, v2.xyzx, cb0[35].xyzx
dp3 r10.x, v2.xyzx, cb0[35].xyzx
mul r5.x, r10.x, r12.x
// replacing matrix usage :  dp3 r5.y, v2.xyzx, cb0[36].xyzx
dp3 r10.y, v2.xyzx, cb0[36].xyzx
mul r5.y, r10.y, r12.y
  dp3 r5.z, v2.xyzx, cb0[37].xyzx
else 
  add r0.z, r3.w, r3.x
  mul r4.x, r0.z, l(0.500000)
  add r0.z, -r3.y, r3.w
  mul r4.y, r0.z, l(0.500000)
  mov r5.xyz, r4.xyzx
endif 
mad r0.zw, v1.yyyx, cb0[42].zzzw, cb0[42].xxxy
sample_l r6.xyzw, r0.zwzz, t1.xyzw, s0, l(0.000000)
mad r4.xyw, r6.xyxz, l(2.000000, 2.000000, 0.000000, 2.000000), l(-1.000000, -1.000000, 0.000000, -1.000000)
dp3_sat r0.z, r4.xywx, -cb0[11].xyzx
ftoi r0.w, cb0[10].x
mov r4.xyw, l(0,0,0,0)
mov r6.xyzw, l(0,0,0,0)
loop 
  ige r7.x, r6.w, r0.w
  breakc_nz r7.x
  ge r7.xy, cb0[r6.w + 15].xyxx, l(100.000000, 100.000000, 0.000000, 0.000000)
  if_nz r7.x
    add r7.x, l(-100.000000), cb0[r6.w + 15].x
  else 
    mov r7.x, cb0[r6.w + 15].x
  endif 
  if_nz r7.y
    add r7.y, l(-100.000000), cb0[r6.w + 15].y
  else 
    mov r7.y, cb0[r6.w + 15].y
  endif 
  lt r7.z, l(1.000000), cb0[r6.w + 11].w
  if_nz r7.z
    add r8.xyz, -r2.xyzx, cb0[r6.w + 11].xyzx
    dp3 r7.z, r8.xyzx, r8.xyzx
    sqrt r7.w, r7.z
    div r8.xyz, r8.xyzx, r7.wwww
    mad r7.z, r7.z, cb0[r6.w + 15].w, l(1.000000)
    div r7.z, l(1.000000, 1.000000, 1.000000, 1.000000), r7.z
    add r7.z, r7.z, l(-0.100000)
    mul_sat r7.z, r7.z, l(1.11111116)
    lt r7.w, l(2.000000), cb0[r6.w + 11].w
    if_nz r7.w
      add r7.w, l(-3.000000), cb0[r6.w + 11].w
      dp3 r8.w, r8.xyzx, cb0[r6.w + 19].xyzx
      add r9.x, -|r8.w|, l(1.000000)
      sqrt r9.x, r9.x
      mad r9.y, |r8.w|, l(-0.0187292993), l(0.074261)
      mad r9.y, r9.y, |r8.w|, l(-0.212114394)
      mad r9.y, r9.y, |r8.w|, l(1.57072878)
      mul r9.z, r9.x, r9.y
      mad r9.z, r9.z, l(-2.000000), l(3.14159274)
      lt r8.w, r8.w, -r8.w
      and r8.w, r8.w, r9.z
      mad r8.w, r9.y, r9.x, r8.w
      lt r9.x, r8.w, r7.w
      if_nz r9.x
        frc r9.x, cb0[r6.w + 19].w
        div r7.w, r8.w, r7.w
        add r7.w, -r9.x, r7.w
        add r8.w, -r9.x, l(1.000000)
        div_sat r7.w, r7.w, r8.w
        add r7.w, -r7.w, l(1.000000)
      else 
        mov r7.w, l(0)
      endif 
      mul r7.z, r7.w, r7.z
    endif 
  else 
    mov r8.xyz, -cb0[r6.w + 11].xyzx
    mov r7.z, l(1.000000)
  endif 
  dp3 r7.w, r8.xyzx, v2.xyzx
  max r7.w, r7.w, l(0.000000)
  mul r8.xy, r7.wwww, r7.xyxx
  mul r8.z, r7.w, cb0[r6.w + 15].z
  mul r7.xyw, r7.zzzz, r8.xyxz
  if_z r6.w
    mov r4.xyw, r7.xyxw
  else 
    mad r6.xyz, r8.xyzx, r7.zzzz, r6.xyzx
  endif 
  iadd r6.w, r6.w, l(1)
endloop 
mul r4.xyw, r0.zzzz, r4.xyxw
mul o5.xyz, r4.xywx, l(0.250000, 0.250000, 0.250000, 0.000000)
mov o5.w, l(0)
mul o6.xyz, r6.xyzx, l(0.250000, 0.250000, 0.250000, 0.000000)
mov o6.w, l(0)
add r1.xyzw, r1.xyzw, -cb0[46].xyzw
dp4 r0.z, r1.xyzw, r1.xyzw
sqrt r0.z, r0.z
lt r0.w, cb0[47].x, r0.z
if_nz r0.w
  mov r1.xyzw, l(0,0,0,0)
else 
  mov r3.z, r4.z
  mov r1.xyzw, r3.xyzw
endif 
add r0.z, -r0.z, cb0[47].x
mul_sat o1.w, r0.z, l(0.010000)
div r0.z, l(0.500000), r1.w
mad o3.x, r1.x, r0.z, l(0.500000)
mad o3.y, -r1.y, r0.z, l(0.500000)
add r3.xyz, r2.xyzx, -cb0[46].xyzx
dp3 r0.z, r3.xyzx, r3.xyzx
sqrt r0.z, r0.z
mul r0.z, r0.z, cb0[30].x
min r0.z, r0.z, l(1.000000)
dp4 r0.w, r2.xyzw, cb0[26].xyzw
add r3.xyz, -r2.xyzx, cb0[46].xyzx
ge r2.w, cb0[25].z, l(0.000000)
if_nz r2.w
  lt r2.w, r0.w, -cb0[28].y
  if_nz r2.w
    mov r0.w, -cb0[28].y
  endif 
  ge r2.w, r0.w, l(0.000000)
  if_nz r2.w
    mov o7.w, l(0)
    mov r2.w, l(0)
    mov r4.x, l(-1)
  else 
    dp3 r4.y, r3.xyzx, r3.xyzx
    rsq r4.y, r4.y
    mul r4.yzw, r3.xxyz, r4.yyyy
    dp3 r4.y, cb0[26].xyzx, r4.yzwy
    lt r4.z, l(0.000100), |r4.y|
    if_nz r4.z
      div r4.y, l(1.000000, 1.000000, 1.000000, 1.000000), r4.y
      add r4.z, -r0.w, cb0[25].z
      mul r4.w, r4.y, cb0[25].z
      mad r2.w, r4.z, r4.y, -r4.w
    else 
      mov r2.w, l(0)
    endif 
    lt r4.x, r2.w, l(0.000100)
    if_nz r4.x
      mov o7.w, l(0)
    endif 
  endif 
  if_z r4.x
    mul r2.w, r2.w, cb0[28].x
    mul r2.w, r2.w, l(1.44254541)
    exp r2.w, r2.w
    div r2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r2.w
    add o7.w, -r2.w, l(1.000000)
  endif 
else 
  ge r0.w, r0.w, l(0.000000)
  if_nz r0.w
    dp3 r0.w, r3.xyzx, r3.xyzx
    rsq r0.w, r0.w
    mul r4.xyz, r0.wwww, r3.xyzx
    dp3 r0.w, cb0[26].xyzx, r4.xyzx
    lt r2.w, l(0.000100), |r0.w|
    if_nz r2.w
      div r0.w, cb0[25].z, r0.w
    endif 
    lt r2.w, r0.w, l(0.000100)
    if_nz r2.w
      mov o7.w, l(0)
    endif 
  else 
    dp3 r3.x, r3.xyzx, r3.xyzx
    sqrt r0.w, r3.x
    mov r2.w, l(0)
  endif 
  if_z r2.w
    mul r0.w, r0.w, cb0[28].x
    mul r0.w, r0.w, l(1.44254541)
    exp r0.w, r0.w
    div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
    add r0.w, r0.w, l(-1.000000)
    mov o7.w, -r0.w
  endif 
endif 
dp3 r0.w, cb0[29].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r0.w, l(0.001000), r0.w
lt r2.w, r0.z, cb0[25].x
if_nz r2.w
  mul r2.w, r0.z, cb0[25].y
  div r2.w, r2.w, cb0[25].x
else 
  add r3.xy, -cb0[25].yxyy, l(1.000000, 1.000000, 0.000000, 0.000000)
  add r3.z, r0.z, -cb0[25].x
  mul r3.x, r3.z, r3.x
  div r3.x, r3.x, r3.y
  add r2.w, r3.x, cb0[25].y
endif 
mul r3.xyz, r2.wwww, cb0[29].xyzx
log r3.xyz, r3.xyzx
mul r3.xyz, r3.xyzx, cb0[29].wwww
exp r3.xyz, r3.xyzx
mul r3.xyz, r3.xyzx, l(-1.442695, -1.442695, -1.442695, 0.000000)
exp r3.xyz, r3.xyzx
add r3.xyz, -r3.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r2.w, l(0.800000), r0.z
and r0.w, r0.w, r2.w
if_nz r0.w
  add r0.z, r0.z, l(-0.800000)
  mul r0.z, r0.z, l(5.000000)
  add r4.xyz, -r3.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mad r3.xyz, r0.zzzz, r4.xyzx, r3.xyzx
endif 
add r0.z, cb0[30].w, l(-0.250000)
add r0.z, r0.z, r0.z
dp3 r0.w, r3.xyzx, l(0.333300, 0.333300, 0.333300, 0.000000)
add r4.xyz, -r3.xyzx, r0.wwww
mad o7.xyz, r0.zzzz, r4.xyzx, r3.xyzx
mov o0.xyzw, r1.xyzw
mov o1.xy, v3.xyxx
mov o1.z, l(0)
mov o2.xy, r0.xyxx
mov o3.zw, r1.zzzw
mov r5.w, r3.w
mov o4.xyzw, r5.xyzw
mov o8.xyz, r2.xyzx
ret 
// Approximately 261 instruction slots used
