// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed 7f3edb899fd8254b-vs.txt
// 3DMigoto: 7f3edb899fd8254b |    Unity headers extracted from 0x002ad9f8.shader
//    Shader "Standard" {
//      Properties {
//       _Color ("Color", Color) = (1,1,1,1)
//       _MainTex ("Albedo", 2D) = "white" { }
//       _Cutoff ("Alpha Cutoff", Range(0,1)) = 0.5
//       _Glossiness ("Smoothness", Range(0,1)) = 0.5
//      [Gamma]  _Metallic ("Metallic", Range(0,1)) = 0
//       _MetallicGlossMap ("Metallic", 2D) = "white" { }
//       _BumpScale ("Scale", Float) = 1
//       _BumpMap ("Normal Map", 2D) = "bump" { }
//       _Parallax ("Height Scale", Range(0.005,0.08)) = 0.02
//       _ParallaxMap ("Height Map", 2D) = "black" { }
//       _OcclusionStrength ("Strength", Range(0,1)) = 1
//       _OcclusionMap ("Occlusion", 2D) = "white" { }
//       _EmissionColor ("Color", Color) = (0,0,0,1)
//       _EmissionMap ("Emission", 2D) = "white" { }
//       _DetailMask ("Detail Mask", 2D) = "white" { }
//       _DetailAlbedoMap ("Detail Albedo x2", 2D) = "grey" { }
//       _DetailNormalMapScale ("Scale", Float) = 1
//       _DetailNormalMap ("Normal Map", 2D) = "bump" { }
//      [Enum(UV0,0,UV1,1)]  _UVSec ("UV Set for secondary textures", Float) = 0
//      [HideInInspector]  _Mode ("__mode", Float) = 0
//      [HideInInspector]  _SrcBlend ("__src", Float) = 1
//      [HideInInspector]  _DstBlend ("__dst", Float) = 0
//      [HideInInspector]  _ZWrite ("__zw", Float) = 1
//      }
//      Fallback "VertexLit"
//      SubShader 2/2 {
//        LOD 150
//        Tags { "RenderType"="Opaque" "PerformanceChecks"="False" }
//        Pass 3/3 {
//          Name "SHADOWCASTER"
//          Tags { "LIGHTMODE"="SHADOWCASTER" "SHADOWSUPPORT"="true" "RenderType"="Opaque" "PerformanceChecks"="False" }
//          GpuProgramID 488501
//          Program "vp" {
//            SubProgram "d3d11_9x " {
//              GpuProgramIndex 175
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from 0x002ad9f8.shader.decompressed:
//   API d3d11_9x
//   Shader model vs_4_0_level_9_1
//   undeciphered1: 201509030 41 0 0
//   Keywords { "SHADOWS_DEPTH" }
//   undeciphered2: 1 0 4 0 0
//   undeciphered3: 3 2 0 0 1 2
//   ConstBuffer "UnityLighting" 720
//   Vector 0 [_WorldSpaceLightPos0]
//   ConstBuffer "UnityShadows" 416
//   Vector 80 [unity_LightShadowBias]
//   ConstBuffer "UnityPerDraw" 352
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [_Object2World]
//   Matrix 256 [_World2Object]
//   ConstBuffer "UnityPerFrame" 256
//   Matrix 144 [unity_MatrixVP]
//   BindCB "UnityLighting" 0
//   BindCB "UnityShadows" 1
//   BindCB "UnityPerDraw" 2
//   BindCB "UnityPerFrame" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://github.com/DarkStarSword/3d-fixes

//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.3.2 on Mon Jul 23 23:45:20 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyz
// NORMAL                   0   xyz         1     NONE   float   xyz
// TEXCOORD                 0   xy          2     NONE   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION              0   xyzw        0      POS   float   xyzw
//
//
// Constant buffer to DX9 shader constant mappings:
//
// Target Reg Buffer  Start Reg # of Regs        Data Conversion
// ---------- ------- --------- --------- ----------------------
// c1         cb0             0         1  ( FLT, FLT, FLT, FLT)
// c2         cb1             5         1  ( FLT, FLT, FLT, FLT)
// c3         cb2             0         4  ( FLT, FLT, FLT, FLT)
// c7         cb2            12         7  ( FLT, FLT, FLT, FLT)
// c14        cb3             9         4  ( FLT, FLT, FLT, FLT)
//
//
// Runtime generated constant mappings:
//
// Target Reg                               Constant Description
// ---------- --------------------------------------------------
// c0                              Vertex Shader position offset
//
//
// Level9 shader bytecode:
//
    vs_2_0
    def c18, 1, 0, 0, 0
    dcl_texcoord v0
    dcl_texcoord1 v1
    mul r0.x, v1.x, c11.x
    mul r0.y, v1.x, c12.x
    mul r0.z, v1.x, c13.x
    mul r1.x, v1.y, c11.y
    mul r1.y, v1.y, c12.y
    mul r1.z, v1.y, c13.y
    add r0.xyz, r0, r1
    mul r1.x, v1.z, c11.z
    mul r1.y, v1.z, c12.z
    mul r1.z, v1.z, c13.z
    add r0.xyz, r0, r1
    nrm r1.xyz, r0
    mul r0.xyz, v0.y, c8
    mad r0.xyz, c7, v0.x, r0
    mad r0.xyz, c9, v0.z, r0
    add r0.xyz, r0, c10
    mad r2.xyz, r0, -c1.w, c1
    nrm r3.xyz, r2
    dp3 r0.w, r1, r3
    mad r0.w, r0.w, -r0.w, c18.x
    rsq r0.w, r0.w
    rcp r0.w, r0.w
    mul r0.w, r0.w, c2.z
    mad r0.xyz, r1, -r0.w, r0
    mul r1, r0.y, c15
    mad r1, c14, r0.x, r1
    mad r0, c16, r0.z, r1
    add r0, r0, c17
    mul r1, v0.y, c4
    mad r1, c3, v0.x, r1
    mad r1, c5, v0.z, r1
    add r1, r1, c6
    mul r2.x, c2.z, c2.z
    slt r2.x, -r2.x, r2.x
    lrp r3, r2.x, r0, r1
    rcp r0.x, r3.w
    mul r0.x, r0.x, c2.x
    max r0.x, r0.x, c18.y
    min r0.x, r0.x, c18.x
    add r0.x, r0.x, r3.z
    max r0.y, r0.x, c18.y
    add r0.y, -r0.x, r0.y
    mad oPos.z, c2.y, r0.y, r0.x
    mad oPos.xy, r3.w, c0, r3
    mov oPos.w, r3.w

// approximately 49 instruction slots used
vs_4_0
dcl_constantbuffer cb0[1], immediateIndexed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb2[19], immediateIndexed
dcl_constantbuffer cb3[13], immediateIndexed
dcl_input v0.xyz
dcl_input v1.xyz
dcl_output_siv o0.xyzw, position
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

mul r0.x, v1.x, cb2[16].x
mul r0.y, v1.x, cb2[17].x
mul r0.z, v1.x, cb2[18].x
mul r1.x, v1.y, cb2[16].y
mul r1.y, v1.y, cb2[17].y
mul r1.z, v1.y, cb2[18].y
add r0.xyz, r0.xyzx, r1.xyzx
mul r1.x, v1.z, cb2[16].z
mul r1.y, v1.z, cb2[17].z
mul r1.z, v1.z, cb2[18].z
add r0.xyz, r0.xyzx, r1.xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
rsq r0.w, r0.w
mul r0.xyz, r0.wwww, r0.xyzx
mul r1.xyz, v0.yyyy, cb2[13].xyzx
mad r1.xyz, cb2[12].xyzx, v0.xxxx, r1.xyzx
mad r1.xyz, cb2[14].xyzx, v0.zzzz, r1.xyzx
add r1.xyz, r1.xyzx, cb2[15].xyzx
mad r2.xyz, -r1.xyzx, cb0[0].wwww, cb0[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, cb1[5].z
mad r0.xyz, -r0.xyzx, r0.wwww, r1.xyzx
mul r1.xyzw, r0.yyyy, cb3[10].xyzw
mad r1.xyzw, cb3[9].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb3[11].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb3[12].xyzw
mul r1.xyzw, v0.yyyy, cb2[1].xyzw
mad r1.xyzw, cb2[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb2[2].xyzw, v0.zzzz, r1.xyzw
add r1.xyzw, r1.xyzw, cb2[3].xyzw
ne r2.x, cb1[5].z, l(0.000000)
movc r0.xyzw, r2.xxxx, r0.xyzw, r1.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 7f3edb899fd8254b-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_sat r1.x, cb1[5].x, r0.w
add r0.z, r0.z, r1.x

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

max r0.x, r0.z, l(0.000000)
add r0.x, -r0.z, r0.x
mad o0.z, cb1[5].y, r0.x, r0.z
ret
// Approximately 0 instruction slots used