// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors 64cd7f9730d5f600-vs_replace.txt
// 3DMigoto: 64cd7f9730d5f600 | Matched 2 variants of 2 shaders: TMPro/Distance Field (Surface), TMPro/Mobile/Distance Field (Surface)
//
// 1:    Unity headers extracted from TMPro_SDF-Surface-Mobile.shader
// 2:    Unity headers extracted from TMPro_SDF-Surface.shader
// 2:    Shader "TMPro/Distance Field (Surface)" {
// 1:    Shader "TMPro/Mobile/Distance Field (Surface)" {
//         Properties {
//          _FaceTex ("Fill Texture", 2D) = "white" { }
// 2:       _FaceUVSpeedX ("Face UV Speed X", Range(-5,5)) = 0
// 2:       _FaceUVSpeedY ("Face UV Speed Y", Range(-5,5)) = 0
//          _FaceColor ("Fill Color", Color) = (1,1,1,1)
//          _FaceDilate ("Face Dilate", Range(-1,1)) = 0
//          _OutlineColor ("Outline Color", Color) = (0,0,0,1)
//          _OutlineTex ("Outline Texture", 2D) = "white" { }
// 2:       _OutlineUVSpeedX ("Outline UV Speed X", Range(-5,5)) = 0
// 2:       _OutlineUVSpeedY ("Outline UV Speed Y", Range(-5,5)) = 0
//          _OutlineWidth ("Outline Thickness", Range(0,1)) = 0
//          _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
// 2:       _Bevel ("Bevel", Range(0,1)) = 0.5
// 2:       _BevelOffset ("Bevel Offset", Range(-0.5,0.5)) = 0
// 2:       _BevelWidth ("Bevel Width", Range(-0.5,0.5)) = 0
// 2:       _BevelClamp ("Bevel Clamp", Range(0,1)) = 0
// 2:       _BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
// 2:       _BumpMap ("Normalmap", 2D) = "bump" { }
// 2:       _BumpOutline ("Bump Outline", Range(0,1)) = 0.5
// 2:       _BumpFace ("Bump Face", Range(0,1)) = 0.5
// 2:       _ReflectFaceColor ("Face Color", Color) = (0,0,0,1)
// 2:       _ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
// 2:       _Cube ("Reflection Cubemap", CUBE) = "black" { }
// 2:       _EnvMatrixRotation ("Texture Rotation", Vector) = (0,0,0,0)
// 2:       _SpecColor ("Specular Color", Color) = (0,0,0,1)
// 2:       _FaceShininess ("Face Shininess", Range(0,1)) = 0
// 2:       _OutlineShininess ("Outline Shininess", Range(0,1)) = 0
//          _GlowColor ("Color", Color) = (0,1,0,0.5)
//          _GlowOffset ("Offset", Range(-1,1)) = 0
//          _GlowInner ("Inner", Range(0,1)) = 0.05
//          _GlowOuter ("Outer", Range(0,1)) = 0.05
//          _GlowPower ("Falloff", Range(1,0)) = 0.75
//          _WeightNormal ("Weight Normal", Float) = 0
//          _WeightBold ("Weight Bold", Float) = 0.5
//          _ShaderFlags ("Flags", Float) = 0
//          _ScaleRatioA ("Scale RatioA", Float) = 1
//          _ScaleRatioB ("Scale RatioB", Float) = 1
//          _ScaleRatioC ("Scale RatioC", Float) = 1
//          _MainTex ("Font Atlas", 2D) = "white" { }
//          _TextureWidth ("Texture Width", Float) = 512
//          _TextureHeight ("Texture Height", Float) = 512
//          _GradientScale ("Gradient Scale", Float) = 5
//          _ScaleX ("Scale X", Float) = 1
//          _ScaleY ("Scale Y", Float) = 1
//          _PerspectiveFilter ("Perspective Correction", Range(0,1)) = 0.875
//          _VertexOffsetX ("Vertex OffsetX", Float) = 0
//          _VertexOffsetY ("Vertex OffsetY", Float) = 0
//         }
//         SubShader 1/1 {
//           LOD 300
//           Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" }
// 1:        Pass 2/2 {
// 2:        Pass 3/3 {
//             Name "CASTER"
//             Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "SHADOWSUPPORT"="true" "RenderType"="Transparent" }
//             Cull Off
//             ColorMask RGB
//             Offset 1, 1
// 2:          GpuProgramID 187670
// 1:          GpuProgramID 91776
//             Program "vp" {
//               SubProgram "d3d11 " {
// 2:              GpuProgramIndex 53
// 1:              GpuProgramIndex 7
//               }
//             }
//           }
//         }
//       }
//
// 1: Unity 5.3 headers extracted from TMPro_SDF-Surface-Mobile.shader.decompressed:
// 2: Unity 5.3 headers extracted from TMPro_SDF-Surface.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 13 0 0
//      Keywords { "SHADOWS_DEPTH" }
//      undeciphered2: 1 0 3 0 0
//      undeciphered3: 9 2 0 0 3 4
//      ConstBuffer "$Globals" 128
//      Vector 96 [_MainTex_ST]
//      Float 112 [_OutlineWidth]
//      Float 116 [_FaceDilate]
//      Float 120 [_ScaleRatioA]
//      ConstBuffer "UnityShadows" 416
//      Vector 80 [unity_LightShadowBias]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 0 [glstate_matrix_mvp]
//      BindCB "$Globals" 0
//      BindCB "UnityShadows" 1
//      BindCB "UnityPerDraw" 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:28:34 2017
cbuffer cb2 : register(b2)
{
  float4 cb2[4];
}

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

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




// 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,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD1,
  out float p1 : TEXCOORD2)
{
  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 = cb2[1].xyzw * v0.yyyy;
  r0.xyzw = cb2[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb2[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb2[3].xyzw + r0.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 64cd7f9730d5f600-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;
  r0.x = -cb0[7].x * cb0[7].z + 1;
  r0.x = -cb0[7].y * cb0[7].z + r0.x;
  p1.x = 0.5 * r0.x;
  o1.xy = v2.xy * cb0[6].xy + cb0[6].zw;
  return;
}
