// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 8533d35f77100491-vs_replace.txt
// 3DMigoto: 8533d35f77100491 | Matched 10 variants of 5 shaders: Hidden/TerrainEngine/Splatmap/Specular-Base, Legacy Shaders/Bumped Diffuse, Legacy Shaders/Diffuse, Legacy Shaders/Transparent/Cutout/Bumped Diffuse, Legacy Shaders/Transparent/Cutout/Diffuse
//
// 003:    Unity headers extracted from AlphaTest-Bumped.shader
// 00c:    Unity headers extracted from AlphaTest-Diffuse.shader
// 030:    Unity headers extracted from Normal-Bumped.shader
// 300:    Unity headers extracted from Normal-Diffuse.shader
// 0c0:    Unity headers extracted from Specular-Base.shader
// 0c0:    Shader "Hidden/TerrainEngine/Splatmap/Specular-Base" {
// 030:    Shader "Legacy Shaders/Bumped Diffuse" {
// 300:    Shader "Legacy Shaders/Diffuse" {
// 003:    Shader "Legacy Shaders/Transparent/Cutout/Bumped Diffuse" {
// 00c:    Shader "Legacy Shaders/Transparent/Cutout/Diffuse" {
//           Properties {
// 0c0:       _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
// 0c0:       _Shininess ("Shininess", Range(0.03,1)) = 0.078125
// 0c0:       _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" { }
//            _Color ("Main Color", Color) = (1,1,1,1)
// 00f:       _MainTex ("Base (RGB) Trans (A)", 2D) = "white" { }
// 330:       _MainTex ("Base (RGB)", 2D) = "white" { }
// 033:       _BumpMap ("Normalmap", 2D) = "bump" { }
// 00f:       _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
//           }
// 030:      Fallback "Legacy Shaders/Diffuse"
// 0c0:      Fallback "Legacy Shaders/Specular"
// 003:      Fallback "Legacy Shaders/Transparent/Cutout/Diffuse"
// 00c:      Fallback "Legacy Shaders/Transparent/Cutout/VertexLit"
// 300:      Fallback "Legacy Shaders/VertexLit"
//           SubShader 1/1 {
// 3cc:        LOD 200
// 033:        LOD 300
// 00f:        Tags { "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" }
// 0c0:        Tags { "QUEUE"="Geometry-100" "RenderType"="Opaque" }
// 330:        Tags { "RenderType"="Opaque" }
//             Pass 4/5 {
//               Name "PREPASS"
// 00f:          Tags { "LIGHTMODE"="PrePassFinal" "QUEUE"="AlphaTest" "IGNOREPROJECTOR"="true" "RenderType"="TransparentCutout" }
// 0c0:          Tags { "LIGHTMODE"="PrePassFinal" "QUEUE"="Geometry-100" "RenderType"="Opaque" }
// 330:          Tags { "LIGHTMODE"="PrePassFinal" "RenderType"="Opaque" }
//               ZWrite Off
// 300:          GpuProgramID 200775
// 003:          GpuProgramID 214373
// 00c:          GpuProgramID 215972
// 0c0:          GpuProgramID 227979
// 030:          GpuProgramID 261745
//               Program "vp" {
//                 SubProgram "d3d11_9x " {
// 155:              GpuProgramIndex 56
// 2aa:              GpuProgramIndex 59
//                 }
//               }
//             }
//           }
//         }
//
// 003: Unity 5.3 headers extracted from AlphaTest-Bumped.shader.decompressed:
// 00c: Unity 5.3 headers extracted from AlphaTest-Diffuse.shader.decompressed:
// 030: Unity 5.3 headers extracted from Normal-Bumped.shader.decompressed:
// 300: Unity 5.3 headers extracted from Normal-Diffuse.shader.decompressed:
// 0c0: Unity 5.3 headers extracted from Specular-Base.shader.decompressed:
//        API d3d11_9x
//        Shader model vs_4_0_level_9_1
//        undeciphered1: 201509030 43 0 0
// 155:   Keywords { "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "HDR_LIGHT_PREPASS_OFF" }
// 2aa:   Keywords { "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "UNITY_HDR_ON" }
//        undeciphered2: 1 0 4 0 0
//        undeciphered3: 15 4 0 0 2 1 1 2 3 4
// 3f0:   ConstBuffer "$Globals" 176
// 00f:   ConstBuffer "$Globals" 192
//        Vector 144 [_MainTex_ST]
//        ConstBuffer "UnityPerCamera" 144
//        Vector 80 [_ProjectionParams]
//        ConstBuffer "UnityLighting" 720
//        Vector 608 [unity_SHAr]
//        Vector 624 [unity_SHAg]
//        Vector 640 [unity_SHAb]
//        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:30:05 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[10];
}




// 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 float3 o5 : TEXCOORD4)
{
  float4 r0,r1,r2,r3;
  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 8533d35f77100491-vs_replace.txt
if (r0.w != 1.0) { r0.x += separation * (r0.w - convergence); }

  o1.xy = v3.xy * cb0[9].xy + cb0[9].zw;
  r1.xyz = cb3[13].xyz * v0.yyy;
  r1.xyz = cb3[12].xyz * v0.xxx + r1.xyz;
  r1.xyz = cb3[14].xyz * v0.zzz + r1.xyz;
  o2.xyz = cb3[15].xyz * v0.www + r1.xyz;
  r0.y = cb1[5].x * r0.y;
  r1.xzw = float3(0.5,0.5,0.5) * r0.xwy;
  o3.zw = r0.zw;
  o3.xy = r1.xw + r1.zz;
  o4.xyzw = float4(0,0,0,0);
  r0.x = cb3[16].x * v2.x;
  r0.y = cb3[17].x * v2.x;
  r0.z = cb3[18].x * v2.x;
  r1.x = cb3[16].y * v2.y;
  r1.y = cb3[17].y * v2.y;
  r1.z = cb3[18].y * v2.y;
  r0.xyz = r1.xyz + r0.xyz;
  r1.x = cb3[16].z * v2.z;
  r1.y = cb3[17].z * v2.z;
  r1.z = cb3[18].z * v2.z;
  r0.xyz = r1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  r1.x = r0.y * r0.y;
  r1.x = r0.x * r0.x + -r1.x;
  r2.xyzw = r0.xyzz * r0.yzzx;
  r3.x = dot(cb2[41].xyzw, r2.xyzw);
  r3.y = dot(cb2[42].xyzw, r2.xyzw);
  r3.z = dot(cb2[43].xyzw, r2.xyzw);
  r1.xyz = cb2[44].xyz * r1.xxx + r3.xyz;
  r0.w = 1;
  r2.x = dot(cb2[38].xyzw, r0.xyzw);
  r2.y = dot(cb2[39].xyzw, r0.xyzw);
  r2.z = dot(cb2[40].xyzw, r0.xyzw);
  r0.xyz = r2.xyz + r1.xyz;
  r0.xyz = max(float3(0,0,0), r0.xyz);
  r0.xyz = log2(r0.xyz);
  r0.xyz = float3(0.416666657,0.416666657,0.416666657) * r0.xyz;
  r0.xyz = exp2(r0.xyz);
  r0.xyz = r0.xyz * float3(1.05499995,1.05499995,1.05499995) + float3(-0.0549999997,-0.0549999997,-0.0549999997);
  o5.xyz = max(float3(0,0,0), r0.xyz);
  return;
}
