//
// 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 [unused]
//   float4 g_vMaskCoord;               // Offset:  656 Size:    16
//   float4 g_vTerrainNormCoord;        // Offset:  672 Size:    16
//   float4 g_vExclusionMask;           // Offset:  688 Size:    16 [unused]
//      = 0x3f800000 0x3f800000 0x3f800000 0x3f800000 
//   float4 g_avFaceK[2];               // Offset:  704 Size:    32 [unused]
//   float4 g_vCamPos;                  // Offset:  736 Size:    16
//   float4 g_vConstraints;             // Offset:  752 Size:    16
//   float4 g_avTreeCenter[128];        // Offset:  768 Size:  2048
//   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_tTerrainNormTexture             texture  float4          2d    0        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   xy w
// 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   xy w
// 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_input v0.xyz
dcl_input v1.xyw
dcl_input v2.xyz
dcl_input v3.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyw
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 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, v1.w
mov r1.xyz, cb0[r0.x + 48].xyzx
mov r1.w, l(1.000000)
add r1.xyzw, r1.xyzw, cb0[39].xyzw
add r0.yzw, v0.xxyz, cb0[r0.x + 48].xxyz
mov r2.xz, v1.xxyx
mov r2.yw, l(0,0,0,1.000000)
add r2.xyz, r0.yzwy, -r2.xyzx
add r2.xyzw, r2.xyzw, cb0[39].xyzw
// replacing matrix usage :dp4 r3.x, r2.xyzw, cb0[31].xyzw
dp4 r11.x, r2.xyzw, cb0[31].xyzw
mul r3.x, r11.x, r13.x
// replacing matrix usage :dp4 r3.y, r2.xyzw, cb0[32].xyzw
dp4 r11.y, r2.xyzw, cb0[32].xyzw
mul r3.y, r11.y, r13.y
dp4 r4.z, r2.xyzw, cb0[33].xyzw
dp4 r3.w, r2.xyzw, cb0[34].xyzw
mov r5.xyz, r2.xyzx
mov r5.w, l(1.000000)
dp4 o2.z, r5.xyzw, cb0[176].xyzw
dp4 o2.w, r5.xyzw, cb0[178].xyzw
lt r0.y, l(0.500000), cb0[23].y
if_nz r0.y
// replacing matrix usage :  dp3 r6.x, v2.xyzx, cb0[35].xyzx
dp3 r11.x, v2.xyzx, cb0[35].xyzx
mul r6.x, r11.x, r13.x
// replacing matrix usage :  dp3 r6.y, v2.xyzx, cb0[36].xyzx
dp3 r11.y, v2.xyzx, cb0[36].xyzx
mul r6.y, r11.y, r13.y
  dp3 r6.z, v2.xyzx, cb0[37].xyzx
else 
  add r0.y, r3.w, r3.x
  mul r4.x, r0.y, l(0.500000)
  add r0.y, -r3.y, r3.w
  mul r4.y, r0.y, l(0.500000)
  mov r6.xyz, r4.xyzx
endif 
mad r0.yz, cb0[r0.x + 48].zzxz, cb0[42].zzwz, cb0[42].xxyx
sample_l r7.xyzw, r0.yzyy, t0.xyzw, s0, l(0.000000)
mad r0.yzw, r7.xxyz, l(0.000000, 2.000000, 2.000000, 2.000000), l(0.000000, -1.000000, -1.000000, -1.000000)
dp3_sat r0.y, r0.yzwy, -cb0[11].xyzx
ftoi r0.z, cb0[10].x
mov r4.xyw, l(0,0,0,0)
mov r7.xyz, l(0,0,0,0)
mov r0.w, l(0)
loop 
  ige r2.w, r0.w, r0.z
  breakc_nz r2.w
  ge r8.xy, cb0[r0.w + 15].xyxx, l(100.000000, 100.000000, 0.000000, 0.000000)
  if_nz r8.x
    add r2.w, l(-100.000000), cb0[r0.w + 15].x
  else 
    mov r2.w, cb0[r0.w + 15].x
  endif 
  if_nz r8.y
    add r7.w, l(-100.000000), cb0[r0.w + 15].y
  else 
    mov r7.w, cb0[r0.w + 15].y
  endif 
  lt r8.x, l(1.000000), cb0[r0.w + 11].w
  if_nz r8.x
    add r8.xyz, -r2.xyzx, cb0[r0.w + 11].xyzx
    dp3 r8.w, r8.xyzx, r8.xyzx
    sqrt r9.x, r8.w
    div r8.xyz, r8.xyzx, r9.xxxx
    mad r8.w, r8.w, cb0[r0.w + 15].w, l(1.000000)
    div r8.w, l(1.000000, 1.000000, 1.000000, 1.000000), r8.w
    add r8.w, r8.w, l(-0.100000)
    mul_sat r8.w, r8.w, l(1.11111116)
    lt r9.x, l(2.000000), cb0[r0.w + 11].w
    if_nz r9.x
      add r9.x, l(-3.000000), cb0[r0.w + 11].w
      dp3 r9.y, r8.xyzx, cb0[r0.w + 19].xyzx
      add r9.z, -|r9.y|, l(1.000000)
      sqrt r9.z, r9.z
      mad r9.w, |r9.y|, l(-0.0187292993), l(0.074261)
      mad r9.w, r9.w, |r9.y|, l(-0.212114394)
      mad r9.w, r9.w, |r9.y|, l(1.57072878)
      mul r10.x, r9.z, r9.w
      mad r10.x, r10.x, l(-2.000000), l(3.14159274)
      lt r9.y, r9.y, -r9.y
      and r9.y, r9.y, r10.x
      mad r9.y, r9.w, r9.z, r9.y
      lt r9.z, r9.y, r9.x
      if_nz r9.z
        frc r9.z, cb0[r0.w + 19].w
        div r9.x, r9.y, r9.x
        add r9.x, -r9.z, r9.x
        add r9.y, -r9.z, l(1.000000)
        div_sat r9.x, r9.x, r9.y
        add r9.x, -r9.x, l(1.000000)
      else 
        mov r9.x, l(0)
      endif 
      mul r8.w, r8.w, r9.x
    endif 
  else 
    mov r8.xyz, -cb0[r0.w + 11].xyzx
    mov r8.w, l(1.000000)
  endif 
  dp3 r8.x, r8.xyzx, v2.xyzx
  max r8.x, r8.x, l(0.000000)
  mul r9.x, r2.w, r8.x
  mul r9.y, r7.w, r8.x
  mul r9.z, r8.x, cb0[r0.w + 15].z
  mul r8.xyz, r8.wwww, r9.xyzx
  if_z r0.w
    mov r4.xyw, r8.xyxz
  else 
    mad r7.xyz, r9.xyzx, r8.wwww, r7.xyzx
  endif 
  iadd r0.w, r0.w, l(1)
endloop 
mul r0.yzw, r0.yyyy, r4.xxyw
mul o5.xyz, r0.yzwy, l(0.250000, 0.250000, 0.250000, 0.000000)
mov o5.w, l(0)
mul o6.xyz, r7.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.y, r1.xyzw, r1.xyzw
sqrt r0.y, r0.y
lt r0.z, cb0[47].x, r0.y
if_nz r0.z
  mov r1.xyzw, l(0,0,0,0)
else 
  mov r3.z, r4.z
  mov r1.xyzw, r3.xyzw
endif 
add r0.y, -r0.y, cb0[47].x
mul_sat o1.w, r0.y, l(0.010000)
div r0.y, l(0.500000), r1.w
mad o3.x, r1.x, r0.y, l(0.500000)
mad o3.y, -r1.y, r0.y, l(0.500000)
add r0.yzw, r5.xxyz, -cb0[46].xxyz
dp3 r0.y, r0.yzwy, r0.yzwy
sqrt r0.y, r0.y
mul r0.y, r0.y, cb0[30].x
min r0.y, r0.y, l(1.000000)
dp4 r0.z, r5.xyzw, cb0[26].xyzw
add r2.xyz, -r2.xyzx, cb0[46].xyzx
ge r0.w, cb0[25].z, l(0.000000)
if_nz r0.w
  lt r0.w, r0.z, -cb0[28].y
  if_nz r0.w
    mov r0.z, -cb0[28].y
  endif 
  ge r0.w, r0.z, l(0.000000)
  if_nz r0.w
    mov o7.w, l(0)
    mov r0.w, l(0)
    mov r2.w, l(-1)
  else 
    dp3 r3.x, r2.xyzx, r2.xyzx
    rsq r3.x, r3.x
    mul r3.xyz, r2.xyzx, r3.xxxx
    dp3 r3.x, cb0[26].xyzx, r3.xyzx
    lt r3.y, l(0.000100), |r3.x|
    if_nz r3.y
      div r3.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.x
      add r3.y, -r0.z, cb0[25].z
      mul r3.z, r3.x, cb0[25].z
      mad r0.w, r3.y, r3.x, -r3.z
    else 
      mov r0.w, l(0)
    endif 
    lt r2.w, r0.w, l(0.000100)
    if_nz r2.w
      mov o7.w, l(0)
    endif 
  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 o7.w, -r0.w, l(1.000000)
  endif 
else 
  ge r0.z, r0.z, l(0.000000)
  if_nz r0.z
    dp3 r0.z, r2.xyzx, r2.xyzx
    rsq r0.z, r0.z
    mul r3.xyz, r0.zzzz, r2.xyzx
    dp3 r0.z, cb0[26].xyzx, r3.xyzx
    lt r0.w, l(0.000100), |r0.z|
    if_nz r0.w
      div r0.z, cb0[25].z, r0.z
    endif 
    lt r0.w, r0.z, l(0.000100)
    if_nz r0.w
      mov o7.w, l(0)
    endif 
  else 
    dp3 r2.x, r2.xyzx, r2.xyzx
    sqrt r0.z, r2.x
    mov r0.w, l(0)
  endif 
  if_z r0.w
    mul r0.z, r0.z, cb0[28].x
    mul r0.z, r0.z, l(1.44254541)
    exp r0.z, r0.z
    div r0.z, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
    add r0.z, r0.z, l(-1.000000)
    mov o7.w, -r0.z
  endif 
endif 
dp3 r0.z, cb0[29].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r0.w, r0.y, cb0[25].x
if_nz r0.w
  mul r0.w, r0.y, cb0[25].y
  div r0.w, r0.w, cb0[25].x
else 
  add r2.xy, -cb0[25].yxyy, l(1.000000, 1.000000, 0.000000, 0.000000)
  add r2.z, r0.y, -cb0[25].x
  mul r2.x, r2.z, r2.x
  div r2.x, r2.x, r2.y
  add r0.w, r2.x, cb0[25].y
endif 
mul r2.xyz, r0.wwww, cb0[29].xyzx
log r2.xyz, r2.xyzx
mul r2.xyz, r2.xyzx, cb0[29].wwww
exp r2.xyz, r2.xyzx
mul r2.xyz, r2.xyzx, l(-1.442695, -1.442695, -1.442695, 0.000000)
exp r2.xyz, r2.xyzx
add r2.xyz, -r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
lt r0.zw, l(0.000000, 0.000000, 0.001000, 0.800000), r0.zzzy
and r0.z, r0.z, r0.w
if_nz r0.z
  add r0.y, r0.y, l(-0.800000)
  mul r0.y, r0.y, l(5.000000)
  add r3.xyz, -r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
  mad r2.xyz, r0.yyyy, r3.xyzx, r2.xyzx
endif 
add r0.y, cb0[30].w, l(-0.250000)
add r0.y, r0.y, r0.y
dp3 r0.z, r2.xyzx, l(0.333300, 0.333300, 0.333300, 0.000000)
add r3.xyz, -r2.xyzx, r0.zzzz
mad o7.xyz, r0.yyyy, r3.xyzx, r2.xyzx
mad o2.x, cb0[r0.x + 48].x, cb0[41].w, cb0[41].y
mad r0.x, -cb0[r0.x + 48].z, cb0[41].w, cb0[41].z
add o2.y, r0.x, cb0[41].x
mov o0.xyzw, r1.xyzw
mov o3.zw, r1.zzzw
mov r6.w, r3.w
mov o4.xyzw, r6.xyzw
mov o1.xy, v3.xyxx
mov o8.xyz, r5.xyzx
ret 
// Approximately 240 instruction slots used
