// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed ec61a46c8c2f6a8e-vs.txt
// 3DMigoto: ec61a46c8c2f6a8e |    Unity headers extracted from FX-Water.shader
//    Shader "FX/Water" {
//      Properties {
//       _WaveScale ("Wave scale", Range(0.02,0.15)) = 0.063
//       _ReflDistort ("Reflection distort", Range(0,1.5)) = 0.44
//       _RefrDistort ("Refraction distort", Range(0,1.5)) = 0.4
//       _RefrColor ("Refraction color", Color) = (0.34,0.85,0.92,1)
//       _Fresnel ("Fresnel (A) ", 2D) = "gray" { }
//       _BumpMap ("Normalmap ", 2D) = "bump" { }
//       WaveSpeed ("Wave speed (map1 x,y; map2 x,y)", Vector) = (19,9,-16,-7)
//       _ReflectiveColor ("Reflective color (RGB) fresnel (A) ", 2D) = "black" { }
//       _ReflectiveColorCube ("Reflective color cube (RGB) fresnel (A)", CUBE) = "" { }
//       _HorizonColor ("Simple water horizon color", Color) = (0.172,0.463,0.435,1)
//       _MainTex ("Fallback texture", 2D) = "" { }
//       _ReflectionTex ("Internal Reflection", 2D) = "" { }
//       _RefractionTex ("Internal Refraction", 2D) = "" { }
//      }
//      SubShader 1/1 {
//        Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "WaterMode"="Refractive" }
//        Pass 1/1 {
//          Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "WaterMode"="Refractive" }
//          Blend SrcAlpha OneMinusSrcAlpha
//          ColorMask RGB
//          GpuProgramID 47338
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 1
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from FX-Water.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201509030 33 0 0
//   undeciphered2: 1 0 4 0 0
//   undeciphered3: 1 1 0 0
//   ConstBuffer "$Globals" 176
//   Float 96 [_FogGradientRange]
//   Vector 112 [_WaveScale4]
//   Vector 128 [_WaveOffset]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 64 [_WorldSpaceCameraPos] 3
//   Vector 80 [_ProjectionParams]
//   ConstBuffer "UnityPerDraw" 352
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [_Object2World]
//   Matrix 256 [_World2Object]
//   ConstBuffer "UnityPerFrame" 256
//   Vector 64 [glstate_lightmodel_ambient]
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityPerDraw" 2
//   BindCB "UnityPerFrame" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.2 on Mon Jul 23 23:48:15 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// NORMAL                   0   xyz         1     NONE   float
//
//
// 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   xy          2     NONE   float   xy
// TEXCOORD                 2     zw        2     NONE   float     zw
// TEXCOORD                 3   xyz         3     NONE   float   xyz
// TEXCOORD                 4      w        3     NONE   float      w
// TEXCOORD                 5   x           4     NONE   float   x
//
vs_4_0
dcl_constantbuffer cb0[9], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[22], immediateIndexed
dcl_constantbuffer cb3[5], immediateIndexed
dcl_input v0.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xy
dcl_output o2.zw
dcl_output o3.xyz
dcl_output o3.w
dcl_output o4.x
dcl_temps 5

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125
dcl_constantbuffer cb10[4], immediateIndexed

ld_indexable(texture2d)(float,float,float,float) r3.xyzw, l(0, 0, 0, 0), t125.xyzw


// Unity reflection/specular fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed ec61a46c8c2f6a8e-vs.txt

mul r3.w, -r3.x, r3.y
mad r4.xyz, -r3.wwww, cb10[0].xyzw, cb1[4].xyzw

mul r0.x, v0.y, cb2[13].z
mad r0.x, cb2[12].z, v0.x, r0.x
mad r0.x, cb2[14].z, v0.z, r0.x
mad r0.x, cb2[15].z, v0.w, r0.x
add r0.y, r0.x, l(200.000000)
mul r1.xyzw, v0.yyyy, cb2[1].xyzw
mad r1.xyzw, cb2[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb2[2].xyzw, v0.zzzz, r1.xyzw
mad r1.xyzw, cb2[3].xyzw, v0.wwww, r1.xyzw

// Relocated to here with asmtool.py
mov o0.xyw, r1.xyxw

// Automatic vertex shader halo fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed ec61a46c8c2f6a8e-vs.txt
ne r3.w, r1.w, l(1.0)
if_nz r3.w
  add r3.w, r1.w, -r3.y
  mad r1.x, r3.w, r3.x, r1.x
endif

mul r0.y, r0.y, r1.w
mul o0.z, r0.y, l(0.000833333354)

// mov o0.xyw, r1.xyxw // Relocated from here with asmtool.py

mul r0.y, r1.y, cb1[5].x
mul r2.w, r0.y, l(0.500000)
mul r2.xz, r1.xxwx, l(0.500000, 0.000000, 0.500000, 0.000000)
add o1.xy, r2.zzzz, r2.xwxx
mov o1.zw, r1.zzzw
dp4 r0.y, r1.xyzw, r1.xyzw
sqrt r0.y, r0.y
mad o2.xyzw, v0.xzzx, cb0[7].xywz, cb0[8].xywz
mul r0.zw, cb3[4].wwww, l(0.000000, 0.000000, 0.200000, 4.060000)
round_ni r0.w, r0.w
add r0.w, -r0.w, l(1.000000)
mul r0.z, r0.w, r0.z
mul r0.y, r0.z, r0.y
exp r0.y, -|r0.y|
mad o3.w, -r0.y, r0.y, l(1.000000)
mul r0.yzw, r4.yyyy, cb2[17].xxzy
mad r0.yzw, cb2[16].xxzy, r4.xxxx, r0.yyzw
mad r0.yzw, cb2[18].xxzy, r4.zzzz, r0.yyzw
add r0.yzw, r0.yyzw, cb2[19].xxzy
add o3.xyz, r0.yzwy, -v0.xzyx
add r0.y, cb0[6].x, cb0[6].x
div r0.x, r0.x, r0.y
add o4.x, r0.x, l(0.500000)
ret
// Approximately 0 instruction slots used