// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed 948c2c34a0c309db-vs.txt
// 3DMigoto: 948c2c34a0c309db |    Unity headers extracted from 0x002ad9f8.shader
//    Shader "Standard" {
//      Properties {
//       _Color ("Color", Color) = (1,1,1,1)
//       _MainTex ("Albedo", 2D) = "white" { }
//       _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
//       _Glossiness ("Smoothness", Range(0,1)) = 0.5
//      [Gamma]  _Metallic ("Metallic", Range(0,1)) = 0
//       _MetallicGlossMap ("Metallic", 2D) = "white" { }
//       _BumpScale ("Scale", Float) = 1
//       _BumpMap ("Normal Map", 2D) = "bump" { }
//       _Parallax ("Height Scale", Range(0.005,0.08)) = 0.02
//       _ParallaxMap ("Height Map", 2D) = "black" { }
//       _OcclusionStrength ("Strength", Range(0,1)) = 1
//       _OcclusionMap ("Occlusion", 2D) = "white" { }
//       _EmissionColor ("Color", Color) = (0,0,0,1)
//       _EmissionMap ("Emission", 2D) = "white" { }
//       _DetailMask ("Detail Mask", 2D) = "white" { }
//       _DetailAlbedoMap ("Detail Albedo x2", 2D) = "grey" { }
//       _DetailNormalMapScale ("Scale", Float) = 1
//       _DetailNormalMap ("Normal Map", 2D) = "bump" { }
//      [Enum(UV0,0,UV1,1)]  _UVSec ("UV Set for secondary textures", Float) = 0
//      [HideInInspector]  _Mode ("__mode", Float) = 0
//      [HideInInspector]  _SrcBlend ("__src", Float) = 1
//      [HideInInspector]  _DstBlend ("__dst", Float) = 0
//      [HideInInspector]  _ZWrite ("__zw", Float) = 1
//      }
//      Fallback "VertexLit"
//      SubShader 1/2 {
//        LOD 300
//        Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
//        Pass 3/4 {
//          Name "SHADOWCASTER"
//          Tags { "LIGHTMODE"="SHADOWCASTER" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" }
//          GpuProgramID 147192
//          Program "vp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 65
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from 0x002ad9f8.shader.decompressed:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201509030 41 0 0
//   Keywords { "SHADOWS_DEPTH" }
//   undeciphered2: 1 0 4 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 [_Object2World]
//   Matrix 256 [_World2Object]
//   ConstBuffer "UnityPerFrame" 256
//   Matrix 144 [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.2 on Mon Jul 23 23:45:51 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   xy          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[13], 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[10].xyzw
mad r1.xyzw, cb3[9].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb3[11].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb3[12].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 948c2c34a0c309db-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_sat r1.x, cb1[5].x, r0.w
add r0.z, r0.z, r1.x

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

max r0.x, r0.z, l(0.000000)
add r0.x, -r0.z, r0.x
mad o0.z, cb1[5].y, r0.x, r0.z
ret
// Approximately 0 instruction slots used