// River water surface / reflections
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.15 on Wed Mar 06 06:24:51 2019
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 vEye;                       // Offset:    0 Size:    16
//   row_major float4x4 mW2P;           // Offset:   16 Size:    64
//   float4 vNormalParam;               // Offset:   80 Size:    16
//   float3 vNormalNoiseParam;          // Offset:   96 Size:    12
//   float2 vTileSizeXZ;                // Offset:  112 Size:     8
//   float4 vCameraDirXZ;               // Offset:  128 Size:    16
//   float4 vSurfaceNormalUVScale;      // Offset:  144 Size:    16
//   float2 vSurfaceNormalUVOffset;     // Offset:  160 Size:     8
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyz         0     NONE   float   xyz
// BLENDINDICES             0   xy          1     NONE   float   xy
// TEXCOORD                 3   xyz         2     NONE   float   xyz
// TEXCOORD                 4   xyz         3     NONE   float   xyz
// TEXCOORD                 5   xyz         4     NONE   float   xyz
// TEXCOORD                 6   xyz         5     NONE   float   xyz
// TEXCOORD                 7   xyz         6     NONE   float   xyz
// COLOR                    0   xyzw        7     NONE   float   xyzw
// NORMAL                   0   xy          8     NONE   float   xy
//
//
// 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   xyz         3     NONE   float   xyz
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[11], immediateIndexed
dcl_constantbuffer cb12[4], immediateIndexed // Disable driver correction
dcl_constantbuffer cb13[4], immediateIndexed // mP2W
dcl_input v0.xyz
dcl_input v1.xy
dcl_input v2.xyz
dcl_input v3.xyz
dcl_input v4.xyz
dcl_input v5.xyz
dcl_input v6.xyz
dcl_input v7.xyzw
dcl_input v8.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyz
dcl_temps 7

dcl_resource_texture2d (float,float,float,float) t121
ld_indexable(texture2d)(float,float,float,float) r4.xyzw, l(0, 0, 0, 0), t121.xyzw

dp3 r0.x, -v2.xyzx, -v2.xyzx
rsq r0.x, r0.x
mul r0.xyz, r0.xxxx, -v2.xyzx
mul r0.xyz, r0.xyzx, v0.yyyy
mul r1.xyz, v1.xxxx, v4.xyzx
add r1.xyz, r1.xyzx, r1.xyzx
mul r0.w, v1.x, v1.x
mul r2.xyz, r0.wwww, v3.xyzx
mad r1.xyz, r2.xyzx, l(3.000000, 3.000000, 3.000000, 0.000000), r1.xyzx
add r1.xyz, r1.xyzx, v5.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r2.xyz, r1.wwww, r1.xyzx
add r3.xy, v1.xyxx, l(-0.500000, 0.500000, 0.000000, 0.000000)
mad r1.w, -r3.x, cb0[7].x, v0.x
mul r3.w, r3.y, cb0[9].w
mad r0.xyz, r1.wwww, r2.xyzx, r0.xyzx
mul r2.xyz, r1.yzxy, v2.zxyz
mad r1.xyz, v2.yzxy, r1.zxyz, -r2.xyzx
dp3 r1.w, r1.xyzx, r1.xyzx
rsq r1.w, r1.w
mul r1.xyz, r1.wwww, r1.xyzx
mad r1.w, -v1.y, cb0[7].y, v0.z
mad r0.xyz, r1.wwww, r1.xyzx, r0.xyzx
mul r1.xyz, r1.xzyx, v1.yyyy
mul r0.y, r0.y, v7.x
mul r1.w, r0.w, v1.x
mul r2.xyz, r0.wwww, v4.xzyx
mad r2.xyz, v3.xzyx, r1.wwww, r2.xyzx
mad r2.xyz, v5.xzyx, v1.xxxx, r2.xyzx
add r2.xyz, r2.xyzx, v6.xzyx
add r0.w, -v1.x, l(1.000000)
mul r1.w, v1.x, v7.z
mad r0.w, r0.w, v7.y, r1.w
mad r1.xyz, r1.xyzx, r0.wwww, r2.xyzx
mad r2.xz, r0.xxzx, v7.xxxx, r1.xxyx
add r0.xz, r2.xxzx, -cb0[0].xxzx
dp2 r0.x, r0.xzxx, cb0[8].xyxx
mad_sat r0.x, -r0.x, cb0[8].z, l(1.000000)
mad r0.y, r0.y, r0.x, cb0[8].w
mul r0.xz, r0.xxxx, v8.xxyx
add r2.y, r1.z, r0.y
mul r1.xyzw, r2.yyyy, cb0[2].xyzw
mov o1.xyz, r2.xyzx
mad r1.xyzw, r2.xxxx, cb0[1].xyzw, r1.xyzw
mad r1.xyzw, r2.zzzz, cb0[3].xyzw, r1.xyzw
add r6.xyzw, r1.xyzw, cb0[4].xyzw

// Apply the standard stereo correction:
add r4.w, r6.w, -r4.y
mad r6.x, r4.w, r4.x, r6.x
mov o0.xyzw, r6.xyzw

if_nz cb13[0].x
	// Convert the coorected coordinates back to world space to remove an outline
	// of the character (not exacly a halo, but similar):
	mul r5.xyzw, r6.xxxx, cb13[0].xyzw
	mad r5.xyzw, r6.yyyy, cb13[1].xyzw, r5.xyzw
	mad r5.xyzw, r6.zzzz, cb13[2].xyzw, r5.xyzw
	mad r5.xyzw, r6.wwww, cb13[3].xyzw, r5.xyzw
	div o1.xyz, r5.xyzw, r5.wwww
endif

mov o1.w, l(1.000000)
add r0.y, v1.x, v7.w
mul r3.z, r0.y, cb0[9].z
add r0.yw, r3.zzzw, cb0[10].xxxy
mad r1.xy, r2.xzxx, cb0[5].xyxx, cb0[10].xyxx
mul o2.xy, r2.xzxx, cb0[6].xyxx
lt r1.z, l(0.000000), cb0[9].z
movc o2.zw, r1.zzzz, r0.yyyw, r1.xxxy
dp2 r0.y, r0.xzxx, r0.xzxx
mov o3.xz, r0.xxzx
add r0.x, -r0.y, l(1.000000)
sqrt o3.y, r0.x
ret
// Approximately 60 instruction slots used
