// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed d6fbc44f11e1d7a6-vs.txt
// 3DMigoto: d6fbc44f11e1d7a6 |    Unity headers extracted from PF_Standard
//    Shader "PF/Standard" {
//      CustomEditor "PFStandardShaderGUI"
//      SubShader 1/1 {
//        LOD 100
//        Tags { "Reflection"="Opaque" "RenderType"="Opaque" }
//        Pass 3/4 {
//          Name "SHADOWCASTER"
//          Tags { "LIGHTMODE"="SHADOWCASTER" "Reflection"="Opaque" "RenderType"="Opaque" "SHADOWSUPPORT"="true" }
//          Program "vp" {
//            SubProgram "d3d11" {
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from PF_Standard:
//   API d3d11
//   Shader model vs_4_0
//   undeciphered1: 201708220 70 0 1
//   undeciphered1a: 5
//   Keywords { "SHADOWS_DEPTH" "INSTANCING_ON" "VERTEX_ANIMATION_ON" "VERTEX_ANIMATION_COMPLEX_ON" }
//   undeciphered2: 1 0 7 0 0 0
//   undeciphered3: 155 3 0 0 1 1 3 3
//   ConstBuffer "UnityPerCamera" 144
//   Vector 0 [_Time]
//   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 "VertexAnimBuffer" 64
//   Float 0 [_ComplexAnimBranchScale]
//   Float 4 [_ComplexAnimEdgeFlutterScale]
//   Float 8 [_ComplexAnimPrimaryFactorScale]
//   Float 12 [_ComplexAnimSecondaryFactorScale]
//   Vector 32 [_Wind]
//   BindCB "UnityPerCamera" 0
//   BindCB "UnityLighting" 1
//   BindCB "UnityShadows" 2
//   BindCB "UnityPerFrame" 3
//   BindCB "UnityDrawCallInfo" 4
//   BindCB "UnityInstancing_PerDraw0" 5
//   BindCB "VertexAnimBuffer" 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.2 on Mon Jan 14 19:34:25 2019
//
//
// 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
// TEXCOORD                 3   xy          4     NONE   float
// COLOR                    0   xyzw        5     NONE   float   xyzw
//
//
// 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[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[3], immediateIndexed
dcl_input v0.xyzw
dcl_input_sgv v1.x, instance_id
dcl_input v2.xyz
dcl_input v5.xyzw
dcl_output_siv o0.xyzw, position
dcl_temps 6

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

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

iadd r0.x, v1.x, cb4[0].x
ishl r0.x, r0.x, l(3)
dp3 r0.y, cb5[r0.x + 3].xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
add r0.z, r0.y, cb0[0].y
mul r0.z, r0.z, cb6[2].w
mul r1.xyz, r0.zzzz, l(1.975000, 0.793000, 0.375000, 0.000000)
frc r1.xyz, r1.xyzx
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-0.500000, -0.500000, -0.500000, 0.000000)
frc r1.xyz, r1.xyzx
mad r1.xyz, r1.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
mul r2.xyz, |r1.xyzx|, |r1.xyzx|
mad r1.xyz, -|r1.xyzx|, l(2.000000, 2.000000, 2.000000, 0.000000), l(3.000000, 3.000000, 3.000000, 0.000000)
mul r1.xyz, r1.xyzx, r2.xyzx
mad r1.xyz, cb6[2].xyzx, r1.xyzx, cb6[2].xyzx
mul r2.xyz, r1.yyyy, cb5[r0.x + 5].xyzx
mad r1.xyw, cb5[r0.x + 4].xyxz, r1.xxxx, r2.xyxz
mad r1.xyz, cb5[r0.x + 6].xyzx, r1.zzzz, r1.xywx
mul r2.xyz, v5.ywzy, cb6[0].yzwy
mad r3.y, v5.x, cb6[0].x, r0.y
mad r0.y, v5.y, cb6[0].y, r3.y
dp3 r3.x, v0.xyzx, r0.yyyy
add r3.xyzw, r3.xxyy, cb0[0].yyyy
mul r3.xyzw, r3.xyzw, l(1.975000, 0.793000, 0.375000, 0.193000)
frc r3.xyzw, r3.xyzw
mad r3.xyzw, r3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-0.500000, -0.500000, -0.500000, -0.500000)
frc r3.xyzw, r3.xyzw
mad r3.xyzw, r3.xyzw, l(2.000000, 2.000000, 2.000000, 2.000000), l(-1.000000, -1.000000, -1.000000, -1.000000)
mul r4.xyzw, |r3.xyzw|, |r3.xyzw|
mad r3.xyzw, -|r3.xyzw|, l(2.000000, 2.000000, 2.000000, 2.000000), l(3.000000, 3.000000, 3.000000, 3.000000)
mul r3.xyzw, r3.xyzw, r4.xyzw
add r3.xy, r3.ywyy, r3.xzxx
mul r0.y, r2.x, l(0.100000)
mul r4.xz, r0.yyyy, v2.xxzx
mul r4.y, r2.z, r3.y
mov r3.z, l(0.300000)
mul r0.yzw, r1.xxyz, r3.yyyy
mul r0.yzw, r2.zzzz, r0.yyzw
mad r0.yzw, r3.xxzx, r4.xxyz, r0.yyzw
mad r0.yzw, r0.yyzw, cb6[2].wwww, v0.xxyz
mad r0.yzw, r2.yyyy, r1.xxyz, r0.yyzw
mul r1.xyzw, r0.zzzz, cb5[r0.x + 1].xyzw
mad r1.xyzw, cb5[r0.x + 0].xyzw, r0.yyyy, r1.xyzw
mad r1.xyzw, cb5[r0.x + 2].xyzw, r0.wwww, 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 d6fbc44f11e1d7a6-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

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