// Primary shadow shader, affects all three main variants. 
// The on ground shadows, directional shadows seem fixed without having to do anything.
// Not sure why. 
// This is following the new-DX9 strategy, but it does not seem to work
// correctly on this game.
// Disabling it here via back-snick key, default off.  Disabling here keeps the lights
// on, but disables shadows.

// CRC32: 00933666 | Matched 4 variants of 1 shaders: Hidden/Internal-PrePassCollectShadows
// 
//    Unity headers extracted from Internal-PrePassCollectShadows.shader
//    Shader "Hidden/Internal-PrePassCollectShadows" {
//      Properties {
//       _ShadowMapTexture ("", any) = "" { }
//      }
//      Fallback Off
//      SubShader 2/2 {
//        Tags { "ShadowmapFilter"="PCF_5x5" }
//        Pass 1/1 {
//          Tags { "ShadowmapFilter"="PCF_5x5" }
//          ZTest Always
//          ZWrite Off
//          Cull Off
//          GpuProgramID 97017
//          Program "vp" {
//            SubProgram "d3d9 " {
// 8:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SINGLE_CASCADE" "SHADOWS_SPLIT_SPHERES" }
// 4:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SINGLE_CASCADE" }
// 2:           Keywords { "SHADOWS_NATIVE" "SHADOWS_SPLIT_SPHERES" }
// 1:           Keywords { "SHADOWS_NATIVE" }
//              Bind "vertex" Vertex
//              Bind "normal" Normal
//              Bind "texcoord" TexCoord0
//              Matrix 0 [glstate_matrix_mvp]
//              Matrix 4 [unity_CameraInvProjection] 3
//              Vector 7 [_ProjectionParams]
//            }
//          }
//        }
//      }
//    }
// 
// Headers extracted with DarkStarSword's extract_unity_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity_shaders.py

    vs_3_0
    def c8, -1, 1, 0, 0
    dcl_position v0
    dcl_texcoord v1
    dcl_normal v2
    dcl_texcoord o0.xy
    dcl_texcoord1 o1.xyz
    dcl_texcoord2 o2
    dcl_position o3

def c220, 0, 1, 0.0625, 0.00
dcl_2d s0

dcl_texcoord5 o5.x // New output to pass FOV from inverse projection matrix to pixel shaders

    dp4 o3.z, c2, v0
    dp4 o3.w, c3, v0
    dp4 r0.x, c1, v0
    mul r1.y, r0.x, c7.x
    mov o3.y, r0.x
    mov r1.zw, c8.xyxy
    dp4 r1.x, c0, v0
    dp4 o2.x, c4, r1
    dp4 o2.y, c5, r1
    dp4 r0.x, c6, r1
    dp4 r0.y, c6, r1.xyww
    mov o3.x, r1.x
    mov o2.zw, -r0.xyxy

    mov o0.xy, v1
    mov o1.xyz, v2

    
// Pass the inverse projection matrix to the pixel shaders to fix the directional shadows
mov o5.x, c4.x


// enable or disable shadows. On command, default "`"

mov r30.x, c200.x
if_eq r30.x, c33.w
  mov o3.xyzw, c220.xxxx
endif

