// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed fe6565af67fa0fb6-vs.txt
// 3DMigoto: fe6565af67fa0fb6 |    Unity headers extracted from Normal-VertexLit.shader
//    Shader "Legacy Shaders/VertexLit" {
//      Properties {
//       _Color ("Main Color", Color) = (1.000000,1.000000,1.000000,1.000000)
//       _SpecColor ("Spec Color", Color) = (1.000000,1.000000,1.000000,1.000000)
//       _Emission ("Emissive Color", Color) = (0.000000,0.000000,0.000000,0.000000)
//       _Shininess ("Shininess", Range(0.010000,1.000000)) = 0.700000
//       _MainTex ("Base (RGB)", 2D) = "white" { }
//      }
//      SubShader 1/1 {
//        LOD 100
//        Tags { "RenderType"="Opaque" }
//        Pass 4/4 {
//          Name "SHADOWCASTER"
//          Tags { "LIGHTMODE"="SHADOWCASTER" "SHADOWSUPPORT"="true" "RenderType"="Opaque" }
//          GpuProgramID 15965
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 10
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Normal-VertexLit.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201510240 43 0 0
//   Keywords { "SHADOWS_DEPTH" }
//   undeciphered2: 1 0 4 0 0 0
//   undeciphered3: 3 2 0 0 1 2
//   ConstBuffer "UnityLighting" 720
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityShadows" 416
//   Vector 80 [unity_LightShadowBias]
//   ConstBuffer "UnityPerDraw" 352
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [unity_ObjectToWorld]
//   Matrix 256 [unity_WorldToObject]
//   ConstBuffer "UnityPerFrame" 272
//   Matrix 128 [unity_MatrixVP]
//   BindCB "UnityLighting" 0
//   BindCB "UnityShadows" 1
//   BindCB "UnityPerDraw" 2
//   BindCB "UnityPerFrame" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.12 on Thu Dec 06 16:59:13 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// NORMAL                   0   xyz         1     NONE   float   xyz
// TEXCOORD                 0   xyzw        2     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb2[19], immediateIndexed
dcl_constantbuffer cb3[12], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_output_siv o0.xyzw, position
dcl_temps 4

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125

ld_indexable(texture2d)(float,float,float,float) r3.xyzw, l(0, 0, 0, 0), t125.xyzw

mul r0.x, v1.x, cb2[16].x
mul r0.y, v1.x, cb2[17].x
mul r0.z, v1.x, cb2[18].x
mul r1.x, v1.y, cb2[16].y
mul r1.y, v1.y, cb2[17].y
mul r1.z, v1.y, cb2[18].y
add r0.xyz, r0.xyzx, r1.xyzx
mul r1.x, v1.z, cb2[16].z
mul r1.y, v1.z, cb2[17].z
mul r1.z, v1.z, cb2[18].z
add r0.xyz, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.xyz, v0.yyyy, cb2[13].xyzx
mad r1.xyz, cb2[12].xyzx, v0.xxxx, r1.xyzx
mad r1.xyz, cb2[14].xyzx, v0.zzzz, r1.xyzx
add r1.xyz, r1.xyzx, cb2[15].xyzx
mad r2.xyz, -r1.xyzx, cb0[0].wwww, cb0[0].xyzx
dp3 r0.w, r2.xyzx, r2.xyzx
rsq r0.w, r0.w
mul r2.xyz, r0.wwww, r2.xyzx
dp3 r0.w, r0.xyzx, r2.xyzx
mad r0.w, -r0.w, r0.w, l(1.000000)
sqrt r0.w, r0.w
mul r0.w, r0.w, cb1[5].z
mad r0.xyz, -r0.xyzx, r0.wwww, r1.xyzx
mul r1.xyzw, r0.yyyy, cb3[9].xyzw
mad r1.xyzw, cb3[8].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb3[10].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb3[11].xyzw
mul r1.xyzw, v0.yyyy, cb2[1].xyzw
mad r1.xyzw, cb2[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb2[2].xyzw, v0.zzzz, r1.xyzw
add r1.xyzw, r1.xyzw, cb2[3].xyzw
ne r2.x, cb1[5].z, l(0.000000)
movc r0.xyzw, r2.xxxx, r0.xyzw, r1.xyzw

// Relocated to here with asmtool.py
mov o0.xyw, r0.xyxw

// Automatic vertex shader halo fix inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed fe6565af67fa0fb6-vs.txt
ne r3.w, r0.w, l(1.0)
if_nz r3.w
  add r3.w, r0.w, -r3.y
  mad r0.x, r3.w, r3.x, r0.x
endif

div r1.x, cb1[5].x, r0.w
max r1.x, r1.x, l(-1.000000)
min r1.x, r1.x, l(0.000000)
add r0.z, r0.z, r1.x
min r1.x, r0.w, r0.z

// mov o0.xyw, r0.xyxw // Relocated from here with asmtool.py

add r0.x, -r0.z, r1.x
mad o0.z, cb1[5].y, r0.x, r0.z
ret
// Approximately 0 instruction slots used