// hlsltool.py -I ../112 --auto-fix-vertex-halo --fix-unity-reflection --only-autofixed --no-validate --ignore-other-errors af2180a9df4128f7-vs_replace.txt
// 3DMigoto: af2180a9df4128f7 | Matched 6 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 1/3 {
//              Name "FORWARD"
//              Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="AlphaTest" "SHADOWSUPPORT"="true" "RenderType"="TransparentCutout" }
//              Cull Off
//              Blend DstColor One
//              GpuProgramID 8660
//              Program "vp" {
//                SubProgram "d3d11 " {
// 04:              GpuProgramIndex 11
// 08:              GpuProgramIndex 15
// 10:              GpuProgramIndex 19
// 20:              GpuProgramIndex 23
// 01:              GpuProgramIndex 3
// 02:              GpuProgramIndex 7
//                }
//              }
//            }
//          }
//        }
//
//     Unity 5.3 headers extracted from 2sided_animated.shader.decompressed:
//       API d3d11
//       Shader model vs_4_0
//       undeciphered1: 201509030 43 0 0
// 08:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 04:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_OFF" }
// 20:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 10:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DIRLIGHTMAP_SEPARATE" "DYNAMICLIGHTMAP_OFF" }
// 02:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" "VERTEXLIGHT_ON" }
// 01:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_OFF" "DIRLIGHTMAP_OFF" "DYNAMICLIGHTMAP_OFF" }
//       undeciphered2: 1 1 3 1 0
//       undeciphered3: 187 6 0 0 1 2 3 4 4 5 5 6 7 8
//       ConstBuffer "$Globals" 272
//       Vector 128 [_TimeEditor]
//       Vector 224 [_AnimationTexture_ST]
//       Float 240 [_Scale]
//       ConstBuffer "UnityPerCamera" 144
//       Vector 0 [_Time]
//       Vector 80 [_ProjectionParams]
//       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 "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:32:02 2017
Texture2D<float4> t0 : register(t0);

SamplerState s0_s : register(s0);

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

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

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




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


void main( 
  float4 v0 : POSITION0,
  float3 v1 : NORMAL0,
  float4 v2 : TANGENT0,
  float4 v3 : TEXCOORD0,
  float4 v4 : TEXCOORD1,
  float2 v5 : TEXCOORD2,
  out float4 o0 : SV_POSITION0,
  out float2 o1 : TEXCOORD0,
  out float2 p1 : TEXCOORD1,
  out float4 o2 : TEXCOORD2,
  out float4 o3 : TEXCOORD3,
  out float4 o4 : TEXCOORD4,
  out float4 o5 : TEXCOORD5,
  out float4 o6 : TEXCOORD6,
  out float4 o7 : TEXCOORD7,
  out float4 o8 : TEXCOORD10)
{
  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.x = cb1[0].y + cb0[8].y;
  r0.xy = r0.xx * float2(0,-0.0500000007) + v3.xy;
  r0.xy = r0.xy * cb0[14].xy + cb0[14].zw;
  r0.xyzw = t0.SampleLevel(s0_s, r0.xy, 0).xyzw;
  r0.x = cb0[15].x * r0.x;
  r0.xyz = r0.xxx * v1.xyz + v0.xyz;
  r1.xyzw = cb2[1].xyzw * r0.yyyy;
  r1.xyzw = cb2[0].xyzw * r0.xxxx + r1.xyzw;
  r1.xyzw = cb2[2].xyzw * r0.zzzz + r1.xyzw;
  r1.xyzw = cb2[3].xyzw * v0.wwww + r1.xyzw;
  o0.xyzw = r1.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 af2180a9df4128f7-vs_replace.txt
if (r1.w != 1.0) { r1.x += separation * (r1.w - convergence); }

  o1.xy = v3.xy;
  p1.xy = v4.xy;
  o2.xy = v5.xy;
  r2.xyzw = cb2[13].xyzw * r0.yyyy;
  r2.xyzw = cb2[12].xyzw * r0.xxxx + r2.xyzw;
  r0.xyzw = cb2[14].xyzw * r0.zzzz + r2.xyzw;
  o3.xyzw = cb2[15].xyzw * v0.wwww + r0.xyzw;
  r0.x = cb2[16].x * v1.x;
  r0.y = cb2[17].x * v1.x;
  r0.z = cb2[18].x * v1.x;
  r2.x = cb2[16].y * v1.y;
  r2.y = cb2[17].y * v1.y;
  r2.z = cb2[18].y * v1.y;
  r0.xyz = r2.xyz + r0.xyz;
  r2.x = cb2[16].z * v1.z;
  r2.y = cb2[17].z * v1.z;
  r2.z = cb2[18].z * v1.z;
  r0.xyz = r2.xyz + r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  r0.xyz = r0.xyz * r0.www;
  o4.xyz = r0.xyz;
  r2.xyz = cb2[13].xyz * v2.yyy;
  r2.xyz = cb2[12].xyz * v2.xxx + r2.xyz;
  r2.xyz = cb2[14].xyz * v2.zzz + r2.xyz;
  r0.w = dot(r2.xyz, r2.xyz);
  r0.w = rsqrt(r0.w);
  r2.xyz = r2.xyz * r0.www;
  o5.xyz = r2.xyz;
  r3.xyz = r2.yzx * r0.zxy;
  r0.xyz = r0.yzx * r2.zxy + -r3.xyz;
  r0.xyz = v2.www * r0.xyz;
  r0.w = dot(r0.xyz, r0.xyz);
  r0.w = rsqrt(r0.w);
  o6.xyz = r0.xyz * r0.www;
  r0.x = cb1[5].x * r1.y;
  r0.w = 0.5 * r0.x;
  r0.xz = float2(0.5,0.5) * r1.xw;
  o7.zw = r1.zw;
  o7.xy = r0.xw + r0.zz;
  o8.xyzw = float4(0,0,0,0);
  return;
}
