// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors efbd57a0318cfe50-vs_replace.txt
// 3DMigoto: efbd57a0318cfe50 | Matched 3 variants of 1 shaders: Shader Forge/2sided_animated
//
//       Unity headers extracted from 2sided_animated.shader
//       Shader "Shader Forge/2sided_animated" {
//         Properties {
//          _BaseColor ("Base Color", 2D) = "white" { }
//          _Color ("Color", Color) = (1,1,1,1)
//          _BumpMap ("Normal Map", 2D) = "bump" { }
//          _Metallic ("Metallic", Range(0,1)) = 0
//          _Gloss ("Gloss", Range(0,1)) = 0
//          _ColorScale ("Color Scale", Float) = 10
//          _AnimationTexture ("Animation Texture", 2D) = "white" { }
//          _Scale ("Scale", Float) = 1
//          _EmissiveColor ("Emissive Color", Color) = (0,0,0,1)
//         [HideInInspector]  _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
//         }
//         Fallback "Diffuse"
//         SubShader 1/1 {
//           Tags { "QUEUE"="AlphaTest" "RenderType"="TransparentCutout" }
//           Pass 3/3 {
//             Name "SHADOWCASTER"
//             Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="AlphaTest" "SHADOWSUPPORT"="true" "RenderType"="TransparentCutout" }
//             Offset 1, 1
//             GpuProgramID 182693
//             Program "vp" {
//               SubProgram "d3d11 " {
// 1:              GpuProgramIndex 193
// 2:              GpuProgramIndex 197
// 4:              GpuProgramIndex 201
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from 2sided_animated.shader.decompressed:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201509030 32 0 0
// 2:   Keywords { "SHADOWS_DEPTH" "LIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" }
// 1:   Keywords { "SHADOWS_DEPTH" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
// 4:   Keywords { "SHADOWS_DEPTH" "LIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" }
//      undeciphered2: 1 1 4 1 0
//      undeciphered3: 59 5 0 0 1 2 3 4 4 5 5 6
//      ConstBuffer "$Globals" 192
//      Vector 128 [_TimeEditor]
//      Vector 160 [_AnimationTexture_ST]
//      Float 176 [_Scale]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 0 [_Time]
//      ConstBuffer "UnityShadows" 416
//      Vector 80 [unity_LightShadowBias]
//      ConstBuffer "UnityPerDraw" 352
//      Matrix 0 [glstate_matrix_mvp]
//      Matrix 192 [_Object2World]
//      Matrix 256 [_World2Object]
//      SetTexture 0 [_AnimationTexture] 2D 0
//      BindCB "$Globals" 0
//      BindCB "UnityPerCamera" 1
//      BindCB "UnityShadows" 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:35:01 2017
Texture2D<float4> t0 : register(t0);

SamplerState s0_s : register(s0);

cbuffer cb3 : register(b3)
{
  float4 cb3[19];
}

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

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

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




// 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,
  float4 v3 : TEXCOORD1,
  float2 v4 : TEXCOORD2,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD1,
  out float2 p1 : TEXCOORD2,
  out float4 o2 : TEXCOORD3,
  out float4 o3 : TEXCOORD4,
  out float3 o4 : TEXCOORD5)
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

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

  r0.x = cb1[0].y + cb0[8].y;
  r0.xy = r0.xx * float2(0,-0.0500000007) + v2.xy;
  r0.xy = r0.xy * cb0[10].xy + cb0[10].zw;
  r0.xyzw = t0.SampleLevel(s0_s, r0.xy, 0).xyzw;
  r0.x = cb0[11].x * r0.x;
  r0.xyz = r0.xxx * v1.xyz + v0.xyz;
  r1.xyzw = cb3[1].xyzw * r0.yyyy;
  r1.xyzw = cb3[0].xyzw * r0.xxxx + r1.xyzw;
  r1.xyzw = cb3[2].xyzw * r0.zzzz + r1.xyzw;
  r1.xyzw = cb3[3].xyzw + r1.xyzw;

o0.xyw = r1.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 efbd57a0318cfe50-vs_replace.txt
if (r1.w != 1.0) { r1.x += separation * (r1.w - convergence); }

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

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

  r1.x = max(0, r0.w);
  r1.x = r1.x + -r0.w;
  o0.z = cb2[5].y * r1.x + r0.w;
  o1.xy = v2.xy;
  p1.xy = v3.xy;
  o2.xy = v4.xy;
  r1.xyzw = cb3[13].xyzw * r0.yyyy;
  r1.xyzw = cb3[12].xyzw * r0.xxxx + r1.xyzw;
  r0.xyzw = cb3[14].xyzw * r0.zzzz + r1.xyzw;
  o3.xyzw = cb3[15].xyzw * v0.wwww + r0.xyzw;
  r0.x = cb3[16].x * v1.x;
  r0.y = cb3[17].x * v1.x;
  r0.z = cb3[18].x * v1.x;
  r1.x = cb3[16].y * v1.y;
  r1.y = cb3[17].y * v1.y;
  r1.z = cb3[18].y * v1.y;
  r0.xyz = r1.xyz + r0.xyz;
  r1.x = cb3[16].z * v1.z;
  r1.y = cb3[17].z * v1.z;
  r1.z = cb3[18].z * v1.z;
  r0.xyz = r1.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  o4.xyz = r0.xyz * r0.www;
  return;
}
