// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed e9e5d3568c13714b-vs.txt
// 3DMigoto: e9e5d3568c13714b | Matched 9 variants of 2 shaders: Midnight Hub/Nature/Cliff, Midnight Hub/Standard
//
// 00f:    Unity headers extracted from Midnight Hub_Nature_Cliff
// 1f0:    Unity headers extracted from Midnight Hub_Standard
// 00f:    Shader "Midnight Hub/Nature/Cliff" {
// 1f0:    Shader "Midnight Hub/Standard" {
//           CustomEditor "Rendering.Materials.StandarMaterialEditor"
// 00f:      Fallback "Diffuse"
//           SubShader 1/1 {
//             Pass 4/5 {
//               Name "SHADOWCASTER"
//               Tags { "LIGHTMODE"="SHADOWCASTER" "SHADOWSUPPORT"="true" }
//               Program "vp" {
//                 SubProgram "d3d11" {
//                 }
//               }
//             }
//           }
//         }
//
// 00f: Unity 5.3 headers extracted from Midnight Hub_Nature_Cliff:
// 1f0: Unity 5.3 headers extracted from Midnight Hub_Standard:
//        API d3d11
//        Shader model vs_4_0
//        undeciphered1: 201609010 43 0 0
//        undeciphered1a: 4
// 002:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "APPLY_MOSS" }
// 008:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "NORMAL_MULTIPLYER" "APPLY_MOSS" }
// 104:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "NORMAL_MULTIPLYER" }
// 040:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "_EMISSIVE" "_EMISSIVE_FADE" }
// 020:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "_EMISSIVE" }
// 080:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" "_NORMALMAP" }
// 011:   Keywords { "SHADOWS_DEPTH" "LOD_FADE_CROSSFADE" }
//        undeciphered2: 1 0 5 0 0 0
//        undeciphered3: 3 2 0 0 1 2
//        ConstBuffer "UnityPerCamera" 144
//        Vector 80 [_ProjectionParams]
//        Vector 96 [_ScreenParams]
//        ConstBuffer "UnityLighting" 752
//        Vector 0 [_WorldSpaceLightPos0]
//        ConstBuffer "UnityShadows" 416
//        Vector 80 [unity_LightShadowBias]
//        ConstBuffer "UnityPerDraw" 160
//        Matrix 0 [unity_ObjectToWorld]
//        Matrix 64 [unity_WorldToObject]
//        ConstBuffer "UnityPerFrame" 384
//        Matrix 272 [unity_MatrixVP]
//        BindCB "UnityPerCamera" 0
//        BindCB "UnityLighting" 1
//        BindCB "UnityShadows" 2
//        BindCB "UnityPerDraw" 3
//        BindCB "UnityPerFrame" 4
//
// 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.16 on Sun Apr 21 18:03:42 2019
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TANGENT                  0   xyzw        1     NONE   float
// NORMAL                   0   xyz         2     NONE   float   xyz
// TEXCOORD                 0   xyzw        3     NONE   float
// TEXCOORD                 1   xyzw        4     NONE   float
// TEXCOORD                 2   xyzw        5     NONE   float
// TEXCOORD                 3   xyzw        6     NONE   float
// COLOR                    0   xyzw        7     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 1   xyz         1     NONE   float   xyz
// TEXCOORD                 2   xyz         2     NONE   float   xyz
//
vs_4_0
dcl_constantbuffer cb0[7], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[6], immediateIndexed
dcl_constantbuffer cb3[7], immediateIndexed
dcl_constantbuffer cb4[21], immediateIndexed
dcl_input v0.xyzw
dcl_input v2.xyz
dcl_output_siv o0.xyzw, position
dcl_output o1.xyz
dcl_output o2.xyz
dcl_temps 5

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

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

dp3 r0.x, v2.xyzx, cb3[4].xyzx
dp3 r0.y, v2.xyzx, cb3[5].xyzx
dp3 r0.z, v2.xyzx, cb3[6].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.xyzw, v0.yyyy, cb3[1].xyzw
mad r1.xyzw, cb3[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb3[2].xyzw, v0.zzzz, r1.xyzw
mad r2.xyzw, cb3[3].xyzw, v0.wwww, r1.xyzw
mad r3.xyz, -r2.xyzx, cb1[0].wwww, cb1[0].xyzx
dp3 r0.w, r3.xyzx, r3.xyzx
rsq r0.w, r0.w
mul r3.xyz, r0.wwww, r3.xyzx
dp3 r0.w, r0.xyzx, r3.xyzx
mad r0.w, -r0.w, r0.w, l(1.000000)
sqrt r0.w, r0.w
mul r0.w, r0.w, cb2[5].z
mad r0.xyz, -r0.xyzx, r0.wwww, r2.xyzx
ne r0.w, cb2[5].z, l(0.000000)
movc r0.xyz, r0.wwww, r0.xyzx, r2.xyzx
mul r3.xyzw, r0.yyyy, cb4[18].xyzw
mad r3.xyzw, cb4[17].xyzw, r0.xxxx, r3.xyzw
mad r0.xyzw, cb4[19].xyzw, r0.zzzz, r3.xyzw
mad r0.xyzw, cb4[20].xyzw, r2.wwww, r0.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 e9e5d3568c13714b-vs.txt
ne r4.w, r0.w, l(1.0)
if_nz r4.w
  add r4.w, r0.w, -r4.y
  mad r0.x, r4.w, r4.x, r0.x
endif

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

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

add r0.x, -r0.z, r2.x
mad o0.z, cb2[5].y, r0.x, r0.z
mad o1.xyz, cb3[3].xyzx, v0.wwww, r1.xyzx
add r0.xyzw, r1.xyzw, cb3[3].xyzw
mul r1.xyz, r0.yyyy, cb4[18].xywx
mad r1.xyz, cb4[17].xywx, r0.xxxx, r1.xyzx
mad r0.xyz, cb4[19].xywx, r0.zzzz, r1.xyzx
mad r0.xyz, cb4[20].xywx, r0.wwww, r0.xyzx
mul r1.xz, r0.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
mul r0.x, r0.y, cb0[5].x
mov o2.z, r0.z
mul r1.w, r0.x, l(0.500000)
add r0.xy, r1.zzzz, r1.xwxx
mul r0.zw, cb0[6].xxxy, l(0.000000, 0.000000, 0.250000, 0.250000)
mul o2.xy, r0.zwzz, r0.xyxx
ret
// Approximately 0 instruction slots used