// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed 7fc73a0d988f78c9-vs.txt
// 3DMigoto: 7fc73a0d988f78c9 |    Unity headers extracted from AlphaBlendDistort.shader
//    Shader "FX/Alpha Blend Distort" {
//      Properties {
//       _MainTex ("Base (RGB)", 2D) = "white" { }
//       _Color ("Main Color", Color) = (1,1,1,1)
//       _MainTexSettings ("Main Texture Settings", Vector) = (0,0,0,0)
//       _MaskTex ("Mask", 2D) = "white" { }
//       _MaskSettings ("Mask Settings", Vector) = (0,0,0,0)
//       _DistortionTex ("Distortion (Normal)", 2D) = "bump" { }
//       _DistortionMaskTex ("Distortion Mask", 2D) = "white" { }
//       _DistortionSettings ("Distortion Settings", Vector) = (0,0,0,0)
//      }
//      Fallback Off
//      SubShader 1/1 {
//        Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" }
//        Pass 1/1 {
//          Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" }
//          ZWrite Off
//          Cull Off
//          Blend SrcAlpha OneMinusSrcAlpha
//          ColorMask RGB
//          GpuProgramID 45185
//          Program "vp" {
//            SubProgram "d3d11_9x " {
//              GpuProgramIndex 2
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from AlphaBlendDistort.shader.decompressed:
//   API d3d11_9x
//   Shader model vs_4_0_level_9_1
//   undeciphered1: 201509030 30 0 0
//   undeciphered2: 1 0 3 0 0
//   undeciphered3: 9 2 0 0 3 4
//   ConstBuffer "$Globals" 240
//   Float 96 [_FogGradientRange]
//   Float 100 [_GameTime]
//   Vector 112 [_MainTex_ST]
//   Vector 128 [_MainTexSettings]
//   Vector 144 [_MaskTex_ST]
//   Vector 160 [_MaskSettings]
//   Vector 192 [_DistortionTex_ST]
//   Vector 208 [_DistortionSettings]
//   Vector 224 [_DistortionMaskTex_ST]
//   ConstBuffer "UnityPerDraw" 352
//   Matrix 0 [glstate_matrix_mvp]
//   Matrix 192 [_Object2World]
//   ConstBuffer "UnityPerFrame" 256
//   Vector 64 [glstate_lightmodel_ambient]
//   BindCB "$Globals" 0
//   BindCB "UnityPerDraw" 1
//   BindCB "UnityPerFrame" 2
//
// 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:21 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy
// TEXCOORD                 1     zw        1     NONE   float     zw
// TEXCOORD                 2   xy          2     NONE   float   xy
// TEXCOORD                 3     zw        2     NONE   float     zw
// TEXCOORD                 4   x           3     NONE   float   x
// TEXCOORD                 5    y          3     NONE   float    y
//
//
// Constant buffer to DX9 shader constant mappings:
//
// Target Reg Buffer  Start Reg # of Regs        Data Conversion
// ---------- ------- --------- --------- ----------------------
// c1         cb0             6         5  ( FLT, FLT, FLT, FLT)
// c6         cb0            12         3  ( FLT, FLT, FLT, FLT)
// c9         cb1             0         4  ( FLT, FLT, FLT, FLT)
// c13        cb1            12         4  ( FLT, FLT, FLT, FLT)
// c17        cb2             4         1  ( 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, 0.200000003, 4.05999994, 1, 0.5
    def c19, 200, 0.000833333354, 0, 0
    dcl_texcoord v0
    dcl_texcoord1 v1
    mad r0.xy, v1, c2, c2.zwzw
    add r0.zw, c1.xyyx, c1.xyyx
    mad oT0.xy, r0.z, c3.zwzw, r0
    mad r0.xy, v1.yxzw, c4.yxzw, c4.wzzw
    mad oT0.zw, r0.z, c5.xywz, r0.xyxy
    mad r0.xy, v1, c6, c6.zwzw
    mad oT1.xy, r0.z, c7.zwzw, r0
    rcp r0.x, r0.w
    mad oT1.zw, v1.xyyx, c8.xyyx, c8.xywz
    mov r1.xy, c18
    mul r0.yz, r1.xxyw, c17.w
    frc r0.w, r0.z
    add r0.z, -r0.w, r0.z
    add r0.z, -r0.z, c18.z
    mul r0.y, r0.z, r0.y
    mul r1, v0.y, c10
    mad r1, c9, v0.x, r1
    mad r1, c11, v0.z, r1
    mad r1, c12, v0.w, r1
    dp4 r0.z, r1, r1
    rsq r0.z, r0.z
    rcp r0.z, r0.z
    mul r0.y, r0.y, r0.z
    abs r0.y, r0.y
    expp r0.y, -r0.y
    mad oT2.x, r0.y, -r0.y, c18.z
    mul r0.y, v0.y, c14.z
    mad r0.y, c13.z, v0.x, r0.y
    mad r0.y, c15.z, v0.z, r0.y
    mad r0.y, c16.z, v0.w, r0.y
    mad oT2.y, r0.y, r0.x, c18.w
    add r0.x, r0.y, c19.x
    mul r0.x, r1.w, r0.x
    mul oPos.z, r0.x, c19.y
    mad oPos.xy, r1.w, c0, r1
    mov oPos.w, r1.w

// approximately 36 instruction slots used
vs_4_0
dcl_constantbuffer cb0[15], immediateIndexed
dcl_constantbuffer cb1[16], immediateIndexed
dcl_constantbuffer cb2[5], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o1.zw
dcl_output o2.xy
dcl_output o2.zw
dcl_output o3.x
dcl_output o3.y
dcl_temps 3

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

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

mul r0.x, v0.y, cb1[13].z
mad r0.x, cb1[12].z, v0.x, r0.x
mad r0.x, cb1[14].z, v0.z, r0.x
mad r0.x, cb1[15].z, v0.w, r0.x
add r0.y, r0.x, l(200.000000)
mul r1.xyzw, v0.yyyy, cb1[1].xyzw
mad r1.xyzw, cb1[0].xyzw, v0.xxxx, r1.xyzw
mad r1.xyzw, cb1[2].xyzw, v0.zzzz, r1.xyzw
mad r1.xyzw, cb1[3].xyzw, v0.wwww, r1.xyzw

// Relocated to here with asmtool.py
mov o0.xyw, r1.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 7fc73a0d988f78c9-vs.txt
ne r2.w, r1.w, l(1.0)
if_nz r2.w
  add r2.w, r1.w, -r2.y
  mad r1.x, r2.w, r2.x, r1.x
endif

mul r0.y, r0.y, r1.w
mul o0.z, r0.y, l(0.000833333354)

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

dp4 r0.y, r1.xyzw, r1.xyzw
sqrt r0.y, r0.y
mad r0.zw, v1.xxxy, cb0[7].xxxy, cb0[7].zzzw
add r1.xy, cb0[6].yxyy, cb0[6].yxyy
mad o1.xy, r1.xxxx, cb0[8].zwzz, r0.zwzz
mad r0.zw, v1.xxxy, cb0[9].xxxy, cb0[9].zzzw
mad o1.zw, r1.xxxx, cb0[10].zzzw, r0.zzzw
mad r0.zw, v1.xxxy, cb0[12].xxxy, cb0[12].zzzw
mad o2.xy, r1.xxxx, cb0[13].zwzz, r0.zwzz
div r0.x, r0.x, r1.y
add o3.y, r0.x, l(0.500000)
mad o2.zw, v1.xxxy, cb0[14].xxxy, cb0[14].zzzw
mul r0.xz, cb2[4].wwww, l(0.200000, 0.000000, 4.060000, 0.000000)
round_ni r0.z, r0.z
add r0.z, -r0.z, l(1.000000)
mul r0.x, r0.z, r0.x
mul r0.x, r0.x, r0.y
exp r0.x, -|r0.x|
mad o3.x, -r0.x, r0.x, l(1.000000)
ret
// Approximately 0 instruction slots used