// 3DMigoto: b78925705424e647 | Matched 8 variants of 1 shaders: Hidden/Internal-PrePassCollectShadows
// 
//     Unity headers extracted from Internal-PrePassCollectShadows.shader
//     Shader "Hidden/Internal-PrePassCollectShadows" {
//       Properties {
//        _ShadowMapTexture ("", any) = "" { }
//       }
//       Fallback Off
// 0f:   SubShader 1/2 {
// f0:   SubShader 2/2 {
// f0:     Tags { "ShadowmapFilter"="PCF_5x5" }
//         Pass 1/1 {
// f0:       Tags { "ShadowmapFilter"="PCF_5x5" }
//           ZTest Always
//           ZWrite Off
//           Cull Off
// 0f:       GpuProgramID 58189
// f0:       GpuProgramID 97017
//           Program "vp" {
//             SubProgram "d3d11 " {
// 88:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SINGLE_CASCADE" "SHADOWS_SPLIT_SPHERES" }
// 44:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SINGLE_CASCADE" }
// 22:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SPLIT_SPHERES" }
// 11:           Keywords { "SHADOWS_NATIVE" }
//               Bind "vertex" Vertex
//               Bind "normal" Normal
//               Bind "texcoord" TexCoord0
//               ConstBuffer "UnityPerCamera" 144
//               Vector 80 [_ProjectionParams]
//               ConstBuffer "UnityPerCameraRare" 224
//               Matrix 160 [unity_CameraInvProjection]
//               ConstBuffer "UnityPerDraw" 336
//               Matrix 0 [glstate_matrix_mvp]
//               BindCB "UnityPerCamera" 0
//               BindCB "UnityPerCameraRare" 1
//               BindCB "UnityPerDraw" 2
//             }
//           }
//         }
//       }
//     }
// 
// Headers extracted with DarkStarSword's extract_unity_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity_shaders.py
//
// Shader model vs_4_0

cbuffer cb2 : register(b2)
{
  float4 cb2[4];
}

// UnityPerCameraRare contains the projection & inverse projection matrices
// that we need to fix the shadows. The headers extracted from the asset files
// show which constant buffer is UnityPerCameraRare, and then we just grab the
// actual definition of the buffer from the Unity Cg source code, and replace
// references to it as necessary.

// cbuffer cb1 : register(b1)
cbuffer UnityPerCameraRare : register(b1)
{
  // float4 cb1[14];
  uniform float4 unity_CameraWorldClipPlanes[6];

  // Projection matrices of the camera. Note that this might be different from projection matrix
  // that is set right now, e.g. while rendering shadows the matrices below are still the projection
  // of original camera.
  row_major uniform float4x4 unity_CameraProjection;	//  cb1[7] - cb1[10]
  row_major uniform float4x4 unity_CameraInvProjection;	// cb1[11] - cb1[14]
}

cbuffer cb0 : register(b0)
{
  float4 cb0[6];
}




// 3Dmigoto declarations
#define cmp -
Texture1D<float4> IniParams : register(t120);
Texture2D<float4> StereoParams : register(t125);


void main( 
  float4 v0 : POSITION0,
  float2 v1 : TEXCOORD0,
  float3 v2 : NORMAL0,
  out float4 o0 : TEXCOORD0,
  out float4 o1 : TEXCOORD1,
  out float4 o2 : TEXCOORD2,
  out float4 o3 : SV_POSITION0,
  out float fov : TEXCOORD3) // New output to pass FOV from inverse projection matrix to pixel shaders
{
  float4 r0,r1;
  uint4 bitmask, uiDest;
  float4 fDest;

  o0.xy = v1.xy;
  o1.xyz = v2.xyz;
  r0.xyzw = cb2[1].xyzw * v0.yyyy;
  r0.xyzw = cb2[0].xyzw * v0.xxxx + r0.xyzw;
  r0.xyzw = cb2[2].xyzw * v0.zzzz + r0.xyzw;
  r0.xyzw = cb2[3].xyzw * v0.wwww + r0.xyzw;
  r1.x = cb0[5].x * r0.y;
  r1.xyz = unity_CameraInvProjection[0].xyz * r1.xxx;
  r1.xyz = unity_CameraProjection[3].xyz * r0.xxx + r1.xyz;
  o3.xyzw = r0.xyzw;
  r0.x = unity_CameraInvProjection[1].z + r1.z;
  r0.yzw = -unity_CameraInvProjection[1].xyz + r1.xyz;
  r0.xyzw = unity_CameraInvProjection[2].zxyz + r0.xyzw;
  o2.xyz = float3(1,1,-1) * r0.yzw;
  o2.w = -r0.x;

fov = unity_CameraInvProjection[0].x;

  return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Original ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) D3D Shader Disassembler
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy  
// NORMAL                   0   xyz         2     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1   xyz         1     NONE   float   xyz 
// TEXCOORD                 2   xyzw        2     NONE   float   xyzw
// SV_POSITION              0   xyzw        3      POS   float   xyzw
//
vs_4_0
dcl_constantbuffer cb0[6], immediateIndexed
dcl_constantbuffer cb1[14], immediateIndexed
dcl_constantbuffer cb2[4], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xy
dcl_input v2.xyz
dcl_output o0.xy
dcl_output o1.xyz
dcl_output o2.xyzw
dcl_output_siv o3.xyzw, position
dcl_temps 2
mov o0.xy, v1.xyxx
mov o1.xyz, v2.xyzx
mul r0.xyzw, v0.yyyy, cb2[1].xyzw
mad r0.xyzw, cb2[0].xyzw, v0.xxxx, r0.xyzw
mad r0.xyzw, cb2[2].xyzw, v0.zzzz, r0.xyzw
mad r0.xyzw, cb2[3].xyzw, v0.wwww, r0.xyzw
mul r1.x, r0.y, cb0[5].x
mul r1.xyz, r1.xxxx, cb1[11].xyzx
mad r1.xyz, cb1[10].xyzx, r0.xxxx, r1.xyzx
mov o3.xyzw, r0.xyzw
add r0.x, r1.z, cb1[12].z
add r0.yzw, r1.xxyz, -cb1[12].xxyz
add r0.xyzw, r0.xyzw, cb1[13].zxyz
mul o2.xyz, r0.yzwy, l(1.000000, 1.000000, -1.000000, 0.000000)
mov o2.w, -r0.x
ret 
// Approximately 0 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Recompiled ASM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20789
//
//
// Buffer Definitions: 
//
// cbuffer cb2
// {
//
//   float4 cb2[4];                     // Offset:    0 Size:    64
//
// }
//
// cbuffer cb1
// {
//
//   float4 cb1[14];                    // Offset:    0 Size:   224
//
// }
//
// cbuffer cb0
// {
//
//   float4 cb0[6];                     // Offset:    0 Size:    96
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// cb0                               cbuffer      NA          NA    0        1
// cb1                               cbuffer      NA          NA    1        1
// cb2                               cbuffer      NA          NA    2        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// POSITION                 0   xyzw        0     NONE   float   xyzw
// TEXCOORD                 0   xy          1     NONE   float   xy  
// NORMAL                   0   xyz         2     NONE   float   xyz 
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy  
// TEXCOORD                 1   xyz         1     NONE   float   xyz 
// TEXCOORD                 2   xyzw        2     NONE   float   xyzw
// SV_POSITION              0   xyzw        3      POS   float   xyzw
//
vs_4_0
dcl_constantbuffer cb2[4], immediateIndexed
dcl_constantbuffer cb1[14], immediateIndexed
dcl_constantbuffer cb0[6], immediateIndexed
dcl_input v0.xyzw
dcl_input v1.xy
dcl_input v2.xyz
dcl_output o0.xy
dcl_output o1.xyz
dcl_output o2.xyzw
dcl_output_siv o3.xyzw, position
dcl_temps 2
mov o0.xy, v1.xyxx
mov o1.xyz, v2.xyzx
mul r0.xyzw, v0.yyyy, cb2[1].xyzw
mad r0.xyzw, cb2[0].xyzw, v0.xxxx, r0.xyzw
mad r0.xyzw, cb2[2].xyzw, v0.zzzz, r0.xyzw
mad r0.xyzw, cb2[3].xyzw, v0.wwww, r0.xyzw
mul r1.x, r0.y, cb0[5].x
mul r1.xyz, r1.xxxx, cb1[11].xyzx
mad r1.xyz, cb1[10].xyzx, r0.xxxx, r1.xyzx
mov o3.xyzw, r0.xyzw
add r0.x, r1.z, cb1[12].z
add r0.yzw, r1.xxyz, -cb1[12].xxyz
add r0.xyzw, r0.xyzw, cb1[13].zxyz
mul o2.xyz, r0.yzwy, l(1.000000, 1.000000, -1.000000, 0.000000)
mov o2.w, -r0.x
ret 
// Approximately 16 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
