// ---- Created with 3Dmigoto v1.2.34 on Fri Apr 29 17:05:11 2016

cbuffer PER_BATCH : register(b0)
{
  float4 VS_SunColor : packoffset(c0);
  float4 OceanParams1 : packoffset(c1);
  float4 OceanParams0 : packoffset(c2);
}

cbuffer PER_INSTANCE : register(b1)
{
  row_major float4x4 mReflProj : packoffset(c0);
}

cbuffer PER_FRAME : register(b3)
{
  row_major float4x4 g_VS_ViewProjMatr : packoffset(c0);
  float4 g_VS_WorldViewPos : packoffset(c6);
  float4 g_VS_AnimGenParams : packoffset(c8);
}

cbuffer PER_MATERIAL : register(b4)
{
  float4 MatSpecColor : packoffset(c1);
  float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3 : packoffset(c2);
  float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2 : packoffset(c3);
  float3 __0Tilling__1DetailTilling__2RipplesNormalsScale__3 : packoffset(c4);
  float __0WaterVolumeFlowSpeed__1__2__3 : packoffset(c5);
}



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


void main( 
  float4 v0 : POSITION0,
  float2 v1 : TEXCOORD0,
  float4 v2 : COLOR0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float4 o5 : TEXCOORD4,
  out float4 o6 : TEXCOORD5,
  out float4 o7 : TEXCOORD6,
  out float4 o8 : TEXCOORD7)
{
  float4 r0,r1,r2,r3;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xyz = g_VS_WorldViewPos.xyz + -v0.xyz;
  r1.x = cmp(0 < r0.z);
  r1.x = r1.x ? 1 : 0;
  r1.y = cmp(r0.z < 0);
  r1.x = (int)r1.y + (int)r1.x;
  r0.w = (int)r1.x;
  r1.x = dot(r0.xyzw, r0.xyzw);
  o4.xyzw = r0.xyzw;
  r0.x = cmp(0.200000003 < abs(r0.z));
  r0.x = r0.x ? 1.000000 : 0;
  r0.y = sqrt(r1.x);
  r0.y = cmp(r0.y < 2);
  r1.xyz = v0.xyz;
  r1.w = 1;
  r0.z = dot(g_VS_ViewProjMatr._m20_m21_m22_m23, r1.xyzw);
  r0.x = r0.z * r0.x;
  o0.z = r0.y ? r0.x : r0.z;
  r0.x = dot(g_VS_ViewProjMatr._m00_m01_m02_m03, r1.xyzw);
  r0.y = dot(g_VS_ViewProjMatr._m10_m11_m12_m13, r1.xyzw);
  r0.w = dot(g_VS_ViewProjMatr._m30_m31_m32_m33, r1.xyzw);
  o0.xyw = r0.xyw;
  
  float4 stereo = StereoParams.Load(0);
  r0.x += stereo.x * (r0.w - stereo.y);
  
  r0.xy = r0.xy * float2(1,-1) + r0.ww;
  o2.xy = float2(0.5,0.5) * r0.xy;
  r0.x = 1;
  r0.z = __0Tilling__1DetailTilling__2RipplesNormalsScale__3.x;
  r2.xyzw = v1.xyxy * r0.xxzz;
  r0.x = __0WaterVolumeFlowSpeed__1__2__3 * g_VS_AnimGenParams.z;
  r3.xyzw = float4(0.25,0,1,0) * r0.xxxx;
  r0.x = __0Tilling__1DetailTilling__2RipplesNormalsScale__3.x;
  r0.z = 2;
  r2.xyzw = r2.xyzw * r0.xxzz + r3.xyzw;
  o1.zw = __0Tilling__1DetailTilling__2RipplesNormalsScale__3.yy * r2.wz;
  o1.xy = r2.xy;
  r0.x = saturate(r0.w);
  o2.w = r0.w;
  r0.x = sqrt(r0.x);
  o2.z = r0.x * -0.150000006 + 1;
  o3.x = dot(mReflProj._m00_m01_m02_m03, r1.xyzw);
  o3.y = dot(mReflProj._m10_m11_m12_m13, r1.xyzw);
  o3.z = dot(mReflProj._m20_m21_m22_m23, r1.xyzw);
  o3.w = dot(mReflProj._m30_m31_m32_m33, r1.xyzw);
  o5.xy = MatSpecColor.ww * float2(4,0.5);
  o5.zw = MatSpecColor.ww * float2(0.636619985,0.0795774981) + float2(0.318309993,0.318309993);
  o6.xyz = MatSpecColor.xyz * VS_SunColor.xyz;
  o6.w = 1;
  o7.xyzw = v0.xyzz;
  r0.xy = g_VS_WorldViewPos.xy * float2(0.200000003,0.200000003);
  r0.xy = frac(r0.xy);
  r0.xy = r0.xy * float2(-5,-5) + g_VS_WorldViewPos.xy;
  r0.xy = -v0.xy + r0.xy;
  o8.xy = r0.xy * float2(0.0250000004,0.0250000004) + float2(0.5,0.5);
  o8.zw = float2(1,1);
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
//
//   using 3Dmigoto v1.2.34 on Fri Apr 29 17:05:11 2016
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float4 VS_SunColor;                // Offset:    0 Size:    16
//   float4 OceanParams1;               // Offset:   16 Size:    16 [unused]
//   float4 OceanParams0;               // Offset:   32 Size:    16 [unused]
//
// }
//
// cbuffer PER_INSTANCE
// {
//
//   row_major float4x4 mReflProj;      // Offset:    0 Size:    64
//
// }
//
// cbuffer PER_FRAME
// {
//
//   row_major float4x4 g_VS_ViewProjMatr;// Offset:    0 Size:    64
//   float4 g_VS_WorldViewPos;          // Offset:   96 Size:    16
//   float4 g_VS_AnimGenParams;         // Offset:  128 Size:    16
//
// }
//
// cbuffer PER_MATERIAL
// {
//
//   float4 MatSpecColor;               // Offset:   16 Size:    16
//   float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3;// Offset:   32 Size:    12 [unused]
//   float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2;// Offset:   48 Size:    16 [unused]
//   float3 __0Tilling__1DetailTilling__2RipplesNormalsScale__3;// Offset:   64 Size:    12
//   float __0WaterVolumeFlowSpeed__1__2__3;// Offset:   80 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PER_BATCH                         cbuffer      NA          NA    0        1
// PER_INSTANCE                      cbuffer      NA          NA    1        1
// PER_FRAME                         cbuffer      NA          NA    3        1
// PER_MATERIAL                      cbuffer      NA          NA    4        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// TEXCOORD                 0   xy          1     NONE   float   xy  
// COLOR                    0   xyzw        2     NONE   float       
//
//
// 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
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyzw        6     NONE   float   xyzw
// TEXCOORD                 6   xyzw        7     NONE   float   xyzw
// TEXCOORD                 7   xyzw        8     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_constantbuffer cb3[9], immediateIndexed
dcl_constantbuffer cb4[6], immediateIndexed
dcl_input v0.xyz
dcl_input v1.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.xyzw
dcl_temps 4
add r0.xyz, -v0.xyzx, cb3[6].xyzx
lt r1.x, l(0.000000), r0.z
and r1.x, r1.x, l(1)
lt r1.y, r0.z, l(0.000000)
iadd r1.x, r1.y, r1.x
itof r0.w, r1.x
dp4 r1.x, r0.xyzw, r0.xyzw
mov o4.xyzw, r0.xyzw
lt r0.x, l(0.200000), |r0.z|
and r0.x, r0.x, l(0x3f800000)
sqrt r0.y, r1.x
lt r0.y, r0.y, l(2.000000)
mov r1.xyz, v0.xyzx
mov r1.w, l(1.000000)
dp4 r0.z, cb3[2].xyzw, r1.xyzw
mul r0.x, r0.x, r0.z
movc o0.z, r0.y, r0.x, r0.z
dp4 r0.x, cb3[0].xyzw, r1.xyzw
dp4 r0.y, cb3[1].xyzw, r1.xyzw
dp4 r0.w, cb3[3].xyzw, r1.xyzw
mov o0.xyw, r0.xyxw
mad r0.xy, r0.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), r0.wwww
mul o2.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mov r0.x, l(1.000000)
mov r0.z, cb4[4].x
mul r2.xyzw, r0.xxzz, v1.xyxy
mul r0.x, cb3[8].z, cb4[5].x
mul r3.xyzw, r0.xxxx, l(0.250000, 0.000000, 1.000000, 0.000000)
mov r0.x, cb4[4].x
mov r0.z, l(2.000000)
mad r2.xyzw, r2.xyzw, r0.xxzz, r3.xyzw
mul o1.zw, r2.wwwz, cb4[4].yyyy
mov o1.xy, r2.xyxx
mov_sat r0.x, r0.w
mov o2.w, r0.w
sqrt r0.x, r0.x
mad o2.z, r0.x, l(-0.150000), l(1.000000)
dp4 o3.x, cb1[0].xyzw, r1.xyzw
dp4 o3.y, cb1[1].xyzw, r1.xyzw
dp4 o3.z, cb1[2].xyzw, r1.xyzw
dp4 o3.w, cb1[3].xyzw, r1.xyzw
mul o5.xy, l(4.000000, 0.500000, 0.000000, 0.000000), cb4[1].wwww
mad o5.zw, cb4[1].wwww, l(0.000000, 0.000000, 0.636620, 0.0795774981), l(0.000000, 0.000000, 0.318310, 0.318310)
mul o6.xyz, cb0[0].xyzx, cb4[1].xyzx
mov o6.w, l(1.000000)
mov o7.xyzw, v0.xyzz
mul r0.xy, l(0.200000, 0.200000, 0.000000, 0.000000), cb3[6].xyxx
frc r0.xy, r0.xyxx
mad r0.xy, r0.xyxx, l(-5.000000, -5.000000, 0.000000, 0.000000), cb3[6].xyxx
add r0.xy, r0.xyxx, -v0.xyxx
mad o8.xy, r0.xyxx, l(0.025000, 0.025000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
mov o8.zw, l(0,0,1.000000,1.000000)
ret 
// Approximately 53 instruction slots used

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