// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 2ea789dee6cc244a-vs_replace.txt
// 3DMigoto: 2ea789dee6cc244a | Matched 4 variants of 1 shaders: PlayWay Water/Depth/Water Depth
//
//       Unity headers extracted from Depth.shader
//       Shader "PlayWay Water/Depth/Water Depth" {
//         Properties {
//          _SubtractiveMask ("", 2D) = "black" { }
//          _AdditiveMask ("", 2D) = "black" { }
//          _DisplacedHeightMaps ("", 2D) = "black" { }
//          _WaterTileSize ("Heightmap Tile Size", Vector) = (180,18,600,1800)
//          _SurfaceOffset ("", Vector) = (0,0,0,0)
//          _WaterId ("", Vector) = (128,256,0,0)
//         }
//         SubShader 2/5 {
//           Tags { "CustomType"="Water" }
//           Pass 1/1 {
//             Tags { "CustomType"="Water" }
//             ZTest Less
//             Cull Off
//             GpuProgramID 104108
//             Program "vp" {
//               SubProgram "d3d11 " {
// 1:              GpuProgramIndex 129
// 2:              GpuProgramIndex 131
// 4:              GpuProgramIndex 133
// 8:              GpuProgramIndex 135
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from Depth.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 11 0 0
// 4:   Keywords { "_BOUNDED_WATER" }
// 8:   Keywords { "_WAVES_ALIGN" "_BOUNDED_WATER" }
// 2:   Keywords { "_WAVES_ALIGN" }
//      undeciphered2: 1 0 3 0 0
//      undeciphered3: 1 1 0 0
//      ConstBuffer "UnityPerCamera" 144
//      Vector 80 [_ProjectionParams]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 192 [_Object2World]
//      ConstBuffer "UnityPerFrame" 256
//      Matrix 144 [unity_MatrixVP]
//      BindCB "UnityPerCamera" 0
//      BindCB "UnityPerDraw" 1
//      BindCB "UnityPerFrame" 2
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity53_shaders.py

// ---- Created with 3Dmigoto v1.2.38 on Thu Feb 09 12:26:02 2017
cbuffer cb2 : register(b2)
{
  float4 cb2[13];
}

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

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




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


void main( 
  float4 v0 : POSITION0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

float4 stereo = StereoParams.Load(0);
float separation = stereo.x, convergence = stereo.y, eye = stereo.z;

  r0.xyzw = cb1[13].xyzw * v0.yyyy;
  r0.xyzw = cb1[12].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb1[14].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb1[15].xyzw * v0.wwww + r0.xyzw;
  r1.xyzw = cb2[10].xyzw * r0.yyyy;
  r1.xyzw = cb2[9].xyzw * r0.xxxx + r1.xyzw;
  r1.xyzw = cb2[11].xyzw * r0.zzzz + r1.xyzw;
  r0.xyzw = cb2[12].xyzw * r0.wwww + r1.xyzw;
  o0.xyzw = r0.xyzw;

// Automatic vertex shader halo fix inserted with DarkStarSword's hlsltool.py:
// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 2ea789dee6cc244a-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  r0.y = cb0[5].x * r0.y;
  r1.xzw = float3(0.5,0.5,0.5) * r0.xwy;
  o1.zw = r0.zw;
  o1.xy = r1.xw + r1.zz;
  return;
}
