// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed c93cbfd42295758c-vs.txt
// 3DMigoto: c93cbfd42295758c |    Unity headers extracted from PF_StandardDynamic
//    Shader "PF/StandardDynamic" {
//      CustomEditor "PFStandardDynamicShaderGUI"
//      SubShader 1/1 {
//        LOD 100
//        Tags { "Reflection"="Opaque" "RenderType"="Opaque" }
//        Pass 3/3 {
//          Name "ShadowCaster"
//          Tags { "LIGHTMODE"="SHADOWCASTER" "Reflection"="Opaque" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          Program "vp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from PF_StandardDynamic:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201802150 35 0 1
//   undeciphered1a: 3
//   Keywords { "SHADOWS_DEPTH" "INSTANCING_ON" "CUTOUT_ON" "DISSOLVE_ON" }
//   undeciphered2: 1 0 7 0 0 0
//   undeciphered3: 19 3 0 0 1 1 4 5
//   ConstBuffer "$Globals" 2400
//   Vector 96 [_MainTex_ST]
//   ConstBuffer "UnityLighting" 768
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityShadows" 416
//   Vector 80 [unity_LightShadowBias]
//   ConstBuffer "UnityPerFrame" 368
//   Matrix 272 [unity_MatrixVP]
//   ConstBuffer "UnityDrawCallInfo" 16
//   ScalarInt 0 [unity_BaseInstanceID]
//   ConstBuffer "UnityInstancing_PerDraw0" 256
//   Struct 0 [unity_Builtins0Array] 2 128
//   Matrix 0 [unity_ObjectToWorldArray]
//   Matrix 64 [unity_WorldToObjectArray]
//   ConstBuffer "PFCommonBuffer" 240
//   Vector 0 [_DissolveTex_ST]
//   BindCB "$Globals" 0
//   BindCB "UnityLighting" 1
//   BindCB "UnityShadows" 2
//   BindCB "UnityPerFrame" 3
//   BindCB "UnityDrawCallInfo" 4
//   BindCB "UnityInstancing_PerDraw0" 5
//   BindCB "PFCommonBuffer" 6
//
// 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 Aug 23 07:03:16 2020
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// SV_InstanceID            0   x           1   INSTID    uint   x
// NORMAL                   0   xyz         2     NONE   float   xyz
// TEXCOORD                 0   xyzw        3     NONE   float   xy
//
//
// 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     zw        1     NONE   float     zw
//
vs_4_0
dcl_constantbuffer cb0[7], immediateIndexed
dcl_constantbuffer cb1[1], immediateIndexed
dcl_constantbuffer cb2[6], immediateIndexed
dcl_constantbuffer cb3[21], immediateIndexed
dcl_constantbuffer cb4[1], immediateIndexed
dcl_constantbuffer cb5[15], dynamicIndexed
dcl_constantbuffer cb6[1], immediateIndexed
dcl_input v0.xyzw
dcl_input_sgv v1.x, instance_id
dcl_input v2.xyz
dcl_input v3.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o1.zw
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

iadd r0.x, v1.x, cb4[0].x
mad o1.xy, v3.xyxx, cb0[6].xyxx, cb0[6].zwzz
mad o1.zw, v3.xxxy, cb6[0].xxxy, cb6[0].zzzw
ishl r0.x, r0.x, l(3)
mul r1.xyzw, v0.yyyy, cb5[r0.x + 1].xyzw
mad r1.xyzw, cb5[r0.x + 0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb5[r0.x + 2].xyzw, v0.zzzz, r1.xyzw
mad r1.xyzw, cb5[r0.x + 3].xyzw, v0.wwww, r1.xyzw
ne r0.y, cb2[5].z, l(0.000000)
if_nz r0.y
  dp3 r2.x, v2.xyzx, cb5[r0.x + 4].xyzx
  dp3 r2.y, v2.xyzx, cb5[r0.x + 5].xyzx
  dp3 r2.z, v2.xyzx, cb5[r0.x + 6].xyzx
  dp3 r0.x, r2.xyzx, r2.xyzx
  rsq r0.x, r0.x
  mul r0.xyz, r0.xxxx, r2.xyzx
  mad r2.xyz, -r1.xyzx, cb1[0].wwww, cb1[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, cb2[5].z
  mad r1.xyz, -r0.xyzx, r0.wwww, r1.xyzx
endif
mul r0.xyzw, r1.yyyy, cb3[18].xyzw
mad r0.xyzw, cb3[17].xyzw, r1.xxxx, r0.xyzw
mad r0.xyzw, cb3[19].xyzw, r1.zzzz, r0.xyzw
mad r0.xyzw, cb3[20].xyzw, r1.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 c93cbfd42295758c-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, cb2[5].x, r0.w
min r1.x, r1.x, l(0.000000)
max r1.x, r1.x, l(-1.000000)
add r0.z, r0.z, r1.x
min r1.x, r0.w, r0.z
add r1.x, -r0.z, r1.x
mad o0.z, cb2[5].y, r1.x, r0.z

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

ret
// Approximately 0 instruction slots used