// asmtool.py -I ../.. --auto-fix-vertex-halo --fix-unusual-halo-with-inconsistent-w-optimisation --fix-unity-reflection --fix-unity-frustum-world --only-autofixed 44dc368c60db8a36-vs.txt
// 3DMigoto: 44dc368c60db8a36 | Matched 4 variants of 1 shaders: Hidden/TerrainEngine/Details/WavingDoublePass
//
//       Unity headers extracted from Hidden_TerrainEngine_Details_WavingDoublePass
//       Shader "Hidden/TerrainEngine/Details/WavingDoublePass" {
//         SubShader 1/2 {
//           LOD 200
//           Tags { "DisableBatching"="true" "IGNOREPROJECTOR"="true" "QUEUE"="Geometry+200" "RenderType"="Grass" }
//           Pass 1/6 {
//             Name "FORWARD"
//             Tags { "DisableBatching"="true" "IGNOREPROJECTOR"="true" "LIGHTMODE"="FORWARDBASE" "QUEUE"="Geometry+200" "RenderType"="Grass" "SHADOWSUPPORT"="true" }
//             Program "vp" {
//               SubProgram "d3d11" {
//               }
//             }
//           }
//         }
//       }
//
//    Unity 5.3 headers extracted from Hidden_TerrainEngine_Details_WavingDoublePass:
//      API d3d11
//      Shader model vs_4_0
//      undeciphered1: 201609010 52 0 0
//      undeciphered1a: 4
// 8:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" "VERTEXLIGHT_ON" }
// 2:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DIRLIGHTMAP_COMBINED" "DYNAMICLIGHTMAP_ON" }
// 4:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_ON" "VERTEXLIGHT_ON" }
// 1:   Keywords { "DIRECTIONAL" "SHADOWS_SCREEN" "DYNAMICLIGHTMAP_ON" }
//      undeciphered2: 1 0 6 0 0 0
//      undeciphered3: 47 5 0 0 1 2 3 4 5 6 2 1
//      ConstBuffer "$Globals" 1136
//      Vector 1120 [_MainTex_ST]
//      ConstBuffer "UnityPerCamera" 144
//      Vector 80 [_ProjectionParams]
//      ConstBuffer "UnityPerDraw" 160
//      Matrix 0 [unity_ObjectToWorld]
//      Matrix 64 [unity_WorldToObject]
//      ConstBuffer "UnityPerFrame" 384
//      Matrix 272 [unity_MatrixVP]
//      ConstBuffer "UnityLightmaps" 32
//      Vector 16 [unity_DynamicLightmapST]
//      ConstBuffer "UnityTerrain" 272
//      Vector 0 [_WavingTint]
//      Vector 16 [_WaveAndDistance]
//      Vector 32 [_CameraPosition]
//      BindCB "$Globals" 0
//      BindCB "UnityPerCamera" 1
//      BindCB "UnityPerDraw" 2
//      BindCB "UnityPerFrame" 3
//      BindCB "UnityLightmaps" 4
//      BindCB "UnityTerrain" 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:54:48 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   xy
// TEXCOORD                 3   xyzw        6     NONE   float
// COLOR                    0   xyzw        7     NONE   float   xyzw
//
//
// 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   xyz         2     NONE   float   xyz
// TEXCOORD                 2   xyz         3     NONE   float   xyz
// COLOR                    0   xyzw        4     NONE   float   xyzw
// TEXCOORD                 4   xyzw        5     NONE   float   xyzw
// TEXCOORD                 6   xyzw        6     NONE   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[71], immediateIndexed
dcl_constantbuffer cb1[6], immediateIndexed
dcl_constantbuffer cb2[7], immediateIndexed
dcl_constantbuffer cb3[21], immediateIndexed
dcl_constantbuffer cb4[2], immediateIndexed
dcl_constantbuffer cb5[3], immediateIndexed
dcl_input v0.xyzw
dcl_input v2.xyz
dcl_input v3.xy
dcl_input v5.xy
dcl_input v7.xyzw
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_output o2.xyz
dcl_output o3.xyz
dcl_output o4.xyzw
dcl_output o5.xyzw
dcl_output o6.xyzw
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

mul r0.xy, v0.xzxx, cb5[1].yyyy
mul r1.xyzw, r0.yyyy, l(0.006000, 0.020000, 0.020000, 0.050000)
mad r0.xyzw, r0.xxxx, l(0.012000, 0.020000, 0.060000, 0.024000), r1.xyzw
mad r0.xyzw, cb5[1].xxxx, l(1.200000, 2.000000, 1.600000, 4.800000), r0.xyzw
frc r0.xyzw, r0.xyzw
mad r0.xyzw, r0.xyzw, l(6.408849, 6.408849, 6.408849, 6.408849), l(-3.14159274, -3.14159274, -3.14159274, -3.14159274)
mul r1.xyzw, r0.xyzw, r0.xyzw
mul r2.xyzw, r0.xyzw, r1.xyzw
mad r0.xyzw, r2.xyzw, l(-0.161616161, -0.161616161, -0.161616161, -0.161616161), r0.xyzw
mul r2.xyzw, r1.xyzw, r2.xyzw
mul r1.xyzw, r1.xyzw, r2.xyzw
mad r0.xyzw, r2.xyzw, l(0.00833330024, 0.00833330024, 0.00833330024, 0.00833330024), r0.xyzw
mad r0.xyzw, r1.xyzw, l(-0.000198409994, -0.000198409994, -0.000198409994, -0.000198409994), r0.xyzw
mul r0.xyzw, r0.xyzw, r0.xyzw
mul r0.xyzw, r0.xyzw, r0.xyzw
mul r1.x, v7.w, cb5[1].z
mul r1.xyzw, r0.xyzw, r1.xxxx
dp4 r0.x, r0.xyzw, l(0.674199879, 0.674199879, 0.269679934, 0.134839967)
mul r0.x, r0.x, l(0.700000)
dp4 r2.x, r1.xyzw, l(0.024000, 0.040000, -0.120000, 0.096000)
dp4 r2.z, r1.xyzw, l(0.006000, 0.020000, -0.020000, 0.100000)
mad r1.xz, -r2.xxzx, cb5[1].zzzz, v0.xxzx
mul r2.xyzw, v0.yyyy, cb2[1].xyzw
mad r2.xyzw, cb2[0].xyzw, r1.xxxx, r2.xyzw
mad r2.xyzw, cb2[2].xyzw, r1.zzzz, r2.xyzw
add r3.xyzw, r2.xyzw, cb2[3].xyzw
mad o3.xyz, cb2[3].xyzx, v0.wwww, r2.xyzx
mul r2.xyzw, r3.yyyy, cb3[18].xyzw
mad r2.xyzw, cb3[17].xyzw, r3.xxxx, r2.xyzw
mad r2.xyzw, cb3[19].xyzw, r3.zzzz, r2.xyzw
mad r2.xyzw, cb3[20].xyzw, r3.wwww, r2.xyzw
mov o0.xyzw, r2.xyzw

// 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 44dc368c60db8a36-vs.txt
ne r4.w, r2.w, l(1.0)
if_nz r4.w
  add r4.w, r2.w, -r4.y
  mad r2.x, r4.w, r4.x, r2.x
endif

mad o1.xy, v3.xyxx, cb0[70].xyxx, cb0[70].zwzz
dp3 r3.x, v2.xyzx, cb2[4].xyzx
dp3 r3.y, v2.xyzx, cb2[5].xyzx
dp3 r3.z, v2.xyzx, cb2[6].xyzx
dp3 r0.y, r3.xyzx, r3.xyzx
rsq r0.y, r0.y
mul o2.xyz, r0.yyyy, r3.xyzx
mov r1.y, v0.y
add r0.yzw, r1.xxyz, -cb5[2].xxyz
dp3 r0.y, r0.yzwy, r0.yzwy
add r0.y, -r0.y, cb5[1].w
add r0.y, r0.y, r0.y
mul_sat o4.w, r0.y, cb5[2].w
add r0.yzw, cb5[0].xxyz, l(0.000000, -0.500000, -0.500000, -0.500000)
mad r0.xyz, r0.xxxx, r0.yzwy, l(0.500000, 0.500000, 0.500000, 0.000000)
mul r0.xyz, r0.xyzx, v7.xyzx
add o4.xyz, r0.xyzx, r0.xyzx
mul r0.x, r2.y, cb1[5].x
mul r0.w, r0.x, l(0.500000)
mul r0.xz, r2.xxwx, l(0.500000, 0.000000, 0.500000, 0.000000)
mov o5.zw, r2.zzzw
add o5.xy, r0.zzzz, r0.xwxx
mad o6.zw, v5.xxxy, cb4[1].xxxy, cb4[1].zzzw
mov o6.xy, l(0,0,0,0)
ret
// Approximately 0 instruction slots used