// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed a1469a07e57a1af5-vs.txt
// 3DMigoto: a1469a07e57a1af5 | Matched 2 variants of 1 shaders: Midnight Hub/Nature/Tree Leaves
//
//       Unity headers extracted from Midnight Hub_Nature_Tree Leaves
//       Shader "Midnight Hub/Nature/Tree Leaves" {
//         CustomEditor "Rendering.Materials.CutoutMaterialEditor"
//         SubShader 1/1 {
//           Tags { "QUEUE"="AlphaTest" }
//           Pass 4/5 {
//             Name "SHADOWCASTER"
//             Tags { "LIGHTMODE"="SHADOWCASTER" "QUEUE"="AlphaTest" "SHADOWSUPPORT"="true" }
//             Program "vp" {
//               SubProgram "d3d11" {
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from Midnight Hub_Nature_Tree Leaves:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201609010 49 0 0
//      undeciphered1a: 4
// 1:   Keywords { "SHADOWS_DEPTH" "_ALPHATEST_ON" }
// 2:   Keywords { "SHADOWS_DEPTH" "_NORMALMAP" "_ALPHATEST_ON" }
//      undeciphered2: 1 0 6 0 0 0
//      undeciphered3: 15 4 0 0 1 2 3 4 2 1
//      ConstBuffer "$Globals" 1216
//      Float 1152 [_RedFlex]
//      Float 1156 [_GreenFlex]
//      Float 1160 [_BlueFlex]
//      Float 1164 [_WindFrequency]
//      Float 1168 [_TurbulanceFrequency]
//      Vector 1184 [_MainTex_ST]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 0 [_Time]
//      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 "$Globals" 0
//      BindCB "UnityPerCamera" 1
//      BindCB "UnityLighting" 2
//      BindCB "UnityShadows" 3
//      BindCB "UnityPerDraw" 4
//      BindCB "UnityPerFrame" 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.16 on Sun Apr 21 17:59:47 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   xy
// TEXCOORD                 1   xyzw        4     NONE   float
// TEXCOORD                 2   xyzw        5     NONE   float
// TEXCOORD                 3   xyzw        6     NONE   float
// COLOR                    0   xyzw        7     NONE   float   xyz
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 1   xy          1     NONE   float   xy
// TEXCOORD                 2   xyz         2     NONE   float   xyz
//
vs_4_0
dcl_constantbuffer cb0[75], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[1], immediateIndexed
dcl_constantbuffer cb3[6], immediateIndexed
dcl_constantbuffer cb4[7], immediateIndexed
dcl_constantbuffer cb5[21], immediateIndexed
dcl_input v0.xyzw
dcl_input v2.xyz
dcl_input v3.xy
dcl_input v7.xyz
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
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, cb4[4].xyzx
dp3 r0.y, v2.xyzx, cb4[5].xyzx
dp3 r0.z, v2.xyzx, cb4[6].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r0.w, cb0[72].w, cb1[0].z
mad r0.w, r0.w, l(0.100000), l(0.100000)
sincos r0.w, null, r0.w
mul r0.w, r0.w, v7.x
mad r1.x, r0.w, cb0[72].x, v0.x
mad r0.w, cb1[0].w, cb0[73].x, v0.y
sincos r0.w, null, r0.w
mul r1.w, r0.w, l(0.050000)
mul r2.xyz, r0.wwww, v2.xyzx
mul r2.xyz, r2.xyzx, v7.zzzz
mul r0.w, r1.w, v7.y
mad r1.y, r0.w, cb0[72].y, v0.y
mov r1.z, v0.z
mad r1.xyz, r2.xyzx, cb0[72].zzzz, r1.xyzx
mul r2.xyzw, r1.yyyy, cb4[1].xyzw
mad r2.xyzw, cb4[0].xyzw, r1.xxxx, r2.xyzw
mad r2.xyzw, cb4[2].xyzw, r1.zzzz, r2.xyzw
mad r2.xyzw, cb4[3].xyzw, v0.wwww, r2.xyzw
mad r3.xyz, -r2.xyzx, cb2[0].wwww, cb2[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, cb3[5].z
mad r0.xyz, -r0.xyzx, r0.wwww, r2.xyzx
ne r0.w, cb3[5].z, l(0.000000)
movc r0.xyz, r0.wwww, r0.xyzx, r2.xyzx
mul r3.xyzw, r0.yyyy, cb5[18].xyzw
mad r3.xyzw, cb5[17].xyzw, r0.xxxx, r3.xyzw
mad r0.xyzw, cb5[19].xyzw, r0.zzzz, r3.xyzw
mad r0.xyzw, cb5[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 a1469a07e57a1af5-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 r1.w, cb3[5].x, r0.w
min r1.w, r1.w, l(0.000000)
max r1.w, r1.w, l(-1.000000)
add r0.z, r0.z, r1.w
min r1.w, r0.w, r0.z

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

add r0.x, -r0.z, r1.w
mad o0.z, cb3[5].y, r0.x, r0.z
mad o1.xy, v3.xyxx, cb0[74].xyxx, cb0[74].zwzz
mul r0.xyz, r1.yyyy, cb4[1].xyzx
mad r0.xyz, cb4[0].xyzx, r1.xxxx, r0.xyzx
mad r0.xyz, cb4[2].xyzx, r1.zzzz, r0.xyzx
mad o2.xyz, cb4[3].xyzx, v0.wwww, r0.xyzx
ret
// Approximately 0 instruction slots used