// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors bd3cd922e1a12d15-vs_replace.txt
// 3DMigoto: bd3cd922e1a12d15 | 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 4/5 {
//           Tags { "CustomType"="WaterVolume" }
//           Pass 1/1 {
//             Tags { "CustomType"="WaterVolume" }
//             ZTest Less
//             Cull Off
//             GpuProgramID 259254
//             Program "vp" {
//               SubProgram "d3d11 " {
// 1:              GpuProgramIndex 211
// 2:              GpuProgramIndex 213
// 4:              GpuProgramIndex 215
// 8:              GpuProgramIndex 217
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from Depth.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 12 0 0
// 8:   Keywords { "_WAVES_FFT" "_WAVES_GERSTNER" }
// 4:   Keywords { "_WAVES_FFT" }
// 2:   Keywords { "_WAVES_GERSTNER" }
//      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:32:42 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,
  out float3 o2 : TEXCOORD1)
{
  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;
  r1.xyzw = cb2[12].xyzw * r0.wwww + r1.xyzw;
  o2.xyz = r0.xyz;
  o0.xyzw = r1.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 bd3cd922e1a12d15-vs_replace.txt
if (r1.w != 1.0) { r1.x += separation * (r1.w - convergence); }

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