// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed 27fed345a45d5c3a-vs.txt
// 3DMigoto: 27fed345a45d5c3a | Matched 16 variants of 2 shaders: Standard, Standard (Specular setup)
//
// 000f:    Unity headers extracted from Standard
// fff0:    Unity headers extracted from Standard (Specular setup)
// fff0:    Shader "Standard (Specular setup)" {
// 000f:    Shader "Standard" {
//            CustomEditor "StandardShaderGUI"
//            Fallback "VertexLit"
//       1:   SubShader 1/2 {
//       2:   SubShader 2/2 {
//       2:     LOD 150
//       1:     LOD 300
//              Tags { "PerformanceChecks"="False" "RenderType"="Opaque" }
//       2:     Pass 2/4 {
//       1:     Pass 2/5 {
//                Name "FORWARD_DELTA"
//                Tags { "LIGHTMODE"="FORWARDADD" "PerformanceChecks"="False" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//                ZWrite Off
//                Program "vp" {
//                  SubProgram "d3d11" {
//                  }
//                }
//              }
//            }
//          }
//
// fff0: Unity 5.3 headers extracted from Standard (Specular setup):
// 000f: Unity 5.3 headers extracted from Standard:
//         API d3d11
//         Shader model vs_4_0
//         undeciphered1: 201708220 38 0 0
//         undeciphered1a: 5
// 1000:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" "_SPECGLOSSMAP" }
// 0400:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" }
// 0004:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_METALLICGLOSSMAP" }
// 0800:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_SPECGLOSSMAP" }
// 0040:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" "_SPECGLOSSMAP" }
// 0010:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" }
// 0001:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_METALLICGLOSSMAP" }
// 0020:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_SPECGLOSSMAP" }
// 8000:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" "_SPECGLOSSMAP" }
// 2000:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" }
// 0008:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_METALLICGLOSSMAP" }
// 4000:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "LIGHTMAP_SHADOW_MIXING" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_SPECGLOSSMAP" }
// 0200:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" "_SPECGLOSSMAP" }
// 0080:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_ALPHATEST_ON" }
// 0002:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_METALLICGLOSSMAP" }
// 0100:   Keywords { "DIRECTIONAL_COOKIE" "SHADOWS_SCREEN" "SHADOWS_SHADOWMASK" "_NORMALMAP" "_SPECGLOSSMAP" }
//         undeciphered2: 1 0 6 0 0 0
//         undeciphered3: 55 5 0 0 1 1 4 5 5 6 2 2
// 1c75:   ConstBuffer "$Globals" 176
// e38a:   ConstBuffer "$Globals" 240
//         Vector 96 [_MainTex_ST]
//         Vector 112 [_DetailAlbedoMap_ST]
//         Float 156 [_UVSec]
//         ConstBuffer "UnityPerCamera" 144
//         Vector 64 [_WorldSpaceCameraPos] 3
//         Vector 80 [_ProjectionParams]
//         ConstBuffer "UnityLighting" 768
//         Vector 0 [_WorldSpaceLightPos0]
//         ConstBuffer "UnityPerDraw" 160
//         Vector 144 [unity_WorldTransformParams]
//         Matrix 0 [unity_ObjectToWorld]
//         Matrix 64 [unity_WorldToObject]
//         ConstBuffer "UnityPerFrame" 368
//         Matrix 272 [unity_MatrixVP]
//         ConstBuffer "UnityLightmaps" 32
//         Vector 0 [unity_LightmapST]
//         BindCB "$Globals" 0
//         BindCB "UnityPerCamera" 1
//         BindCB "UnityLighting" 2
//         BindCB "UnityPerDraw" 3
//         BindCB "UnityPerFrame" 4
//         BindCB "UnityLightmaps" 5
//
// Headers extracted with DarkStarSword's extract_unity55_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.2 on Mon Jan 14 17:54:08 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// NORMAL                   0   xyz         1     NONE   float   xyz
// TEXCOORD                 0   xy          2     NONE   float   xy
// TEXCOORD                 1   xy          3     NONE   float   xy
// TANGENT                  0   xyzw        4     NONE   float   xyzw
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xyzw        1     NONE   float   xyzw
// TEXCOORD                 1   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyzw        3     NONE   float   xyzw
// TEXCOORD                 3   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 5   xyz         6     NONE   float   xyz
// TEXCOORD                 6   xyzw        7     NONE   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[10], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[10], immediateIndexed
dcl_constantbuffer cb4[23], immediateIndexed
dcl_constantbuffer cb5[1], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xyz
dcl_input v2.xy
dcl_input v3.xy
dcl_input v4.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xyzw
dcl_output o2.xyz
dcl_output o3.xyzw
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyz
dcl_output o7.xyzw
dcl_temps 7

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125
dcl_constantbuffer cb10[4], immediateIndexed

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


// Unity reflection/specular 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 27fed345a45d5c3a-vs.txt

mul r5.w, -r5.x, r5.y
mad r6.xyz, -r5.wwww, cb10[0].xyzw, cb1[4].xyzw

mul r0.xyzw, v0.yyyy, cb3[1].xyzw
mad r0.xyzw, cb3[0].xyzw, v0.xxxx, r0.xyzw
mad r0.xyzw, cb3[2].xyzw, v0.zzzz, r0.xyzw
add r0.xyzw, r0.xyzw, cb3[3].xyzw
mul r1.xyzw, r0.yyyy, cb4[18].xyzw
mad r1.xyzw, cb4[17].xyzw, r0.xxxx, r1.xyzw
mad r1.xyzw, cb4[19].xyzw, r0.zzzz, r1.xyzw
mad r0.xyzw, cb4[20].xyzw, r0.wwww, r1.xyzw
mov o0.xyzw, r0.xyzw

// 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 27fed345a45d5c3a-vs.txt
ne r5.w, r0.w, l(1.0)
if_nz r5.w
  add r5.w, r0.w, -r5.y
  mad r0.x, r5.w, r5.x, r0.x
endif

eq r0.z, cb0[9].w, l(0.000000)
movc r1.xy, r0.zzzz, v2.xyxx, v3.xyxx
mad o1.zw, r1.xxxy, cb0[7].xxxy, cb0[7].zzzw
mad o1.xy, v2.xyxx, cb0[6].xyxx, cb0[6].zwzz
mul r1.xyz, v0.yyyy, cb3[1].xyzx
mad r1.xyz, cb3[0].xyzx, v0.xxxx, r1.xyzx
mad r1.xyz, cb3[2].xyzx, v0.zzzz, r1.xyzx
mad r1.xyz, cb3[3].xyzx, v0.wwww, r1.xyzx
add o2.xyz, r1.xyzx, -r6.xyzx
mul r2.xyz, v4.yyyy, cb3[1].xyzx
mad r2.xyz, cb3[0].xyzx, v4.xxxx, r2.xyzx
mad r2.xyz, cb3[2].xyzx, v4.zzzz, r2.xyzx
dp3 r0.z, r2.xyzx, r2.xyzx
rsq r0.z, r0.z
mul r2.xyz, r0.zzzz, r2.xyzx
mov o3.xyz, r2.xyzx
mad r3.xyz, -r1.xyzx, cb2[0].wwww, cb2[0].xyzx
mov o6.xyz, r1.xyzx
mov o3.w, r3.x
dp3 r1.x, v1.xyzx, cb3[4].xyzx
dp3 r1.y, v1.xyzx, cb3[5].xyzx
dp3 r1.z, v1.xyzx, cb3[6].xyzx
dp3 r0.z, r1.xyzx, r1.xyzx
rsq r0.z, r0.z
mul r1.xyz, r0.zzzz, r1.xyzx
mul r4.xyz, r2.yzxy, r1.zxyz
mad r2.xyz, r1.yzxy, r2.zxyz, -r4.xyzx
mov o5.xyz, r1.xyzx
mul r0.z, v4.w, cb3[9].w
mul o4.xyz, r0.zzzz, r2.xyzx
mov o4.w, r3.y
mov o5.w, r3.z
mul r0.y, r0.y, cb1[5].x
mul r0.xz, r0.xxwx, l(0.500000, 0.000000, 0.500000, 0.000000)
mul r0.w, r0.y, l(0.500000)
add o7.zw, r0.zzzz, r0.xxxw
mad o7.xy, v3.xyxx, cb5[0].xyxx, cb5[0].zwzz
ret
// Approximately 0 instruction slots used