// ---- Created with 3Dmigoto v1.2.31 on Fri Feb 26 09:26:25 2016

cbuffer PER_BATCH : register(b0)
{
  float4 _WaveLevels : packoffset(c0);
  float4 _WaveVtxPhases : packoffset(c1);
  float4 _WaveInfoX : packoffset(c2);
  float4 _InstancingParams : packoffset(c3);
  float4 _WaveAmp : packoffset(c4);
  float4 vfRampParams : packoffset(c5);
  float4 _WaveFreq : packoffset(c6);
  float4 DiffusesVS[4] : packoffset(c7);
  float4 vfParams : packoffset(c11);
  float4 vfViewPos : packoffset(c12);
}

cbuffer PER_INSTANCE : register(b1)
{
  float4 HMAGradients : packoffset(c0);
}

cbuffer STATIC_INSTANCE : register(b2)
{
  row_major float3x4 ObjWorldMatrix : packoffset(c0);
  float4 BendInfo : packoffset(c3);
  float4 AmbientObjectCol : packoffset(c4);
}

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

cbuffer PER_MATERIAL : register(b4)
{
  float4 MatSpecColor : packoffset(c1);
  float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3 : packoffset(c2);
  float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2 : packoffset(c3);
  float4 __0__1BackViewDep__2BackDiffuseMultiplier__3blendWithTerrainAmount : packoffset(c4);
  float4 BackDiffuse : packoffset(c6);
}



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


void main( 
  float4 v0 : POSITION0,
  float4 v1 : TEXCOORD0,
  float4 v2 : COLOR0,
  float4 v3 : TANGENT0,
  float4 v4 : BINORMAL0,
  out float4 o0 : SV_Position0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float4 o5 : COLOR0)
{
  float4 r0,r1,r2,r3,r4,r5;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = BendInfo.z * v0.z;
  r0.x = r0.x * r0.x;
  r0.xy = BendInfo.xy * r0.xx + v0.xy;
  r0.z = v0.z;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r0.w = dot(v0.xyz, v0.xyz);
  r0.w = sqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r1.x = abs(ObjWorldMatrix._m00) + abs(ObjWorldMatrix._m01);
  r1.x = abs(ObjWorldMatrix._m02) + r1.x;
  r2.xy = r1.xx * r0.xy;
  r2.zw = r2.xy * r2.xy;
  r1.y = dot(r2.xyzw, HMAGradients.xyzw);
  r2.w = -g_VS_WorldViewPos.x + ObjWorldMatrix._m03;
  r3.x = r2.w;
  r4.w = -g_VS_WorldViewPos.y + ObjWorldMatrix._m13;
  r3.y = r4.w;
  r3.z = -g_VS_WorldViewPos.z + ObjWorldMatrix._m23;
  r5.xyz = r0.xyz * r1.xxx + r3.xyz;
  r5.z = r5.z + r1.y;
  r5.w = 1;
  r1.x = dot(g_VS_ViewProjZeroMatr._m00_m01_m02_m03, r5.xyzw);
  r1.y = dot(g_VS_ViewProjZeroMatr._m10_m11_m12_m13, r5.xyzw);
  r1.z = dot(g_VS_ViewProjZeroMatr._m20_m21_m22_m23, r5.xyzw);
  r1.w = dot(g_VS_ViewProjZeroMatr._m30_m31_m32_m33, r5.xyzw);
  o0.xyzw = r1.xyzw;
  
  float4 stereo = StereoParams.Load(0);
  r1.x += stereo.x * (r1.w - stereo.y);
  
  r1.xy = r1.xy * float2(1,-1) + r1.ww;
  o2.zw = r1.zw;
  o2.xy = float2(0.5,0.5) * r1.xy;
  o1.xy = v1.xy;
  o1.zw = float2(0,0);
  r2.xyz = ObjWorldMatrix._m00_m01_m02;
  r0.w = 1;
  r1.x = dot(r2.xyzw, r0.xyzw);
  r4.xyz = ObjWorldMatrix._m10_m11_m12;
  r1.y = dot(r4.xyzw, r0.xyzw);
  r3.xyw = ObjWorldMatrix._m20_m21_m22;
  r1.z = dot(r3.xywz, r0.xyzw);
  r0.x = dot(-r1.xyz, -r1.xyz);
  r0.x = rsqrt(r0.x);
  r0.xyz = -r1.xyz * r0.xxx;
  r0.w = saturate(dot(r0.xyz, -g_VS_SunLightDir.xyz));
  r0.w = r0.w * r0.w;
  r0.w = r0.w * r0.w;
  r1.xyz = float3(9.99999997e-007,0,0) + v3.xyz;
  r2.y = dot(ObjWorldMatrix._m00_m01_m02, r1.xyz);
  r2.z = dot(ObjWorldMatrix._m10_m11_m12, r1.xyz);
  r2.x = dot(ObjWorldMatrix._m20_m21_m22, r1.xyz);
  r1.x = dot(r2.xyz, r2.xyz);
  r1.x = rsqrt(r1.x);
  r1.xyz = r2.xyz * r1.xxx;
  r2.xyz = float3(-9.99999997e-007,0,0) + v4.xyz;
  r3.z = dot(ObjWorldMatrix._m00_m01_m02, r2.xyz);
  r3.x = dot(ObjWorldMatrix._m10_m11_m12, r2.xyz);
  r3.y = dot(ObjWorldMatrix._m20_m21_m22, r2.xyz);
  r1.w = dot(r3.xyz, r3.xyz);
  r1.w = rsqrt(r1.w);
  r2.xyz = r3.xyz * r1.www;
  r3.xyz = r2.xyz * r1.xyz;
  r1.xyz = r1.zxy * r2.yzx + -r3.xyz;
  r1.xyz = v3.www * r1.xyz;
  r0.x = dot(r0.xyz, r1.xyz);
  r0.x = 0.100000001 + r0.x;
  r0.x = min(1, r0.x);
  r0.xyz = r1.xyz * r0.xxx;
  r1.x = dot(-r0.xyz, g_VS_SunLightDir.xyz);
  r1.x = saturate(r1.x * 0.600000024 + 0.400000006);
  r1.y = -__0__1BackViewDep__2BackDiffuseMultiplier__3blendWithTerrainAmount.y + 1;
  r1.x = r1.y * r1.x;
  r0.w = saturate(r0.w * __0__1BackViewDep__2BackDiffuseMultiplier__3blendWithTerrainAmount.y + r1.x);
  r1.xyz = DiffusesVS[0].xyz * r0.www;
  r2.xyz = BackDiffuse.xyz * __0__1BackViewDep__2BackDiffuseMultiplier__3blendWithTerrainAmount.zzz;
  r2.xyz = AmbientObjectCol.www * r2.xyz;
  o3.xyz = r2.xyz * r1.xyz;
  o3.w = 0;
  r0.x = dot(r0.xyz, g_VS_SunLightDir.xyz);
  o5.z = r0.z * 0.25 + 0.75;
  r0.x = max(0.5, r0.x);
  o4.xyz = DiffusesVS[0].xyz * r0.xxx;
  o4.w = 0;
  o5.w = AmbientObjectCol.x * v2.w;
  o5.xy = AmbientObjectCol.wy;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.2.31 on Fri Feb 26 09:26:25 2016
//
//
// Buffer Definitions: 
//
// cbuffer PER_BATCH
// {
//
//   float4 _WaveLevels;                // Offset:    0 Size:    16 [unused]
//   float4 _WaveVtxPhases;             // Offset:   16 Size:    16 [unused]
//   float4 _WaveInfoX;                 // Offset:   32 Size:    16 [unused]
//   float4 _InstancingParams;          // Offset:   48 Size:    16 [unused]
//   float4 _WaveAmp;                   // Offset:   64 Size:    16 [unused]
//   float4 vfRampParams;               // Offset:   80 Size:    16 [unused]
//   float4 _WaveFreq;                  // Offset:   96 Size:    16 [unused]
//   float4 DiffusesVS[4];              // Offset:  112 Size:    64
//   float4 vfParams;                   // Offset:  176 Size:    16 [unused]
//   float4 vfViewPos;                  // Offset:  192 Size:    16 [unused]
//
// }
//
// cbuffer PER_INSTANCE
// {
//
//   float4 HMAGradients;               // Offset:    0 Size:    16
//
// }
//
// cbuffer STATIC_INSTANCE
// {
//
//   row_major float3x4 ObjWorldMatrix; // Offset:    0 Size:    48
//   float4 BendInfo;                   // Offset:   48 Size:    16
//   float4 AmbientObjectCol;           // Offset:   64 Size:    16
//
// }
//
// cbuffer PER_FRAME
// {
//
//   row_major float4x4 g_VS_ViewProjMatr;// Offset:    0 Size:    64 [unused]
//   float4 g_VS_SunLightDir;           // Offset:   64 Size:    16
//   float4 g_VS_WorldViewPos;          // Offset:   96 Size:    16
//   float4 g_VS_AnimGenParams;         // Offset:  128 Size:    16 [unused]
//   row_major float4x4 g_VS_ViewProjZeroMatr;// Offset:  160 Size:    64
//
// }
//
// cbuffer PER_MATERIAL
// {
//
//   float4 MatSpecColor;               // Offset:   16 Size:    16 [unused]
//   float3 __0bendDetailFrequency__1bendDetailLeafAmplitude__2bendDetailBranchAmplitude__3;// Offset:   32 Size:    12 [unused]
//   float4 __0AnimFrequency__1AnimAmplitudeWav0__2AnimPhase__3AnimAmplitudeWav2;// Offset:   48 Size:    16 [unused]
//   float4 __0__1BackViewDep__2BackDiffuseMultiplier__3blendWithTerrainAmount;// Offset:   64 Size:    16
//   float4 BackDiffuse;                // Offset:   96 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PER_BATCH                         cbuffer      NA          NA    0        1
// PER_INSTANCE                      cbuffer      NA          NA    1        1
// STATIC_INSTANCE                   cbuffer      NA          NA    2        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   xyzw        1     NONE   float   xy  
// COLOR                    0   xyzw        2     NONE   float      w
// TANGENT                  0   xyzw        3     NONE   float   xyzw
// BINORMAL                 0   xyzw        4     NONE   float   xyz 
//
//
// 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
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[8], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[5], immediateIndexed
dcl_constantbuffer cb3[14], immediateIndexed
dcl_constantbuffer cb4[7], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xy
dcl_input v2.w
dcl_input v3.xyzw
dcl_input v4.xyz
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_temps 6
mul r0.x, v0.z, cb2[3].z
mul r0.x, r0.x, r0.x
mad r0.xy, cb2[3].xyxx, r0.xxxx, v0.xyxx
mov r0.z, v0.z
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
dp3 r0.w, v0.xyzx, v0.xyzx
sqrt r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
add r1.x, |cb2[0].y|, |cb2[0].x|
add r1.x, r1.x, |cb2[0].z|
mul r2.xy, r0.xyxx, r1.xxxx
mul r2.zw, r2.xxxy, r2.xxxy
dp4 r1.y, r2.xyzw, cb1[0].xyzw
add r2.w, cb2[0].w, -cb3[6].x
mov r3.x, r2.w
add r4.w, cb2[1].w, -cb3[6].y
mov r3.y, r4.w
add r3.z, cb2[2].w, -cb3[6].z
mad r5.xyz, r0.xyzx, r1.xxxx, r3.xyzx
add r5.z, r1.y, r5.z
mov r5.w, l(1.000000)
dp4 r1.x, cb3[10].xyzw, r5.xyzw
dp4 r1.y, cb3[11].xyzw, r5.xyzw
dp4 r1.z, cb3[12].xyzw, r5.xyzw
dp4 r1.w, cb3[13].xyzw, r5.xyzw
mov o0.xyzw, r1.xyzw
mad r1.xy, r1.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), r1.wwww
mov o2.zw, r1.zzzw
mul o2.xy, r1.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mov o1.xy, v1.xyxx
mov o1.zw, l(0,0,0,0)
mov r2.xyz, cb2[0].xyzx
mov r0.w, l(1.000000)
dp4 r1.x, r2.xyzw, r0.xyzw
mov r4.xyz, cb2[1].xyzx
dp4 r1.y, r4.xyzw, r0.xyzw
mov r3.xyw, cb2[2].xyxz
dp4 r1.z, r3.xywz, r0.xyzw
dp3 r0.x, -r1.xyzx, -r1.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, -r1.xyzx
dp3_sat r0.w, r0.xyzx, -cb3[4].xyzx
mul r0.w, r0.w, r0.w
mul r0.w, r0.w, r0.w
add r1.xyz, v3.xyzx, l(0.000001, 0.000000, 0.000000, 0.000000)
dp3 r2.y, cb2[0].xyzx, r1.xyzx
dp3 r2.z, cb2[1].xyzx, r1.xyzx
dp3 r2.x, cb2[2].xyzx, r1.xyzx
dp3 r1.x, r2.xyzx, r2.xyzx
rsq r1.x, r1.x
mul r1.xyz, r1.xxxx, r2.xyzx
add r2.xyz, v4.xyzx, l(-0.000001, 0.000000, 0.000000, 0.000000)
dp3 r3.z, cb2[0].xyzx, r2.xyzx
dp3 r3.x, cb2[1].xyzx, r2.xyzx
dp3 r3.y, cb2[2].xyzx, r2.xyzx
dp3 r1.w, r3.xyzx, r3.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r3.xyzx
mul r3.xyz, r1.xyzx, r2.xyzx
mad r1.xyz, r1.zxyz, r2.yzxy, -r3.xyzx
mul r1.xyz, r1.xyzx, v3.wwww
dp3 r0.x, r0.xyzx, r1.xyzx
add r0.x, r0.x, l(0.100000)
min r0.x, r0.x, l(1.000000)
mul r0.xyz, r0.xxxx, r1.xyzx
dp3 r1.x, -r0.xyzx, cb3[4].xyzx
mad_sat r1.x, r1.x, l(0.600000), l(0.400000)
add r1.y, l(1.000000), -cb4[4].y
mul r1.x, r1.x, r1.y
mad_sat r0.w, r0.w, cb4[4].y, r1.x
mul r1.xyz, r0.wwww, cb0[7].xyzx
mul r2.xyz, cb4[4].zzzz, cb4[6].xyzx
mul r2.xyz, r2.xyzx, cb2[4].wwww
mul o3.xyz, r1.xyzx, r2.xyzx
mov o3.w, l(0)
dp3 r0.x, r0.xyzx, cb3[4].xyzx
mad o5.z, r0.z, l(0.250000), l(0.750000)
max r0.x, r0.x, l(0.500000)
mul o4.xyz, r0.xxxx, cb0[7].xyzx
mov o4.w, l(0)
mul o5.w, v2.w, cb2[4].x
mov o5.xy, cb2[4].wyww
ret 
// Approximately 85 instruction slots used

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