//Water VS 8 masterotaku.
// ---- Created with 3Dmigoto v1.2.45 on Tue Nov 08 10:49:44 2016
cbuffer cb2 : register(b2)
{
  float4 cb2[14];
}

cbuffer cb1 : register(b1)
{
  float4 cb1[6];
}

cbuffer cb0 : register(b0)
{
  float4 cb0[1];
}




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

void main( 
  float4 v0 : POSITION0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : COLOR0,
  out float4 o2 : TEXCOORD0,
  out float4 o3 : TEXCOORD1,
  out float4 o4 : TEXCOORD2,
  out float4 o5 : TEXCOORD3,
  out float4 o6 : TEXCOORD4,
  out float4 o7 : TEXCOORD5,
out float4 o8: TEXCOORD6)
{
  float4 r0,r1,r10,r11;
  uint4 bitmask, uiDest;
  float4 fDest;
matrix vp = {cb2[8], cb2[9], cb2[10], cb2[11]};
matrix ivp = inverse(vp);

float4 stereo = StereoParams.Load(0);
float4 params = IniParams.Load(0);
  
  r0.xyz = v0.xyz;
  r0.w = 1;
  r1.z = dot(cb2[10].xyzw, r0.xyzw);
  r1.w = -70000 + r1.z;
  r1.w = max(0, r1.w);
  r1.w = 9.99999975e-005 * r1.w;
  r1.w = min(1, r1.w);
  o0.z = r1.w * 0.5 + r1.z;
  r1.x = dot(cb2[8].xyzw, r0.xyzw);
  r1.y = dot(cb2[9].xyzw, r0.xyzw);
  o0.xy = r1.xy;
  r1.x = dot(r1.xyz, r1.xyz);
  r1.x = sqrt(r1.x);
  r1.x = saturate(r1.x * cb1[0].y + -cb1[0].x);
  r1.x = log2(r1.x);
  r1.x = cb1[5].w * r1.x;
  r1.x = exp2(r1.x);
  r1.x = min(cb1[2].w, r1.x);
  o0.w = dot(cb2[11].xyzw, r0.xyzw);
  r1.yzw = cb1[2].xyz + -cb1[1].xyz;
  o1.xyz = r1.xxx * r1.yzw + cb1[1].xyz;
  o1.w = r1.x;
float4 tmp = mul(vp, r0);
tmp.x+=stereo.x*(tmp.w-stereo.y);
r10=mul(ivp, tmp);
  r1.z = dot(cb2[2].xyzw, r0.xyzw);
  r1.x = dot(cb2[0].xyzw, r0.xyzw);
  r1.y = dot(cb2[1].xyzw, r0.xyzw);
r11.z = dot(cb2[2].xyzw, r10.xyzw);
r11.x = dot(cb2[0].xyzw, r10.xyzw);
r11.y = dot(cb2[1].xyzw, r10.xyzw);
o7.xyzw = r10.xyzw;
  //o7.xyzw = r0.xyzw;
  
// World space fix
// float4 tmp = mul(vp, r0);
// tmp.x+=stereo.x*(tmp.w-stereo.y);
// o7=mul(ivp, tmp);

  r0.x = dot(r1.xyz, r1.xyz);
  //o2.xyz = r1.xyz;
o2.xyz = r11.xyz;
o8.xyz = r1.xyz;
  r0.yz = cb0[0].xy + r1.xy;
  o2.w = sqrt(r0.x);
o8.w = sqrt(r0.x);
  r1.xyzw = r0.yzyz / cb1[5].xxyy;
  r0.xy = r0.yz / cb1[5].zz;
  o4.xy = cb1[4].xy + r0.xy;
  o3.xyzw = cb1[3].xyzw + r1.xyzw;
  r0.xy = float2(-0.5,-0.5) + v1.xy;
  r0.xy = r0.xy * float2(0.100000001,0.100000001) + cb2[13].xy;
  r0.z = -cb2[13].w + cb2[12].x;
  r0.w = r0.z / cb2[12].x;
  r0.z = cb2[13].z / cb2[12].x;
  o4.zw = r0.xy + r0.zw;
  r0.xy = v1.xy * float2(0.5,0.5) + cb2[12].yz;
  o5.xy = float2(-0.25,-0.25) + r0.xy;
  o5.zw = v1.xy;
  o6.x = cb2[12].x;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.45 on Tue Nov 08 10:49:44 2016
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz 
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// COLOR                    0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 0   xyzw        2     NONE   float   xyzw
// TEXCOORD                 1   xyzw        3     NONE   float   xyzw
// TEXCOORD                 2   xyzw        4     NONE   float   xyzw
// TEXCOORD                 3   xyzw        5     NONE   float   xyzw
// TEXCOORD                 4   x           6     NONE   float   x   
// TEXCOORD                 5   xyzw        7     NONE   float   xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb2[14], 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.x
dcl_output o7.xyzw
dcl_temps 2
mov r0.xyz, v0.xyzx
mov r0.w, l(1.000000)
dp4 r1.z, cb2[10].xyzw, r0.xyzw
add r1.w, r1.z, l(-70000.000000)
max r1.w, r1.w, l(0.000000)
mul r1.w, r1.w, l(0.000100)
min r1.w, r1.w, l(1.000000)
mad o0.z, r1.w, l(0.500000), r1.z
dp4 r1.x, cb2[8].xyzw, r0.xyzw
dp4 r1.y, cb2[9].xyzw, r0.xyzw
mov o0.xy, r1.xyxx
dp3 r1.x, r1.xyzx, r1.xyzx
sqrt r1.x, r1.x
mad_sat r1.x, r1.x, cb1[0].y, -cb1[0].x
log r1.x, r1.x
mul r1.x, r1.x, cb1[5].w
exp r1.x, r1.x
min r1.x, r1.x, cb1[2].w
dp4 o0.w, cb2[11].xyzw, r0.xyzw
add r1.yzw, -cb1[1].xxyz, cb1[2].xxyz
mad o1.xyz, r1.xxxx, r1.yzwy, cb1[1].xyzx
mov o1.w, r1.x
dp4 r1.z, cb2[2].xyzw, r0.xyzw
dp4 r1.x, cb2[0].xyzw, r0.xyzw
dp4 r1.y, cb2[1].xyzw, r0.xyzw
mov o7.xyzw, r0.xyzw
dp3 r0.x, r1.xyzx, r1.xyzx
mov o2.xyz, r1.xyzx
add r0.yz, r1.xxyx, cb0[0].xxyx
sqrt o2.w, r0.x
div r1.xyzw, r0.yzyz, cb1[5].xxyy
div r0.xy, r0.yzyy, cb1[5].zzzz
add o4.xy, r0.xyxx, cb1[4].xyxx
add o3.xyzw, r1.xyzw, cb1[3].xyzw
add r0.xy, v1.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mad r0.xy, r0.xyxx, l(0.100000, 0.100000, 0.000000, 0.000000), cb2[13].xyxx
add r0.z, cb2[12].x, -cb2[13].w
div r0.w, r0.z, cb2[12].x
div r0.z, cb2[13].z, cb2[12].x
add o4.zw, r0.zzzw, r0.xxxy
mad r0.xy, v1.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), cb2[12].yzyy
add o5.xy, r0.xyxx, l(-0.250000, -0.250000, 0.000000, 0.000000)
mov o5.zw, v1.xxxy
mov o6.x, cb2[12].x
ret 
// Approximately 0 instruction slots used

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