// asmtool.py -I ../.. --fix-unity-lighting-ps=TEXCOORD4 --only-autofixed 60d16875680b749f-ps.txt
// 3DMigoto: 60d16875680b749f |    Unity headers extracted from Internal-ScreenSpaceShadows.shader
//    Shader "Hidden/Internal-ScreenSpaceShadows" {
//      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 88306
//          Program "fp" {
//            SubProgram "d3d11 " {
//              GpuProgramIndex 9
//            }
//          }
//        }
//      }
//    }
//
// Unity 5.3 headers extracted from Internal-ScreenSpaceShadows.shader.decompressed:
//   API d3d11
//   Shader model ps_4_0
//   undeciphered1: 201510240 87 1 0
//   Keywords { "SHADOWS_SPLIT_SPHERES" }
//   undeciphered2: 1 2 4 2 0 0
//   undeciphered3: 0 0
//   ConstBuffer "$Globals" 128
//   Vector 112 [_ShadowMapTexture_TexelSize]
//   ConstBuffer "UnityPerCamera" 144
//   Vector 112 [_ZBufferParams]
//   Vector 128 [unity_OrthoParams]
//   ConstBuffer "UnityPerCameraRare" 352
//   Matrix 288 [unity_CameraToWorld]
//   ConstBuffer "UnityShadows" 416
//   Vector 0 [unity_ShadowSplitSpheres0]
//   Vector 16 [unity_ShadowSplitSpheres1]
//   Vector 32 [unity_ShadowSplitSpheres2]
//   Vector 48 [unity_ShadowSplitSpheres3]
//   Vector 64 [unity_ShadowSplitSqRadii]
//   Vector 384 [_LightShadowData]
//   Vector 400 [unity_ShadowFadeCenterAndType]
//   Matrix 128 [unity_WorldToShadow0]
//   Matrix 192 [unity_WorldToShadow1]
//   Matrix 256 [unity_WorldToShadow2]
//   Matrix 320 [unity_WorldToShadow3]
//   SetTexture 0 [_CameraDepthTexture] 2D 0
//   SetTexture 1 [_ShadowMapTexture] 2D 1
//   BindCB "$Globals" 0
//   BindCB "UnityPerCamera" 1
//   BindCB "UnityPerCameraRare" 2
//   BindCB "UnityShadows" 3
//
// 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.12 on Thu Dec 06 16:58:53 2018
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// TEXCOORD                 0   xy          0     NONE   float   xy
// TEXCOORD                 1   xyz         1     NONE   float   xyz
// TEXCOORD                 2   xyz         2     NONE   float   xyz
// TEXCOORD                 3   xyz         3     NONE   float   xyz
// TEXCOORD                 4      w        3     NONE   float      w
// SV_POSITION              0   xyzw        4      POS   float
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_4_0
dcl_constantbuffer cb0[8], immediateIndexed
dcl_constantbuffer cb1[9], immediateIndexed
dcl_constantbuffer cb2[22], immediateIndexed
dcl_constantbuffer cb3[26], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v0.xy
dcl_input_ps linear v1.xyz
dcl_input_ps linear v2.xyz
dcl_input_ps linear v3.xyz
dcl_output o0.xyzw
dcl_temps 11

// New input from vertex shader with unity_CameraInvProjection[0].x:
dcl_input_ps linear v3.w
dcl_constantbuffer cb10[4], immediateIndexed

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

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

sample r0.xyzw, v0.xyxx, t0.xyzw, s0
mad r0.y, cb1[7].x, r0.x, cb1[7].y
div r0.y, l(1.000000, 1.000000, 1.000000, 1.000000), r0.y
add r0.z, -r0.y, r0.x
mad r0.y, cb1[8].w, r0.z, r0.y
add r1.xyz, -v2.xyzx, v3.xyzx
mad r0.xzw, r0.xxxx, r1.xxyz, v2.xxyz
mad r0.xzw, -v1.xxyz, r0.yyyy, r0.xxzw
mul r1.xyz, r0.yyyy, v1.xyzx
mad r0.xyz, cb1[8].wwww, r0.xzwx, r1.xyzx

// copy depth from r0.z to r9.x:
mov r9.x, r0.z


// Unity light/shadow fix (pixel shader stage) inserted with DarkStarSword's asmtool.py:
// asmtool.py -I ../.. --fix-unity-lighting-ps=TEXCOORD4 --only-autofixed 60d16875680b749f-ps.txt

add r10.x, r9.x, -r8.y
mul r10.x, r8.x, r10.x
ne r8.w, l(0.0, 0.0, 0.0, 0.0), v3.w
if_nz r8.w
  mad r0.x, -r10.x, v3.w, r0.x
endif

mul r1.xyzw, r0.yyyy, cb2[19].xyzw
mad r1.xyzw, cb2[18].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb2[20].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb2[21].xyzw

if_z r8.w
  mad r0.xyz, -r10.xxxx, cb10[0].xyzx, r0.xyzw
endif

add r1.xyz, r0.xyzx, -cb3[0].xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
add r2.xyz, r0.xyzx, -cb3[1].xyzx
dp3 r1.y, r2.xyzx, r2.xyzx
add r2.xyz, r0.xyzx, -cb3[2].xyzx
dp3 r1.z, r2.xyzx, r2.xyzx
add r2.xyz, r0.xyzx, -cb3[3].xyzx
dp3 r1.w, r2.xyzx, r2.xyzx
lt r1.xyzw, r1.xyzw, cb3[4].xyzw
movc r2.xyz, r1.xyzx, l(-1.000000,-1.000000,-1.000000,0), l(-0.000000,-0.000000,-0.000000,0)
and r1.xyzw, r1.xyzw, l(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000)
add r1.yzw, r2.xxyz, r1.yyzw
max r1.yzw, r1.yyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
mul r2.xyz, r0.yyyy, cb3[13].xyzx
mad r2.xyz, cb3[12].xyzx, r0.xxxx, r2.xyzx
mad r2.xyz, cb3[14].xyzx, r0.zzzz, r2.xyzx
mad r2.xyz, cb3[15].xyzx, r0.wwww, r2.xyzx
mul r2.xyz, r1.yyyy, r2.xyzx
mul r3.xyz, r0.yyyy, cb3[9].xyzx
mad r3.xyz, cb3[8].xyzx, r0.xxxx, r3.xyzx
mad r3.xyz, cb3[10].xyzx, r0.zzzz, r3.xyzx
mad r3.xyz, cb3[11].xyzx, r0.wwww, r3.xyzx
mad r2.xyz, r3.xyzx, r1.xxxx, r2.xyzx
mul r3.xyz, r0.yyyy, cb3[17].xyzx
mad r3.xyz, cb3[16].xyzx, r0.xxxx, r3.xyzx
mad r3.xyz, cb3[18].xyzx, r0.zzzz, r3.xyzx
mad r3.xyz, cb3[19].xyzx, r0.wwww, r3.xyzx
mad r1.xyz, r3.xyzx, r1.zzzz, r2.xyzx
mul r2.xyz, r0.yyyy, cb3[21].xyzx
mad r2.xyz, cb3[20].xyzx, r0.xxxx, r2.xyzx
mad r2.xyz, cb3[22].xyzx, r0.zzzz, r2.xyzx
mad r2.xyz, cb3[23].xyzx, r0.wwww, r2.xyzx
add r0.xyz, r0.xyzx, -cb3[25].xyzx
dp3 r0.x, r0.xyzx, r0.xyzx
sqrt r0.x, r0.x
mad_sat r0.x, r0.x, cb3[24].z, cb3[24].w
mad r0.yzw, r2.xxyz, r1.wwww, r1.xxyz
mad r0.yz, r0.yyzy, cb0[7].zzwz, l(0.000000, 0.500000, 0.500000, 0.000000)
round_ni r1.xy, r0.yzyy
frc r0.yz, r0.yyzy
add r1.xy, r1.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
mad r1.zw, -r0.yyyz, l(0.000000, 0.000000, 2.000000, 2.000000), l(0.000000, 0.000000, 3.000000, 3.000000)
mad r2.xy, -r0.yzyy, l(3.000000, 3.000000, 0.000000, 0.000000), l(4.000000, 4.000000, 0.000000, 0.000000)
div r1.zw, r1.zzzw, r2.xxxy
add r3.xy, r1.zwzz, l(-2.000000, -2.000000, 0.000000, 0.000000)
mov r4.z, r3.y
mad r1.zw, r0.yyyz, l(0.000000, 0.000000, 3.000000, 3.000000), l(0.000000, 0.000000, 1.000000, 1.000000)
div r2.xz, r0.yyzy, r1.zzwz
add r4.xw, r2.xxxz, l(2.000000, 0.000000, 0.000000, 2.000000)
mov r3.w, r4.x
add r2.xz, r0.yyzy, l(3.000000, 0.000000, 3.000000, 0.000000)
mul r0.y, r0.y, l(3.000000)
mad r5.xz, r0.yyyy, l(-1.000000, 0.000000, 1.000000, 0.000000), l(4.000000, 0.000000, 1.000000, 0.000000)
mul r4.xy, r2.xzxx, cb0[7].xyxx
mov r6.xz, cb0[7].yyyy
mov r6.y, l(0.142857149)
mul r6.xyz, r4.zywz, r6.xyzx
mov r3.z, r4.x
mov r4.w, r6.x
mov r7.xz, cb0[7].xxxx
mov r7.y, l(0.142857149)
mul r4.xyz, r3.zxwz, r7.yxzy
mad r3.xyzw, r1.xyxy, cb0[7].xyxy, r4.ywxw
mad r0.yz, r1.xxyx, cb0[7].xxyx, r4.zzwz
sample_c_lz r0.y, r0.yzyy, t1.xxxx, s1, r0.w
sample_c_lz r0.z, r3.xyxx, t1.xxxx, s1, r0.w
sample_c_lz r1.z, r3.zwzz, t1.xxxx, s1, r0.w
mov r5.y, l(7.000000)
mul r2.xyz, r2.yyyy, r5.xyzx
mul r3.xyz, r1.wwww, r5.xyzx
mul r5.xy, r5.xzxx, l(7.000000, 7.000000, 0.000000, 0.000000)
mul r1.z, r1.z, r2.y
mad r0.z, r2.x, r0.z, r1.z
mad r0.y, r2.z, r0.y, r0.z
mov r6.w, r4.y
mad r2.xyzw, r1.xyxy, cb0[7].xyxy, r6.wywz
mov r4.yw, r6.yyyz
sample_c_lz r0.z, r2.xyxx, t1.xxxx, s1, r0.w
sample_c_lz r1.z, r2.zwzz, t1.xxxx, s1, r0.w
mad r0.y, r5.x, r0.z, r0.y
mad r2.xyzw, r1.xyxy, cb0[7].xyxy, r4.xyzy
mad r4.xyzw, r1.xyxy, cb0[7].xyxy, r4.xwzw
sample_c_lz r0.z, r2.xyxx, t1.xxxx, s1, r0.w
sample_c_lz r1.x, r2.zwzz, t1.xxxx, s1, r0.w
mad r0.y, r0.z, l(49.000000), r0.y
mad r0.y, r5.y, r1.x, r0.y
mad r0.y, r3.x, r1.z, r0.y
sample_c_lz r0.z, r4.xyxx, t1.xxxx, s1, r0.w
sample_c_lz r0.w, r4.zwzz, t1.xxxx, s1, r0.w
mad r0.y, r3.y, r0.z, r0.y
mad r0.y, r3.z, r0.w, r0.y
mul r0.y, r0.y, l(0.00694444450)
add r0.z, -cb3[24].x, l(1.000000)
mad r0.y, r0.y, r0.z, cb3[24].x
add o0.xyzw, r0.xxxx, r0.yyyy
ret
// Approximately 0 instruction slots used