// Water: ponds - FIXED

cbuffer _Globals : register(b0)
{
  row_major float4x4 m_texgen : packoffset(c0);
}

cbuffer dynamic_transforms : register(b1)
{
  row_major float4x4 m_WVP : packoffset(c0);
  row_major float3x4 m_WV : packoffset(c4);
  row_major float3x4 m_W : packoffset(c7);
  float4 L_material : packoffset(c10);
  float4 hemi_cube_pos_faces : packoffset(c11);
  float4 hemi_cube_neg_faces : packoffset(c12);
  float4 dt_params : packoffset(c13);
}

cbuffer static_globals : register(b2)
{
  row_major float3x4 m_V : packoffset(c0);
  row_major float4x4 m_P : packoffset(c3);
  row_major float4x4 m_VP : packoffset(c7);
  float4 timers : packoffset(c11);
  float4 fog_plane : packoffset(c12);
  float4 fog_params : packoffset(c13);
  float4 fog_color : packoffset(c14);
  float4 L_ambient : packoffset(c15);
  float3 L_sun_color : packoffset(c16);
  float3 L_sun_dir_w : packoffset(c17);
  float4 L_hemi_color : packoffset(c18);
  float3 eye_position : packoffset(c19);
  float4 pos_decompression_params : packoffset(c20);
  float4 pos_decompression_params2 : packoffset(c21);
}


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


void main( 
  float4 v0 : POSITION0,
  float4 v1 : NORMAL0,
  float4 v2 : TANGENT0,
  float4 v3 : BINORMAL0,
  float4 v4 : COLOR0,
  int2 v5 : TEXCOORD0,
  out float2 o0 : TEXCOORD0,
  out float2 p0 : TEXCOORD1,
  out float2 o1 : TEXCOORD2,
  out float p1 : FOG0,
  out float4 o2 : TEXCOORD3,
  out float4 o3 : TEXCOORD4,
  out float4 o4 : TEXCOORD5,
  out float4 o5 : TEXCOORD6,
  out float4 o6 : TEXCOORD7,
  out float4 o7 : COLOR0,
  out float4 o8 : SV_Position0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = dot(v0.xz, float2(0.0316650011,0.0349950008));
  r0.x = timers.z + r0.x;
  sincos(r0.x, r0.x, r1.x);
  r0.z = r0.x;
  r0.w = r1.x;
  r1.xyzw = (int4)v5.xyxy;
  r2.xz = v2.ww;
  r2.yw = v3.ww;
  r1.xyzw = r2.xyzw + r1.xyzw;
  r1.xyzw = float4(0.0009765625,0.0009765625,0.00107421877,0.00107421877) * r1.xyzw;
  p0.xy = r0.zw * float2(0.150000006,0.150000006) + r1.xy;
  o0.xy = r1.xy;
  r0.x = dot(v0.xz, float2(0.116104998,0.128315002));
  r0.x = timers.z + r0.x;
  sincos(r0.x, r0.x, r1.x);
  r0.y = r1.x;
  o1.xy = r0.xy * float2(0.550000012,0.550000012) + r1.zw;
  p1.x = saturate(dot(v0.xyzw, fog_plane.xyzw));
  r0.xyz = v2.zyx * float3(2,2,2) + float3(-1,-1,-1);
  o2.x = dot(m_W._m00_m01_m02, r0.xyz);
  r1.xyz = v3.zyx * float3(2,2,2) + float3(-1,-1,-1);
  o2.y = dot(m_W._m00_m01_m02, r1.xyz);
  r2.xyz = v1.zyx * float3(2,2,2) + float3(-1,-1,-1);
  o2.z = dot(m_W._m00_m01_m02, r2.xyz);
  o3.x = dot(m_W._m10_m11_m12, r0.xyz);
  o4.x = dot(m_W._m20_m21_m22, r0.xyz);
  o3.y = dot(m_W._m10_m11_m12, r1.xyz);
  o4.y = dot(m_W._m20_m21_m22, r1.xyz);
  o3.z = dot(m_W._m10_m11_m12, r2.xyz);
  o4.z = dot(m_W._m20_m21_m22, r2.xyz);
  r0.x = dot(v0.xyz, float3(2.75,3.25,1.75));
  r0.x = timers.x + r0.x;
  r0.x = sin(r0.x);
  r0.y = r0.x * 0.0166666675 + v0.y;
  r0.xz = v0.xz;
  o5.xyz = -eye_position.xyz + r0.xyz;
  r0.xzw = v0.xzw;
  o6.x = dot(m_texgen._m00_m01_m02_m03, r0.xyzw);
  o6.y = dot(m_texgen._m10_m11_m12_m13, r0.xyzw);
  o6.w = dot(m_texgen._m30_m31_m32_m33, r0.xyzw);
  o6.z = dot(m_V._m20_m21_m22_m23, r0.xyzw);
  r1.x = r2.y * 0.5 + 0.5;
  r1.y = dot(r2.xyz, -L_sun_dir_w.xyz);
  r1.yzw = L_sun_color.xyz * r1.yyy;
  r2.xyz = L_hemi_color.xyz * r1.xxx;
  r2.xyz = r2.xyz * v1.www + v4.zyx;
  r1.xyz = r1.yzw * v4.www + r2.xyz;
  o7.xyz = L_ambient.xyz + r1.xyz;
  o7.w = 1;
  o8.x = dot(m_VP._m00_m01_m02_m03, r0.xyzw);
  o8.y = dot(m_VP._m10_m11_m12_m13, r0.xyzw);
  o8.z = dot(m_VP._m20_m21_m22_m23, r0.xyzw);
  o8.w = dot(m_VP._m30_m31_m32_m33, r0.xyzw);
float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);
o6.x += stereo.x * (o6.w - stereo.y)/2;

  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
//   using 3Dmigoto v1.2.29 on Wed Apr 06 23:19:32 2016
//
//
// Buffer Definitions: 
//
// cbuffer $Globals
// {
//
//   row_major float4x4 m_texgen;       // Offset:    0 Size:    64
//
// }
//
// cbuffer dynamic_transforms
// {
//
//   row_major float4x4 m_WVP;          // Offset:    0 Size:    64 [unused]
//   row_major float3x4 m_WV;           // Offset:   64 Size:    48 [unused]
//   row_major float3x4 m_W;            // Offset:  112 Size:    48
//   float4 L_material;                 // Offset:  160 Size:    16 [unused]
//   float4 hemi_cube_pos_faces;        // Offset:  176 Size:    16 [unused]
//   float4 hemi_cube_neg_faces;        // Offset:  192 Size:    16 [unused]
//   float4 dt_params;                  // Offset:  208 Size:    16 [unused]
//
// }
//
// cbuffer static_globals
// {
//
//   row_major float3x4 m_V;            // Offset:    0 Size:    48
//   row_major float4x4 m_P;            // Offset:   48 Size:    64 [unused]
//   row_major float4x4 m_VP;           // Offset:  112 Size:    64
//   float4 timers;                     // Offset:  176 Size:    16
//   float4 fog_plane;                  // Offset:  192 Size:    16
//   float4 fog_params;                 // Offset:  208 Size:    16 [unused]
//   float4 fog_color;                  // Offset:  224 Size:    16 [unused]
//   float4 L_ambient;                  // Offset:  240 Size:    16
//   float3 L_sun_color;                // Offset:  256 Size:    12
//   float3 L_sun_dir_w;                // Offset:  272 Size:    12
//   float4 L_hemi_color;               // Offset:  288 Size:    16
//   float3 eye_position;               // Offset:  304 Size:    12
//   float4 pos_decompression_params;   // Offset:  320 Size:    16 [unused]
//   float4 pos_decompression_params2;  // Offset:  336 Size:    16 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
// dynamic_transforms                cbuffer      NA          NA    1        1
// static_globals                    cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// NORMAL                   0   xyzw        1     NONE   float   xyzw
// TANGENT                  0   xyzw        2     NONE   float   xyzw
// BINORMAL                 0   xyzw        3     NONE   float   xyzw
// COLOR                    0   xyzw        4     NONE   float   xyzw
// TEXCOORD                 0   xy          5     NONE     int   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1     zw        0     NONE   float     zw
// TEXCOORD                 2   xy          1     NONE   float   xy  
// FOG                      0     z         1     NONE   float     z 
// TEXCOORD                 3   xyz         2     NONE   float   xyz 
// TEXCOORD                 4   xyz         3     NONE   float   xyz 
// TEXCOORD                 5   xyz         4     NONE   float   xyz 
// TEXCOORD                 6   xyz         5     NONE   float   xyz 
// TEXCOORD                 7   xyzw        6     NONE   float   xyzw
// COLOR                    0   xyzw        7     NONE   float   xyzw
// SV_Position              0   xyzw        8      POS   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[4], immediateIndexed
dcl_constantbuffer cb1[10], immediateIndexed
dcl_constantbuffer cb2[20], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xyzw
dcl_input v2.xyzw
dcl_input v3.xyzw
dcl_input v4.xyzw
dcl_input v5.xy
dcl_output o0.xy
dcl_output o0.zw
dcl_output o1.xy
dcl_output o1.z
dcl_output o2.xyz
dcl_output o3.xyz
dcl_output o4.xyz
dcl_output o5.xyz
dcl_output o6.xyzw
dcl_output o7.xyzw
dcl_output_siv o8.xyzw, position
dcl_temps 3
dp2 r0.x, v0.xzxx, l(0.031665, 0.034995, 0.000000, 0.000000)
add r0.x, r0.x, cb2[11].z
sincos r0.x, r1.x, r0.x
mov r0.z, r0.x
mov r0.w, r1.x
itof r1.xyzw, v5.xyxy
mov r2.xz, v2.wwww
mov r2.yw, v3.wwww
add r1.xyzw, r1.xyzw, r2.xyzw
mul r1.xyzw, r1.xyzw, l(0.000976562500, 0.000976562500, 0.00107421877, 0.00107421877)
mad o0.zw, r0.zzzw, l(0.000000, 0.000000, 0.150000, 0.150000), r1.xxxy
mov o0.xy, r1.xyxx
dp2 r0.x, v0.xzxx, l(0.116105, 0.128315, 0.000000, 0.000000)
add r0.x, r0.x, cb2[11].z
sincos r0.x, r1.x, r0.x
mov r0.y, r1.x
mad o1.xy, r0.xyxx, l(0.550000, 0.550000, 0.000000, 0.000000), r1.zwzz
dp4_sat o1.z, v0.xyzw, cb2[12].xyzw
mad r0.xyz, v2.zyxz, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 o2.x, cb1[7].xyzx, r0.xyzx
mad r1.xyz, v3.zyxz, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 o2.y, cb1[7].xyzx, r1.xyzx
mad r2.xyz, v1.zyxz, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
dp3 o2.z, cb1[7].xyzx, r2.xyzx
dp3 o3.x, cb1[8].xyzx, r0.xyzx
dp3 o4.x, cb1[9].xyzx, r0.xyzx
dp3 o3.y, cb1[8].xyzx, r1.xyzx
dp3 o4.y, cb1[9].xyzx, r1.xyzx
dp3 o3.z, cb1[8].xyzx, r2.xyzx
dp3 o4.z, cb1[9].xyzx, r2.xyzx
dp3 r0.x, v0.xyzx, l(2.750000, 3.250000, 1.750000, 0.000000)
add r0.x, r0.x, cb2[11].x
sincos r0.x, null, r0.x
mad r0.y, r0.x, l(0.0166666675), v0.y
mov r0.xz, v0.xxzx
add o5.xyz, r0.xyzx, -cb2[19].xyzx
mov r0.xzw, v0.xxzw
dp4 o6.x, cb0[0].xyzw, r0.xyzw
dp4 o6.y, cb0[1].xyzw, r0.xyzw
dp4 o6.w, cb0[3].xyzw, r0.xyzw
dp4 o6.z, cb2[2].xyzw, r0.xyzw
mad r1.x, r2.y, l(0.500000), l(0.500000)
dp3 r1.y, r2.xyzx, -cb2[17].xyzx
mul r1.yzw, r1.yyyy, cb2[16].xxyz
mul r2.xyz, r1.xxxx, cb2[18].xyzx
mad r2.xyz, r2.xyzx, v1.wwww, v4.zyxz
mad r1.xyz, r1.yzwy, v4.wwww, r2.xyzx
add o7.xyz, r1.xyzx, cb2[15].xyzx
mov o7.w, l(1.000000)
dp4 o8.x, cb2[7].xyzw, r0.xyzw
dp4 o8.y, cb2[8].xyzw, r0.xyzw
dp4 o8.z, cb2[9].xyzw, r0.xyzw
dp4 o8.w, cb2[10].xyzw, r0.xyzw
ret 
// Approximately 54 instruction slots used

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