//needs to be edited
// 3DMigoto: ec438fa268f752c1 |    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 128839
//          Program "fp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 95
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Internal-PrePassCollectShadows.shader.decompressed:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 59 1 0
//   Keywords { "SHADOWS_SPLIT_SPHERES" "SHADOWS_NATIVE" "SHADOWS_SINGLE_CASCADE" }
//   undeciphered2: 1 2 4 2 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 128
//   Vector 112 [_ShadowMapTexture_TexelSize]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 112 [_ZBufferParams]
//   Vector 128 [unity_OrthoParams]
//   ConstBuffer "UnityShadows" 416
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   Matrix 128 [unity_World2Shadow0]
//   Matrix 192 [unity_World2Shadow1]
//   Matrix 256 [unity_World2Shadow2]
//   Matrix 320 [unity_World2Shadow3]
//   ConstBuffer "UnityPerCamera2" 64
//   Matrix 0 [_CameraToWorld]
//   SetTexture 0 [_CameraDepthTexture] 2D 0
//   SetTexture 1 [_ShadowMapTexture] 2D 1
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityShadows" 2
//   BindCB "UnityPerCamera2" 3
//
// Headers extracted with DarkStarSword's extract_unity53_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity53_shaders.py

// ---- Created with 3Dmigoto v1.2.38 on Mon Sep 12 06:51:26 2016
Texture2D<float4> t1 : register(t1);

Texture2D<float4> t0 : register(t0);

SamplerComparisonState s1_s : register(s1);

SamplerState s0_s : register(s0);

cbuffer cb3 : register(b3)
{
  float4 cb3[4];
}

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

cbuffer cb1 : register(b1)
{
  float4 cb1[9];
}

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




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


void main( 
  float4 v0 : TEXCOORD0,
  float4 v1 : TEXCOORD1,
  float4 v2 : TEXCOORD2,
  float3 v3 : TEXCOORD3,
float fov : TEXCOORD4, // New input from vertex shader with unity_CameraInvProjection[0].x;
  float4 v4 : SV_POSITION0,
  out float4 o0 : SV_Target0)
{
  float4 r0,r1,r2,r3,r4,r5,r6,r7;
  uint4 bitmask, uiDest;
  float4 fDest;

  r0.xz = cb0[7].yy;
  r0.y = 0.142857149;
  r1.xyzw = t0.Sample(s0_s, v0.xy).xyzw;
  r0.w = cb1[7].x * r1.x + cb1[7].y;
  r0.w = 1 / r0.w;
  r1.y = r1.x + -r0.w;
  r0.w = cb1[8].w * r1.y + r0.w;

float depth = r1.z;

  r1.yzw = v3.xyz + -v2.xyz;
  r1.xyz = r1.xxx * r1.yzw + v2.xyz;
  r1.xyz = -v1.xyz * r0.www + r1.xyz;
  r2.xyz = v1.xyz * r0.www;
  r1.xyz = cb1[8].www * r1.xyz + r2.xyz;

float4 stereo = StereoParams.Load(0);
float separation = stereo.x; float convergence = stereo.y;
//r1.x -= separation * (depth - convergence) * fov;

  r2.xyzw = cb3[1].xyzw * r1.yyyy;
  r2.xyzw = cb3[0].xyzw * r1.xxxx + r2.xyzw;
  r1.xyzw = cb3[2].xyzw * r1.zzzz + r2.xyzw;
  r1.xyzw = cb3[3].xyzw + r1.xyzw;
  r2.xyz = cb2[9].xyz * r1.yyy;
  r2.xyz = cb2[8].xyz * r1.xxx + r2.xyz;
  r2.xyz = cb2[10].xyz * r1.zzz + r2.xyz;
  r2.xyz = cb2[11].xyz * r1.www + r2.xyz;
  r1.xyz = -cb2[25].xyz + r1.xyz;
  r0.w = dot(r1.xyz, r1.xyz);
  r0.w = sqrt(r0.w);
  r0.w = saturate(r0.w * cb2[24].z + cb2[24].w);
  r1.xy = r2.xy * cb0[7].zw + float2(0.5,0.5);
  r1.zw = frac(r1.xy);
  r1.xy = floor(r1.xy);
  r1.xy = float2(-0.5,-0.5) + r1.xy;
  r2.xy = -r1.zw * float2(2,2) + float2(3,3);
  r3.xy = -r1.zw * float2(3,3) + float2(4,4);
  r2.xy = r2.xy / r3.xy;
  r4.xy = float2(-2,-2) + r2.xy;
  r5.z = r4.y;
  r2.xy = r1.zw * float2(3,3) + float2(1,1);
  r2.xw = r1.zw / r2.xy;
  r5.xw = float2(2,2) + r2.xw;
  r4.w = r5.x;
  r2.xw = float2(3,3) + r1.zw;
  r1.z = 3 * r1.z;
  r6.xz = r1.zz * float2(-1,1) + float2(4,1);
  r5.xy = cb0[7].xy * r2.xw;
  r7.xyz = r5.zyw * r0.xyz;
  r4.z = r5.x;
  r5.w = r7.x;
  r0.xz = cb0[7].xx;
  r0.y = 0.142857149;
  r5.xyz = r4.zxw * r0.yxz;
  r4.xyzw = r1.xyxy * cb0[7].xyxy + r5.ywxw;
  r0.xy = r1.xy * cb0[7].xy + r5.zw;
  r0.x = t1.SampleCmpLevelZero(s1_s, r0.xy, r2.z).x;
  r0.y = t1.SampleCmpLevelZero(s1_s, r4.xy, r2.z).x;
  r0.z = t1.SampleCmpLevelZero(s1_s, r4.zw, r2.z).x;
  r6.y = 7;
  r3.xyz = r6.xyz * r3.yyy;
  r2.xyw = r6.xyz * r2.yyy;
  r1.zw = float2(7,7) * r6.xz;
  r0.z = r3.y * r0.z;
  r0.y = r3.x * r0.y + r0.z;
  r0.x = r3.z * r0.x + r0.y;
  r7.w = r5.y;
  r3.xyzw = r1.xyxy * cb0[7].xyxy + r7.wywz;
  r5.yw = r7.yz;
  r0.y = t1.SampleCmpLevelZero(s1_s, r3.xy, r2.z).x;
  r0.z = t1.SampleCmpLevelZero(s1_s, r3.zw, r2.z).x;
  r0.x = r1.z * r0.y + r0.x;
  r3.xyzw = r1.xyxy * cb0[7].xyxy + r5.xyzy;
  r4.xyzw = r1.xyxy * cb0[7].xyxy + r5.xwzw;
  r0.y = t1.SampleCmpLevelZero(s1_s, r3.xy, r2.z).x;
  r1.x = t1.SampleCmpLevelZero(s1_s, r3.zw, r2.z).x;
  r0.x = r0.y * 49 + r0.x;
  r0.x = r1.w * r1.x + r0.x;
  r0.x = r2.x * r0.z + r0.x;
  r0.y = t1.SampleCmpLevelZero(s1_s, r4.xy, r2.z).x;
  r0.z = t1.SampleCmpLevelZero(s1_s, r4.zw, r2.z).x;
  r0.x = r2.y * r0.y + r0.x;
  r0.x = r2.w * r0.z + r0.x;
  r0.x = 0.0069444445 * r0.x;
  r0.y = 1 + -cb2[24].x;
  r0.x = r0.x * r0.y + cb2[24].x;
  o0.xyzw = r0.xxxx + r0.wwww;
  return;
}