// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 71ef3d5a69c520a3-vs_replace.txt
// 3DMigoto: 71ef3d5a69c520a3 | Matched 2 variants of 2 shaders: Hidden/TerrainEngine/Splatmap/Diffuse-AddPass, Nature/Terrain/Diffuse
//
// 1:    Unity headers extracted from AddPass.shader
// 2:    Unity headers extracted from FirstPass.shader
// 1:    Shader "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass" {
// 2:    Shader "Nature/Terrain/Diffuse" {
//         Properties {
// 1:      [HideInInspector]  _Control ("Control (RGBA)", 2D) = "black" { }
// 2:      [HideInInspector]  _Control ("Control (RGBA)", 2D) = "red" { }
//         [HideInInspector]  _Splat3 ("Layer 3 (A)", 2D) = "white" { }
//         [HideInInspector]  _Splat2 ("Layer 2 (B)", 2D) = "white" { }
//         [HideInInspector]  _Splat1 ("Layer 1 (G)", 2D) = "white" { }
//         [HideInInspector]  _Splat0 ("Layer 0 (R)", 2D) = "white" { }
//         [HideInInspector]  _Normal3 ("Normal 3 (A)", 2D) = "bump" { }
//         [HideInInspector]  _Normal2 ("Normal 2 (B)", 2D) = "bump" { }
//         [HideInInspector]  _Normal1 ("Normal 1 (G)", 2D) = "bump" { }
//         [HideInInspector]  _Normal0 ("Normal 0 (R)", 2D) = "bump" { }
// 2:      [HideInInspector]  _MainTex ("BaseMap (RGB)", 2D) = "white" { }
// 2:      [HideInInspector]  _Color ("Main Color", Color) = (1,1,1,1)
//         }
// 2:      Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Diffuse-AddPass"
// 1:      Fallback Off
// 2:      Dependency "BaseMapShader" = "Diffuse"
// 2:      Dependency "Details0" = "Hidden/TerrainEngine/Details/Vertexlit"
// 2:      Dependency "Details1" = "Hidden/TerrainEngine/Details/WavingDoublePass"
// 2:      Dependency "Details2" = "Hidden/TerrainEngine/Details/BillboardWavingDoublePass"
// 2:      Dependency "Tree0" = "Hidden/TerrainEngine/BillboardTree"
// 2:      Fallback "Diffuse"
//         SubShader 1/2 {
// 1:        Tags { "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "RenderType"="Opaque" }
// 2:        Tags { "QUEUE"="Geometry-99" "RenderType"="Opaque" }
//           Pass 1/5 {
//             Name "FORWARD"
// 1:          Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Geometry-99" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
// 2:          Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Geometry-99" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
// 2:          GpuProgramID 41366
// 1:          ZWrite Off
// 1:          Blend One One
// 1:          GpuProgramID 58605
//             Program "vp" {
//               SubProgram "d3d11 " {
//                 GpuProgramIndex 3
//               }
//             }
//           }
//         }
//       }
//
// 1: Unity 5.3 headers extracted from AddPass.shader.decompressed:
// 2: Unity 5.3 headers extracted from FirstPass.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 37 0 0
//      Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
//      undeciphered2: 1 0 4 0 0
//      undeciphered3: 15 4 0 0 2 1 1 2 3 4
//      ConstBuffer "$Globals" 208
//      Vector 128 [_Control_ST]
//      Vector 144 [_Splat0_ST]
//      Vector 160 [_Splat1_ST]
//      Vector 176 [_Splat2_ST]
//      Vector 192 [_Splat3_ST]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 80 [_ProjectionParams]
//      ConstBuffer "UnityLighting" 720
//      Vector 656 [unity_SHBr]
//      Vector 672 [unity_SHBg]
//      Vector 688 [unity_SHBb]
//      Vector 704 [unity_SHC]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 0 [glstate_matrix_mvp]
//      Matrix 192 [_Object2World]
//      Matrix 256 [_World2Object]
//      BindCB "$Globals" 0
//      BindCB "UnityPerCamera" 1
//      BindCB "UnityLighting" 2
//      BindCB "UnityPerDraw" 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:29:12 2017
cbuffer cb3 : register(b3)
{
  float4 cb3[19];
}

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

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

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




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


void main( 
  float4 v0 : POSITION0,
  float4 v1 : TANGENT0,
  float3 v2 : NORMAL0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float4 v5 : TEXCOORD2,
  float4 v6 : TEXCOORD3,
  float4 v7 : COLOR0,
  out float4 o0 : SV_POSITION0,
  out float4 o1 : TEXCOORD0,
  out float4 o2 : TEXCOORD1,
  out float4 o3 : TEXCOORD2,
  out float4 o4 : TEXCOORD3,
  out float4 o5 : TEXCOORD4,
  out float4 o6 : TEXCOORD5,
  out float4 o7 : TEXCOORD6,
  out float4 o8 : TEXCOORD7)
{
  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.xyzw = cb3[1].xyzw * v0.yyyy;
  r0.xyzw = cb3[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb3[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb3[3].xyzw * v0.wwww + r0.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 71ef3d5a69c520a3-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  o1.xy = v3.xy * cb0[9].xy + cb0[9].zw;
  o1.zw = v3.xy * cb0[10].xy + cb0[10].zw;
  o2.xy = v3.xy * cb0[11].xy + cb0[11].zw;
  o2.zw = v3.xy * cb0[12].xy + cb0[12].zw;
  r1.x = cb3[16].x * v2.x;
  r1.y = cb3[17].x * v2.x;
  r1.z = cb3[18].x * v2.x;
  r2.x = cb3[16].y * v2.y;
  r2.y = cb3[17].y * v2.y;
  r2.z = cb3[18].y * v2.y;
  r1.xyz = r2.xyz + r1.xyz;
  r2.x = cb3[16].z * v2.z;
  r2.y = cb3[17].z * v2.z;
  r2.z = cb3[18].z * v2.z;
  r1.xyz = r2.xyz + r1.xyz;
  r1.w = dot(r1.xyz, r1.xyz);
  r1.w = rsqrt(r1.w);
  r1.xyz = r1.xyz * r1.www;
  o3.xyz = r1.xyz;
  r2.xyz = cb3[13].xyz * v0.yyy;
  r2.xyz = cb3[12].xyz * v0.xxx + r2.xyz;
  r2.xyz = cb3[14].xyz * v0.zzz + r2.xyz;
  o4.xyz = cb3[15].xyz * v0.www + r2.xyz;
  o5.xy = v3.xy * cb0[8].xy + cb0[8].zw;
  r1.w = r1.y * r1.y;
  r1.w = r1.x * r1.x + -r1.w;
  r2.xyzw = r1.xyzz * r1.yzzx;
  r1.x = dot(cb2[41].xyzw, r2.xyzw);
  r1.y = dot(cb2[42].xyzw, r2.xyzw);
  r1.z = dot(cb2[43].xyzw, r2.xyzw);
  o6.xyz = cb2[44].xyz * r1.www + r1.xyz;
  r0.y = cb1[5].x * r0.y;
  r1.xzw = float3(0.5,0.5,0.5) * r0.xwy;
  o7.zw = r0.zw;
  o7.xy = r1.xw + r1.zz;
  o8.xyzw = float4(0,0,0,0);
  return;
}
