// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors ce70f78fc9115d48-vs_replace.txt
// 3DMigoto: ce70f78fc9115d48 | Matched 3 variants of 3 shaders: PlayWay Water/Standard, PlayWay Water/Standard Volume, PlayWay Water/Variations/Water Volume _ALPHABLEND_ON _CUBEMAP_REFLECTIONS _VOLUMETRIC_LIGHTING _WATER_REFRACTION _WAVES_FFT
//
// 1:    Unity headers extracted from PlayWay Water - Volume.shader
// 2:    Unity headers extracted from PlayWay Water Volume Variation #-1229508536.shader
// 4:    Unity headers extracted from PlayWay Water.shader
// 1:    Shader "PlayWay Water/Standard Volume" {
// 4:    Shader "PlayWay Water/Standard" {
// 2:    Shader "PlayWay Water/Variations/Water Volume _ALPHABLEND_ON _CUBEMAP_REFLECTIONS _VOLUMETRIC_LIGHTING _WATER_REFRACTION _WAVES_FFT" {
//         Properties {
//          _Color ("Color", Color) = (1,1,1,1)
//          _MainTex ("Albedo", 2D) = "white" { }
//          _DepthColor ("Depth Color", Color) = (0,0.012,0.05,1)
//          _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
//          _Glossiness ("Smoothness", Range(0,1)) = 0.5
//          _SpecColor ("Specular", Color) = (0.2,0.2,0.2,1)
//          _BumpScale ("Bump Scale", Vector) = (1,1,0,0)
//          _BumpMap ("Normal Map", 2D) = "bump" { }
//          _DisplacementNormalsIntensity ("Displacement Normals Intensity", Float) = 1.4
//          _GlobalNormalMap ("", 2D) = "black" { }
//          _GlobalNormalMap1 ("", 2D) = "black" { }
//          _GlobalNormalMap2 ("", 2D) = "black" { }
//          _GlobalNormalMap3 ("", 2D) = "black" { }
//          _GlobalDisplacementMap ("", 2D) = "black" { }
//          _GlobalDisplacementMap1 ("", 2D) = "black" { }
//          _GlobalDisplacementMap2 ("", 2D) = "black" { }
//          _GlobalDisplacementMap3 ("", 2D) = "black" { }
//          _DisplacementsScale ("Horizontal Displacement Scale", Float) = 1
//          _OcclusionStrength ("Strength", Range(0,1)) = 1
//          _OcclusionMap ("Occlusion", 2D) = "white" { }
//          _EmissionColor ("Color", Color) = (0,0,0,1)
//          _EmissionMap ("Emission", 2D) = "white" { }
//          _SubtractiveMask ("", 2D) = "black" { }
//          _AdditiveMask ("", 2D) = "black" { }
//          _DetailAlbedoMap ("Detail Albedo x2", 2D) = "grey" { }
//          _DetailNormalMapScale ("Scale", Float) = 1
//          _DetailNormalMap ("Normal Map", 2D) = "bump" { }
//          _DetailFadeFactor ("", Float) = 2
//          _PlanarReflectionTex ("Planar Reflection", 2D) = "black" { }
//          _PlanarReflectionPack ("Planar reflection (distortion, intensity, offset Y, unused)", Vector) = (1,0.45,-0.3,0)
//          _LightSmoothnessMul ("Light Smoothness Multiplier", Float) = 1
//          _WrapSubsurfaceScatteringPack ("Wrap SSS", Vector) = (0.2,0.833333,0.5,0.66666)
//          _SpecularFresnelBias ("Specular Fresnel Bias", Float) = 0.02041
//          _RefractionDistortion ("Refraction Distortion", Float) = 0.55
// 4:       _RefractionMaxDepth ("Refraction Max Depth", Float) = -1
//          _WaterTileSize ("Heightmap Tile Size", Vector) = (180,18,600,1800)
// 4:       _WaterTileOffsets ("Tile Offsets", Vector) = (0,0,0,0)
//          _WaterTileSizeScales ("", Vector) = (0.63241,0.113151,3.16513,10.2651)
//          _Foam ("Foam (intensity, cutoff)", Vector) = (0.1,0.375,0,0)
//          _FoamTex ("Foam texture ", 2D) = "black" { }
//          _FoamNormalMap ("Foam Normal Map", 2D) = "bump" { }
//          _FoamNormalScale ("Foam Normal Scale", Float) = 2.2
//          _FoamTiling ("Foam Tiling", Vector) = (5.4,5.4,1,1)
//          _FoamSpecularColor ("Foam Specular Color", Color) = (1,1,1,1)
//          _EdgeBlendFactorInv ("Edge Blend Factor", Float) = 0.3333
//          _FoamMapWS ("", 2D) = "black" { }
//          _AbsorptionColor ("", Color) = (0.35,0.04,0.001,1)
//          _ReflectionColor ("", Color) = (1,1,1,1)
//          _LocalDisplacementMap ("", 2D) = "black" { }
//          _LocalSlopeMap ("", 2D) = "black" { }
//          _DisplacedHeightMaps ("", 2D) = "black" { }
//          _SubsurfaceScatteringPack ("Subsurface Scattering", Vector) = (1,0.15,1.65,0)
//          _SlopeVariance ("", 3D) = "black" { }
//          _TesselationFactor ("Tesselation Factor", Float) = 14
//          _MaxDisplacement ("", Float) = 10
// 3:       _SurfaceOffset ("", Vector) = (0,0,0,0)
// 4:       _SurfaceOffset ("", Vector) = (0,0,0,1)
//          _WaterId ("", Vector) = (128,256,0,0)
//          _WaterStencilId ("", Float) = 0
//          _WaterStencilIdInv ("", Float) = 0
// 4:       _GerstnerOrigin ("", Vector) = (0,0,0,0)
// 4:       _GrAmp0 ("", Vector) = (0,0,0,0)
// 4:       _GrOff0 ("", Vector) = (0,0,0,0)
// 4:       _GrFrq0 ("", Vector) = (0,0,0,0)
// 4:       _GrAB0 ("", Vector) = (0,0,0,0)
// 4:       _GrCD0 ("", Vector) = (0,0,0,0)
// 4:       _GrAmp1 ("", Vector) = (0,0,0,0)
// 4:       _GrOff1 ("", Vector) = (0,0,0,0)
// 4:       _GrFrq1 ("", Vector) = (0,0,0,0)
// 4:       _GrAB1 ("", Vector) = (0,0,0,0)
// 4:       _GrCD1 ("", Vector) = (0,0,0,0)
// 4:       _GrAmp2 ("", Vector) = (0,0,0,0)
// 4:       _GrOff2 ("", Vector) = (0,0,0,0)
// 4:       _GrFrq2 ("", Vector) = (0,0,0,0)
// 4:       _GrAB2 ("", Vector) = (0,0,0,0)
// 4:       _GrCD2 ("", Vector) = (0,0,0,0)
// 4:       _GrAmp3 ("", Vector) = (0,0,0,0)
// 4:       _GrOff3 ("", Vector) = (0,0,0,0)
// 4:       _GrFrq3 ("", Vector) = (0,0,0,0)
// 4:       _GrAB3 ("", Vector) = (0,0,0,0)
// 4:       _GrCD3 ("", Vector) = (0,0,0,0)
// 4:       _GrAmp4 ("", Vector) = (0,0,0,0)
// 4:       _GrOff4 ("", Vector) = (0,0,0,0)
// 4:       _GrFrq4 ("", Vector) = (0,0,0,0)
// 4:       _GrAB4 ("", Vector) = (0,0,0,0)
// 4:       _GrCD4 ("", Vector) = (0,0,0,0)
//         [HideInInspector]  _Cull ("_Cull", Float) = 2
//         [HideInInspector]  _Mode ("__mode", Float) = 0
//         [HideInInspector]  _SrcBlend ("__src", Float) = 1
//         [HideInInspector]  _DstBlend ("__dst", Float) = 0
//         }
// 3:      SubShader 1/1 {
// 4:      SubShader 2/3 {
//           LOD 300
// 3:        Tags { "QUEUE"="Transparent" "RenderType"="Opaque" "PerformanceChecks"="False" "CustomType"="WaterVolume" }
// 4:        Tags { "QUEUE"="Transparent-1" "RenderType"="Opaque" "PerformanceChecks"="False" "CustomType"="Water" }
//           GrabPass {
// 4:          "_RefractionTex"
// 3:          "_RefractionTex2"
//            }
//           Pass 3/4 {
//             Name "SHADOWCASTER"
// 3:          Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="Transparent" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" "CustomType"="WaterVolume" }
// 4:          Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="Transparent-1" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" "CustomType"="Water" }
// 4:          Cull Off
// 3:          Cull [_Cull]
// 1:          GpuProgramID 144331
// 2:          GpuProgramID 154006
// 4:          GpuProgramID 455776
//             Program "vp" {
//               SubProgram "d3d11 " {
// 4:              GpuProgramIndex 115
// 3:              GpuProgramIndex 27
//               }
//             }
//           }
//         }
//       }
//
// 1: Unity 5.3 headers extracted from PlayWay Water - Volume.shader.decompressed:
// 2: Unity 5.3 headers extracted from PlayWay Water Volume Variation #-1229508536.shader.decompressed:
// 4: Unity 5.3 headers extracted from PlayWay Water.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 30 0 0
// 2:   Keywords { "SHADOWS_DEPTH" "_WAVES_FFT" }
// 5:   Keywords { "SHADOWS_DEPTH" }
//      undeciphered2: 1 0 4 0 0
//      undeciphered3: 1 1 0 0
//      ConstBuffer "UnityLighting" 720
//      Vector 0 [_WorldSpaceLightPos0]
//      ConstBuffer "UnityShadows" 416
//      Vector 80 [unity_LightShadowBias]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 192 [_Object2World]
//      Matrix 256 [_World2Object]
//      ConstBuffer "UnityPerFrame" 256
//      Matrix 144 [unity_MatrixVP]
//      BindCB "UnityLighting" 0
//      BindCB "UnityShadows" 1
//      BindCB "UnityPerDraw" 2
//      BindCB "UnityPerFrame" 3
//
// 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:33:30 2017
cbuffer cb3 : register(b3)
{
  float4 cb3[13];
}

cbuffer cb2 : register(b2)
{
  float4 cb2[19];
}

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

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




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


void main( 
  float4 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float4 v2 : TEXCOORD0,
  float2 v3 : TEXCOORD1,
  out float4 o0 : SV_POSITION0)
{
  float4 r0,r1,r2;
  uint4 bitmask, uiDest;
  float4 fDest;

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

  r0.x = cb2[16].y;
  r0.y = cb2[17].y;
  r0.z = cb2[18].y;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r1.xyz = cb2[13].xyz * v0.yyy;
  r1.xyz = cb2[12].xyz * v0.xxx + r1.xyz;
  r1.xyz = cb2[14].xyz * v0.zzz + r1.xyz;
  r1.xyz = cb2[15].xyz * v0.www + r1.xyz;
  r2.xyz = -r1.xyz * cb0[0].www + cb0[0].xyz;
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = r2.xyz * r0.www;
  r0.w = dot(r0.xyz, r2.xyz);
  r0.w = -r0.w * r0.w + 1;
  r0.w = sqrt(r0.w);
  r0.w = cb1[5].z * r0.w;
  r0.xyz = -r0.xyz * r0.www + r1.xyz;
  r2.xyzw = cb3[10].xyzw * r0.yyyy;
  r2.xyzw = cb3[9].xyzw * r0.xxxx + r2.xyzw;
  r0.xyzw = cb3[11].xyzw * r0.zzzz + r2.xyzw;
  r0.xyzw = cb3[12].xyzw + r0.xyzw;
  r2.xyzw = cb3[10].xyzw * r1.yyyy;
  r2.xyzw = cb3[9].xyzw * r1.xxxx + r2.xyzw;
  r1.xyzw = cb3[11].xyzw * r1.zzzz + r2.xyzw;
  r1.xyzw = cb3[12].xyzw + r1.xyzw;
  r2.x = cmp(cb1[5].z != 0.000000);
  r0.xyzw = r2.xxxx ? r0.xyzw : r1.xyzw;

o0.xyw = r0.xyw; // Relocated to here with hlsltool.py

// 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 ce70f78fc9115d48-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  r1.x = saturate(cb1[5].x / r0.w);
  r0.z = r1.x + r0.z;

  // o0.xyw = r0.xyw; // Relocated from here with hlsltool.py

  r0.x = max(0, r0.z);
  r0.x = r0.x + -r0.z;
  o0.z = cb1[5].y * r0.x + r0.z;
  return;
}
