// ---- Created with 3Dmigoto v1.2.35 on Tue Apr 26 22:30:27 2016

cbuffer cbWaterHeightMap : register(b0)
{
  float4 g_ClickPos : packoffset(c0);
  float g_heightMapWidth : packoffset(c1);
  float g_heightMapHeight : packoffset(c1.y);
  float g_areaWidth : packoffset(c1.z);
  float g_areaHeight : packoffset(c1.w);
  float g_deltaTime : packoffset(c2);
  float g_totalTime : packoffset(c2.y);
  float g_interactionType : packoffset(c2.z);
  float g_waveSpeed : packoffset(c2.w);
  float g_waveLength : packoffset(c3);
  float g_waveAmp : packoffset(c3.y);
  float g_circularAge : packoffset(c3.z);
  float g_circularWaveNum : packoffset(c3.w);
  float g_femAttenuation : packoffset(c4);
  float g_femDt : packoffset(c4.y);
  float g_femDx : packoffset(c4.z);
  float g_waveK : packoffset(c4.w);
  float4 g_vecTranslate : packoffset(c5);
}

SamplerState SS_DiffuseMap_s : register(s0);
Texture2D<float4> g_DiffuseTexture : register(t0);
Texture2D<float4> g_DiffuseTexture2 : register(t7);


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


void main( 
  float4 v0 : SV_Position0,
  float2 v1 : TEXCOORD0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.x = g_interactionType;
  switch (r0.x) {
    case 0 :    r0.x = 0;
    break;
    case 1 :    r0.y = max(0.00100000005, g_heightMapHeight);
    r0.y = -v0.y / r0.y;
    r0.z = 0.5 * g_areaHeight;
    r0.y = r0.y * g_areaHeight + r0.z;
    r0.z = max(0.00100000005, g_waveLength);
    r0.z = 6.28318405 / r0.z;
    r0.w = g_waveSpeed * r0.z;
    r1.x = g_waveAmp + g_waveAmp;
    r0.w = g_totalTime * r0.w;
    r0.y = r0.y * r0.z + r0.w;
    r0.y = sin(r0.y);
    r0.y = 1 + r0.y;
    r0.y = 0.5 * r0.y;
    r0.y = log2(r0.y);
    r0.y = g_waveK * r0.y;
    r0.y = exp2(r0.y);
    r0.x = r1.x * r0.y;
    break;
    case 2 :    r0.yz = max(float2(0.00100000005,0.00100000005), g_heightMapWidth);
    r1.xy = float2(1,-1) * v0.xy;
    r0.yz = r1.xy / r0.yz;
    r1.xy = float2(-0.5,0.5) * g_areaWidth;
    r0.yz = r0.yz * g_areaWidth + r1.xy;
    r1.xy = g_ClickPos.xz + -r0.yz;
    r0.w = dot(r1.xy, r1.xy);
    r1.z = rsqrt(r0.w);
    r1.xy = r1.xy * r1.zz;
    r0.w = sqrt(r0.w);
    r1.zw = max(float2(0.00100000005,0.00100000005), g_waveLength);
    r1.z = 6.28318405 / r1.z;
    r2.x = g_waveSpeed * r1.z;
    r1.w = saturate(g_totalTime / r1.w);
    r1.w = 1 + -r1.w;
    r2.y = -1 + g_circularWaveNum;
    r2.y = g_waveLength * r2.y;
    r2.y = g_waveLength * 0.5 + -r2.y;
    r2.y = g_totalTime * g_waveSpeed + r2.y;
    r2.y = cmp(r0.w < r2.y);
    r2.z = g_totalTime * g_waveSpeed + g_waveLength;
    r0.w = cmp(r2.z < r0.w);
    r0.w = (int)r0.w | (int)r2.y;
    r1.w = dot(r1.ww, g_waveAmp);
    r0.w = r0.w ? 0 : r1.w;
    r0.yz = -g_ClickPos.xz + r0.yz;
    r0.y = dot(r1.xy, r0.yz);
    r0.z = g_totalTime * r2.x;
    r0.y = r0.y * r1.z + r0.z;
    r0.y = sin(r0.y);
    r0.y = 1 + r0.y;
    r0.y = 0.5 * r0.y;
    r0.y = log2(r0.y);
    r0.y = g_waveK * r0.y;
    r0.y = exp2(r0.y);
    r0.x = r0.w * r0.y;
    break;
    case 3 :    r0.y = max(0.00100000005, g_heightMapWidth);
    r0.y = 1 / r0.y;
    r0.z = g_waveSpeed * g_waveSpeed;
    r1.xy = g_femDt * g_femDt;
    r0.z = r1.x * r0.z;
    r0.w = max(0.00100000005, r1.y);
    r0.z = r0.z / r0.w;
    r1.xy = g_femAttenuation * g_femDt + float2(-2,2);
    r0.w = r1.x / r1.y;
    r1.x = -r0.z * 8 + 4;
    r1.x = r1.x / r1.y;
    r0.z = r0.z + r0.z;
    r0.z = r0.z / r1.y;
    r1.yz = v0.xy * r0.yy;
    r2.xy = g_vecTranslate.xy + v0.xy;
    r3.xy = r2.xy * r0.yy;
    r2.zw = g_vecTranslate.zw + r2.xy;
    r2.zw = r2.zw * r0.yy;
    r4.xy = cmp(r0.yy >= r1.yz);
    r1.w = 1 + -r0.y;
    r1.yz = cmp(r1.yz >= r1.ww);
    r1.y = (int)r1.y | (int)r4.x;
    r1.y = (int)r4.y | (int)r1.y;
    r1.y = (int)r1.z | (int)r1.y;
    r1.z = g_DiffuseTexture2.SampleLevel(SS_DiffuseMap_s, r2.zw, 0).x;
    r1.w = g_DiffuseTexture.SampleLevel(SS_DiffuseMap_s, r3.xy, 0).x;
    r3.zw = r2.yx * r0.yy + r0.yy;
    r2.z = g_DiffuseTexture.SampleLevel(SS_DiffuseMap_s, r3.xz, 0).x;
    r4.xy = r2.yx * r0.yy + -r0.yy;
    r4.zw = r3.xy;
    r0.y = g_DiffuseTexture.SampleLevel(SS_DiffuseMap_s, r4.zx, 0).x;
    r2.x = g_DiffuseTexture.SampleLevel(SS_DiffuseMap_s, r3.wy, 0).x;
    r2.y = g_DiffuseTexture.SampleLevel(SS_DiffuseMap_s, r4.yw, 0).x;
    r1.x = r1.x * r1.w;
    r0.w = r0.w * r1.z + r1.x;
    r0.y = r2.z + r0.y;
    r0.y = r0.y + r2.x;
    r0.y = r0.y + r2.y;
    r0.y = r0.z * r0.y + r0.w;
    r0.y = min(1, r0.y);
    r0.x = r1.y ? 0 : r0.y;
    break;
    default :
    r0.x = 0;
    break;
  }
  o0.xyz = r0.xxx;
  o0.w = 1;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbWaterHeightMap
// {
//
//   float4 g_ClickPos;                 // Offset:    0 Size:    16
//   float g_heightMapWidth;            // Offset:   16 Size:     4
//   float g_heightMapHeight;           // Offset:   20 Size:     4
//   float g_areaWidth;                 // Offset:   24 Size:     4
//   float g_areaHeight;                // Offset:   28 Size:     4
//   float g_deltaTime;                 // Offset:   32 Size:     4 [unused]
//   float g_totalTime;                 // Offset:   36 Size:     4
//   float g_interactionType;           // Offset:   40 Size:     4
//   float g_waveSpeed;                 // Offset:   44 Size:     4
//   float g_waveLength;                // Offset:   48 Size:     4
//   float g_waveAmp;                   // Offset:   52 Size:     4
//   float g_circularAge;               // Offset:   56 Size:     4
//   float g_circularWaveNum;           // Offset:   60 Size:     4
//   float g_femAttenuation;            // Offset:   64 Size:     4
//   float g_femDt;                     // Offset:   68 Size:     4
//   float g_femDx;                     // Offset:   72 Size:     4
//   float g_waveK;                     // Offset:   76 Size:     4
//   float4 g_vecTranslate;             // Offset:   80 Size:    16
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_DiffuseMap                     sampler      NA          NA    0        1
// g_DiffuseTexture                  texture  float4          2d    0        1
// g_DiffuseTexture2                 texture  float4          2d    7        1
// cbWaterHeightMap                  cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy  
// TEXCOORD                 0   xy          1     NONE   float       
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[6], immediateIndexed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t7
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 5
ftou r0.x, cb0[2].z
switch r0.x
  case l(0)
  mov r0.x, l(0)
  break 
  case l(1)
  max r0.y, cb0[1].y, l(0.001000)
  div r0.y, -v0.y, r0.y
  mul r0.z, cb0[1].w, l(0.500000)
  mad r0.y, r0.y, cb0[1].w, r0.z
  max r0.z, cb0[3].x, l(0.001000)
  div r0.z, l(6.283184), r0.z
  mul r0.w, r0.z, cb0[2].w
  add r1.x, cb0[3].y, cb0[3].y
  mul r0.w, r0.w, cb0[2].y
  mad r0.y, r0.y, r0.z, r0.w
  sincos r0.y, null, r0.y
  add r0.y, r0.y, l(1.000000)
  mul r0.y, r0.y, l(0.500000)
  log r0.y, r0.y
  mul r0.y, r0.y, cb0[4].w
  exp r0.y, r0.y
  mul r0.x, r0.y, r1.x
  break 
  case l(2)
  max r0.yz, cb0[1].xxyx, l(0.000000, 0.001000, 0.001000, 0.000000)
  mul r1.xy, v0.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000)
  div r0.yz, r1.xxyx, r0.yyzy
  mul r1.xy, cb0[1].zwzz, l(-0.500000, 0.500000, 0.000000, 0.000000)
  mad r0.yz, r0.yyzy, cb0[1].zzwz, r1.xxyx
  add r1.xy, -r0.yzyy, cb0[0].xzxx
  dp2 r0.w, r1.xyxx, r1.xyxx
  rsq r1.z, r0.w
  mul r1.xy, r1.zzzz, r1.xyxx
  sqrt r0.w, r0.w
  max r1.zw, cb0[3].xxxz, l(0.000000, 0.000000, 0.001000, 0.001000)
  div r1.z, l(6.283184), r1.z
  mul r2.x, r1.z, cb0[2].w
  div_sat r1.w, cb0[2].y, r1.w
  add r1.w, -r1.w, l(1.000000)
  add r2.y, cb0[3].w, l(-1.000000)
  mul r2.y, r2.y, cb0[3].x
  mad r2.y, cb0[3].x, l(0.500000), -r2.y
  mad r2.y, cb0[2].y, cb0[2].w, r2.y
  lt r2.y, r0.w, r2.y
  mad r2.z, cb0[2].y, cb0[2].w, cb0[3].x
  lt r0.w, r2.z, r0.w
  or r0.w, r0.w, r2.y
  dp2 r1.w, r1.wwww, cb0[3].yyyy
  movc r0.w, r0.w, l(0), r1.w
  add r0.yz, r0.yyzy, -cb0[0].xxzx
  dp2 r0.y, r1.xyxx, r0.yzyy
  mul r0.z, r2.x, cb0[2].y
  mad r0.y, r0.y, r1.z, r0.z
  sincos r0.y, null, r0.y
  add r0.y, r0.y, l(1.000000)
  mul r0.y, r0.y, l(0.500000)
  log r0.y, r0.y
  mul r0.y, r0.y, cb0[4].w
  exp r0.y, r0.y
  mul r0.x, r0.y, r0.w
  break 
  case l(3)
  max r0.y, cb0[1].x, l(0.001000)
  div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
  mul r0.z, cb0[2].w, cb0[2].w
  mul r1.xy, cb0[4].yzyy, cb0[4].yzyy
  mul r0.z, r0.z, r1.x
  max r0.w, r1.y, l(0.001000)
  div r0.z, r0.z, r0.w
  mad r1.xy, cb0[4].xxxx, cb0[4].yyyy, l(-2.000000, 2.000000, 0.000000, 0.000000)
  div r0.w, r1.x, r1.y
  mad r1.x, -r0.z, l(8.000000), l(4.000000)
  div r1.x, r1.x, r1.y
  add r0.z, r0.z, r0.z
  div r0.z, r0.z, r1.y
  mul r1.yz, r0.yyyy, v0.xxyx
  add r2.xy, v0.xyxx, cb0[5].xyxx
  mul r3.xy, r0.yyyy, r2.xyxx
  add r2.zw, r2.xxxy, cb0[5].zzzw
  mul r2.zw, r0.yyyy, r2.zzzw
  ge r4.xy, r0.yyyy, r1.yzyy
  add r1.w, -r0.y, l(1.000000)
  ge r1.yz, r1.yyzy, r1.wwww
  or r1.y, r1.y, r4.x
  or r1.y, r4.y, r1.y
  or r1.y, r1.z, r1.y
  sample_l_indexable(texture2d)(float,float,float,float) r1.z, r2.zwzz, t7.yzxw, s0, l(0.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r1.w, r3.xyxx, t0.yzwx, s0, l(0.000000)
  mad r3.zw, r2.yyyx, r0.yyyy, r0.yyyy
  sample_l_indexable(texture2d)(float,float,float,float) r2.z, r3.xzxx, t0.yzxw, s0, l(0.000000)
  mad r4.xy, r2.yxyy, r0.yyyy, -r0.yyyy
  mov r4.zw, r3.xxxy
  sample_l_indexable(texture2d)(float,float,float,float) r0.y, r4.zxzz, t0.yxzw, s0, l(0.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r2.x, r3.wyww, t0.xyzw, s0, l(0.000000)
  sample_l_indexable(texture2d)(float,float,float,float) r2.y, r4.ywyy, t0.yxzw, s0, l(0.000000)
  mul r1.x, r1.w, r1.x
  mad r0.w, r0.w, r1.z, r1.x
  add r0.y, r0.y, r2.z
  add r0.y, r2.x, r0.y
  add r0.y, r2.y, r0.y
  mad r0.y, r0.z, r0.y, r0.w
  min r0.y, r0.y, l(1.000000)
  movc r0.x, r1.y, l(0), r0.y
  break 
  default 
  mov r0.x, l(0)
  break 
endswitch 
mov o0.xyz, r0.xxxx
mov o0.w, l(1.000000)
ret 
// Approximately 112 instruction slots used

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