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

cbuffer cbWaterNormalMap : register(b0)
{
  float g_normalMapWidth : packoffset(c0);
  float g_normalMapHeight : packoffset(c0.y);
  float g_normalMapAreaWidth : packoffset(c0.z);
  float g_normalMapAreaHeight : packoffset(c0.w);
}

SamplerState SS_BumpMap_s : register(s2);
Texture2D<float4> g_BumpmapTexture : register(t3);


// 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;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xy = max(float2(0.00100000005,0.00100000005), g_normalMapWidth);
  r0.yz = float2(1,1) / r0.xy;
  r0.x = g_normalMapAreaWidth / r0.x;
  r1.xy = v1.xy + r0.yz;
  r2.xy = v1.xy + -r0.yz;
  r1.zw = v1.yx;
  r0.y = g_BumpmapTexture.Sample(SS_BumpMap_s, r1.wy).x;
  r0.z = g_BumpmapTexture.Sample(SS_BumpMap_s, r1.xz).x;
  r2.zw = v1.yx;
  r0.w = g_BumpmapTexture.Sample(SS_BumpMap_s, r2.wy).x;
  r1.x = g_BumpmapTexture.Sample(SS_BumpMap_s, r2.xz).x;
  r0.z = -r1.x + r0.z;
  r0.y = r0.y + -r0.w;
  r0.w = r0.x + r0.x;
  r0.x = cmp(r0.x != 0.000000);
  r0.w = max(0.00100000005, r0.w);
  r1.z = r0.y / r0.w;
  r2.y = r0.z / r0.w;
  r1.xy = float2(1,0);
  r0.y = dot(r1.xz, r1.xz);
  r0.y = rsqrt(r0.y);
  r0.yzw = r1.xyz * r0.yyy;
  r2.x = 1;
  r1.x = dot(r2.xy, r2.xy);
  r1.x = rsqrt(r1.x);
  r2.x = r2.y * r1.x;
  r2.yz = float2(0,1) * r1.xx;
  r1.xyz = r2.xyz * r0.yzw;
  r0.yzw = r0.wyz * r2.yzx + -r1.xyz;
  r1.x = dot(r0.yzw, r0.yzw);
  r1.x = rsqrt(r1.x);
  r0.yzw = r1.xxx * r0.yzw;
  r0.xyz = r0.xxx ? r0.yzw : float3(0,1,0);
  r0.w = 1;
  r0.xyzw = float4(1,1,1,1) + r0.xyzw;
  o0.xyzw = float4(0.5,0.5,0.5,0.5) * r0.xyzw;
  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//
// Buffer Definitions: 
//
// cbuffer cbWaterNormalMap
// {
//
//   float g_normalMapWidth;            // Offset:    0 Size:     4
//   float g_normalMapHeight;           // Offset:    4 Size:     4
//   float g_normalMapAreaWidth;        // Offset:    8 Size:     4
//   float g_normalMapAreaHeight;       // Offset:   12 Size:     4 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// SS_BumpMap                        sampler      NA          NA    2        1
// g_BumpmapTexture                  texture  float4          2d    3        1
// cbWaterNormalMap                  cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float       
// TEXCOORD                 0   xy          1     NONE   float   xy  
//
//
// 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[1], immediateIndexed
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 3
max r0.xy, cb0[0].xyxx, l(0.001000, 0.001000, 0.000000, 0.000000)
div r0.yz, l(1.000000, 1.000000, 1.000000, 1.000000), r0.xxyx
div r0.x, cb0[0].z, r0.x
add r1.xy, r0.yzyy, v1.xyxx
add r2.xy, -r0.yzyy, v1.xyxx
mov r1.zw, v1.yyyx
sample_indexable(texture2d)(float,float,float,float) r0.y, r1.wyww, t3.yxzw, s2
sample_indexable(texture2d)(float,float,float,float) r0.z, r1.xzxx, t3.yzxw, s2
mov r2.zw, v1.yyyx
sample_indexable(texture2d)(float,float,float,float) r0.w, r2.wyww, t3.yzwx, s2
sample_indexable(texture2d)(float,float,float,float) r1.x, r2.xzxx, t3.xyzw, s2
add r0.z, r0.z, -r1.x
add r0.y, -r0.w, r0.y
add r0.w, r0.x, r0.x
ne r0.x, r0.x, l(0.000000)
max r0.w, r0.w, l(0.001000)
div r1.z, r0.y, r0.w
div r2.y, r0.z, r0.w
mov r1.xy, l(1.000000,0,0,0)
dp2 r0.y, r1.xzxx, r1.xzxx
rsq r0.y, r0.y
mul r0.yzw, r0.yyyy, r1.xxyz
mov r2.x, l(1.000000)
dp2 r1.x, r2.xyxx, r2.xyxx
rsq r1.x, r1.x
mul r2.x, r1.x, r2.y
mul r2.yz, r1.xxxx, l(0.000000, 0.000000, 1.000000, 0.000000)
mul r1.xyz, r0.yzwy, r2.xyzx
mad r0.yzw, r0.wwyz, r2.yyzx, -r1.xxyz
dp3 r1.x, r0.yzwy, r0.yzwy
rsq r1.x, r1.x
mul r0.yzw, r0.yyzw, r1.xxxx
movc r0.xyz, r0.xxxx, r0.yzwy, l(0,1.000000,0,0)
mov r0.w, l(1.000000)
add r0.xyzw, r0.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
mul o0.xyzw, r0.xyzw, l(0.500000, 0.500000, 0.500000, 0.500000)
ret 
// Approximately 37 instruction slots used

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