// Shadows
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.15 on Wed Mar 06 06:25:15 2019
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
//   float4 ambLit;                     // Offset:    0 Size:    16
//   row_major float4x4 mW2Pt;          // Offset:   16 Size:    64
//   float fPtn;                        // Offset:   80 Size:     4
//   row_major float4x4 mW2S[4];        // Offset:   96 Size:   256
//   float4 vSMOf[4];                   // Offset:  352 Size:    64
//   float4 vS2VZ;                      // Offset:  416 Size:    16
//   float4 vSMDF;                      // Offset:  432 Size:    16
//   bool bSM[3];                       // Offset:  448 Size:    36
//   float4 scSM;                       // Offset:  496 Size:    16
//   float4 scSM2;                      // Offset:  512 Size:    16
//   float4 sdplane;                    // Offset:  528 Size:    16
//   int nSubSdw;                       // Offset:  544 Size:     4
//   row_major float4x4 mSubW2S[4];     // Offset:  560 Size:   256
//   float4 scSubSM;                    // Offset:  816 Size:    16
//   row_major float4x4 mP2W;           // Offset:  832 Size:    64
//   float fDOFade;                     // Offset:  896 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// __smpsShadow                    sampler_c      NA          NA    0        1
// __smpsLit                         sampler      NA          NA    1        1
// __smpsSubShadow                 sampler_c      NA          NA    2        1
// sShadow                           texture  float4          2d    0        1
// sLit                              texture  float4          2d    1        1
// sSubShadow                        texture  float4     2darray    2        1
// sDepth                            texture  float4          2d    3        1
// $Globals                          cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   float   xy
// TEXCOORD                 0   xyzw        1     NONE   float   xy
//
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target                0   xyzw        0   TARGET   float   xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[57], dynamicIndexed
dcl_sampler s0, mode_comparison
dcl_sampler s1, mode_default
dcl_sampler s2, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2darray (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 15

// mP2W inversed with inverse-cs, i.e. mW2P
dcl_constantbuffer cb13[4], immediateIndexed

dcl_resource_texture2d (float,float,float,float) t121
ld_indexable(texture2d)(float,float,float,float) r12.xyzw, l(0, 0, 0, 0), t121.xyzw

ftoi r0.xy, v0.xyxx
mov r0.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.x, r0.xyzw, t3.xyzw
// mP2W
mul r1.xyzw, v1.yyyy, cb0[53].xyzw
mad r1.xyzw, v1.xxxx, cb0[52].xyzw, r1.xyzw
mad r0.xyzw, r0.xxxx, cb0[54].xyzw, r1.xyzw
add r0.xyzw, r0.xyzw, cb0[55].xyzw
div r0.xyzw, r0.xyzw, r0.wwww


if_nz cb13[0].x
	// mW2P
	mul r13.xyzw, r0.xxxx, cb13[0].xyzw
	mad r13.xyzw, r0.yyyy, cb13[1].xyzw, r13.xyzw
	mad r13.xyzw, r0.zzzz, cb13[2].xyzw, r13.xyzw
	add r13.xyzw, r13.xyzw, cb13[3].xyzw

	// Stereo correct
	add r12.w, r13.w, -r12.y
	mad r13.x, -r12.w, r12.x, r13.x

	// mP2W
	mul r14.xyzw, r13.xxxx, cb0[52].xyzw
	mad r14.xyzw, r13.yyyy, cb0[53].xyzw, r14.xyzw
	mad r14.xyzw, r13.zzzz, cb0[54].xyzw, r14.xyzw
	mad r14.xyzw, r13.wwww, cb0[55].xyzw, r14.xyzw
	div r0.xyzw, r14.xyzw, r14.wwww
endif


// mW2Pt
mul r1.xy, r0.yyyy, cb0[2].xyxx
mad r1.xy, r0.xxxx, cb0[1].xyxx, r1.xyxx
mad r1.xy, r0.zzzz, cb0[3].xyxx, r1.xyxx
mad r1.xy, r0.wwww, cb0[4].xyxx, r1.xyxx
if_nz cb0[28].x
  add r1.zw, v0.xxxy, l(0.000000, 0.000000, -0.500000, -0.500000)
  mul r2.xyzw, r0.yyyy, cb0[7].xyzw
  mad r2.xyzw, r0.xxxx, cb0[6].xyzw, r2.xyzw
  mad r2.xyzw, r0.zzzz, cb0[8].xyzw, r2.xyzw
  mad r2.xyzw, r0.wwww, cb0[9].xyzw, r2.xyzw
  mul r3.xyzw, r0.yyyy, cb0[11].xyzw
  mad r3.xyzw, r0.xxxx, cb0[10].xyzw, r3.xyzw
  mad r3.xyzw, r0.zzzz, cb0[12].xyzw, r3.xyzw
  mad r3.xyzw, r0.wwww, cb0[13].xyzw, r3.xyzw
  mul r4.xyzw, r0.yyyy, cb0[15].xyzw
  mad r4.xyzw, r0.xxxx, cb0[14].xyzw, r4.xyzw
  mad r4.xyzw, r0.zzzz, cb0[16].xyzw, r4.xyzw
  mad r4.xyzw, r0.wwww, cb0[17].xyzw, r4.xyzw
  mul r5.xyzw, r0.yyyy, cb0[19].xyzw
  mad r5.xyzw, r0.xxxx, cb0[18].xyzw, r5.xyzw
  mad r5.xyzw, r0.zzzz, cb0[20].xyzw, r5.xyzw
  mad r5.xyzw, r0.wwww, cb0[21].xyzw, r5.xyzw
  dp4 r6.x, r2.xyzw, cb0[26].xyzw
  lt r6.y, l(0.000000), r6.x
  movc r3.xyzw, r6.yyyy, r3.xyzw, r2.xyzw
  movc r7.xyzw, r6.yyyy, cb0[23].xyzw, cb0[22].xyzw
  add r6.xy, r6.xxxx, -cb0[27].xyxx
  lt r6.xy, l(0.000000, 0.000000, 0.000000, 0.000000), r6.xyxx
  movc r3.xyzw, r6.xxxx, r4.xyzw, r3.xyzw
  movc r4.xyzw, r6.xxxx, cb0[24].xyzw, r7.xyzw
  movc r3.xyzw, r6.yyyy, r5.zxyw, r3.zxyw
  movc r4.xyzw, r6.yyyy, cb0[25].xyzw, r4.xyzw
  mul r1.zw, r1.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000)
  add r1.w, r1.z, r1.w
  frc r5.xy, r1.zwzz
  if_nz cb0[30].x
    mad r1.zw, r5.xxxy, cb0[32].zzzw, cb0[32].xxxy
    add r6.zw, r1.zzzw, r3.yyyz
    ge r1.zw, r6.zzzw, l(0.000000, 0.000000, 1.000000, 1.000000)
    add r6.xy, r6.zwzz, cb0[32].zwzz
    ge r5.zw, l(0.000000, 0.000000, 0.000000, 0.000000), r6.xxxy
    or r1.z, r1.z, r5.z
    or r1.z, r1.w, r1.z
    or r1.z, r5.w, r1.z
    if_z r1.z
      mov_sat r7.xyzw, r6.zwxw
      mad r7.xyzw, r7.xyzw, r4.xyxy, r4.zwzw
      mov_sat r3.x, r3.x
      sample_c_lz_indexable(texture2d)(float,float,float,float) r1.z, r7.xyxx, t0.xxxx, s0, r3.x
      sample_c_lz_indexable(texture2d)(float,float,float,float) r1.w, r7.zwzz, t0.xxxx, s0, r3.x
      add r1.z, r1.w, r1.z
      mov_sat r6.xyzw, r6.zyxy
      mad r6.xyzw, r6.xyzw, r4.xyxy, r4.zwzw
      sample_c_lz_indexable(texture2d)(float,float,float,float) r1.w, r6.xyxx, t0.xxxx, s0, r3.x
      add r1.z, r1.w, r1.z
      sample_c_lz_indexable(texture2d)(float,float,float,float) r1.w, r6.zwzz, t0.xxxx, s0, r3.x
      add r1.z, r1.w, r1.z
      mad r1.z, -r1.z, l(0.250000), l(1.000000)
    else
      mov r1.z, l(0)
    endif
  else
    if_nz cb0[29].x
      add r6.xz, r3.zzyz, cb0[32].yyxy
      ge r5.zw, r6.zzzx, l(0.000000, 0.000000, 1.000000, 1.000000)
      mad r7.xy, cb0[31].xyxx, l(3.000000, 3.000000, 0.000000, 0.000000), r6.zxzz
      ge r7.xy, l(0.000000, 0.000000, 0.000000, 0.000000), r7.xyxx
      or r1.w, r5.z, r7.x
      or r1.w, r5.w, r1.w
      or r1.w, r7.y, r1.w
      if_z r1.w
        mov_sat r5.zw, r6.zzzx
        mad r5.zw, r5.zzzw, r4.xxxy, r4.zzzw
        mov_sat r3.x, r3.x
        sample_c_lz_indexable(texture2d)(float,float,float,float) r1.w, r5.zwzz, t0.xxxx, s0, r3.x
        add r6.yw, r6.xxxz, cb0[31].yyyx
        mov_sat r7.xyzw, r6.wxzy
        mad r7.xyzw, r7.xyzw, r4.xyxy, r4.zwzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r7.xyxx, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        add r8.xz, r6.wwyw, cb0[31].xxyx
        mov r8.yw, r6.xxxy
        mov_sat r9.xyzw, r8.xyxw
        mad r9.xyzw, r9.xyzw, r4.xyxy, r4.zwzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r9.xyxx, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        add r10.xy, r8.xzxx, cb0[31].xyxx
        mov r10.zw, r8.yyyw
        mov_sat r11.xyzw, r10.xzxw
        mad r11.xyzw, r11.xyzw, r4.xyxy, r4.zwzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r11.xyxx, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r7.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov_sat r5.zw, r6.wwwy
        mad r5.zw, r5.zzzw, r4.xxxy, r4.zzzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r5.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r9.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r11.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov r6.y, r8.z
        mov_sat r7.xyzw, r6.zywy
        mad r7.xyzw, r7.xyzw, r4.xyxy, r4.zwzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r7.xyxx, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r7.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov_sat r5.zw, r8.xxxz
        mad r5.zw, r5.zzzw, r4.xxxy, r4.zzzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r5.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov r6.x, r10.x
        mov_sat r6.xy, r6.xyxx
        mad r5.zw, r6.xxxy, r4.xxxy, r4.zzzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r5.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov r8.zw, r6.zzzw
        mov r8.y, r10.y
        mov_sat r6.xyzw, r8.zywy
        mad r6.xyzw, r6.xyzw, r4.xyxy, r4.zwzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.xyxx, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r6.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov_sat r8.xy, r8.xyxx
        mad r5.zw, r8.xxxy, r4.xxxy, r4.zzzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r5.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mov_sat r10.xy, r10.xyxx
        mad r5.zw, r10.xxxy, r4.xxxy, r4.zzzw
        sample_c_lz_indexable(texture2d)(float,float,float,float) r5.z, r5.zwzz, t0.xxxx, s0, r3.x
        add r1.w, r1.w, r5.z
        mad r1.z, -r1.w, l(0.062500), l(1.000000)
      else
        mov r1.z, l(0)
      endif
    else
      mov_sat r3.yz, r3.yyzy
      mad r3.yz, r3.yyzy, r4.xxyx, r4.zzwz
      div r3.yz, r3.yyzy, r3.wwww
      div_sat r1.w, r3.x, r3.w
      sample_c_lz_indexable(texture2d)(float,float,float,float) r1.w, r3.yzyy, t0.xxxx, s0, r1.w
      add r1.z, -r1.w, l(1.000000)
    endif
  endif
  mul r1.z, r1.z, cb0[0].w
  add r3.xy, cb0[51].xyxx, cb0[51].xyxx
  mul r3.zw, cb0[51].xxxy, l(0.000000, 0.000000, 1.500000, 1.500000)
  mad r3.xy, r5.xyxx, r3.xyxx, -r3.zwzz
  mov r1.w, cb0[29].x
  mov r3.z, cb0[30].x
  mov r3.w, r1.z
  mov r4.x, l(0)
  loop
    ige r4.y, r4.x, cb0[34].x
    breakc_nz r4.y
    ishl r4.y, r4.x, l(2)
    mul r5.xyz, r0.yyyy, cb0[r4.y + 36].xyzx
    mad r5.xyz, r0.xxxx, cb0[r4.y + 35].xyzx, r5.xyzx
    mad r5.xyz, r0.zzzz, cb0[r4.y + 37].xyzx, r5.xyzx
    mad r5.xyz, r0.wwww, cb0[r4.y + 38].zxyz, r5.zxyz
    if_nz r3.z
      add r6.xy, r3.xyxx, r5.yzyy
      ge r4.yz, r6.xxyx, l(0.000000, 1.000000, 1.000000, 0.000000)
      mad r7.xy, cb0[51].xyxx, l(2.000000, 2.000000, 0.000000, 0.000000), r6.xyxx
      ge r8.xy, l(0.000000, 0.000000, 0.000000, 0.000000), r7.xyxx
      or r4.y, r4.y, r8.x
      or r4.y, r4.z, r4.y
      or r4.y, r8.y, r4.y
      if_z r4.y
        itof r6.z, r4.x
        mov_sat r5.x, r5.x
        sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.y, r6.xyzx, t2.xxxx, s2, r5.x
        mov r7.zw, r6.yyyz
        sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.z, r7.xzwx, t2.xxxx, s2, r5.x
        add r4.y, r4.z, r4.y
        mov r6.w, r7.y
        sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.z, r6.xwzx, t2.xxxx, s2, r5.x
        add r4.y, r4.z, r4.y
        sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.z, r7.xywx, t2.xxxx, s2, r5.x
        add r4.y, r4.z, r4.y
        mad r4.y, -r4.y, l(0.250000), l(1.000000)
      else
        mov r4.y, l(0)
      endif
    else
      if_nz r1.w
        mad r6.xy, -cb0[51].xyxx, l(1.500000, 1.500000, 0.000000, 0.000000), r5.yzyy
        ge r4.zw, r6.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000)
        mad r7.xy, cb0[51].xyxx, l(3.000000, 3.000000, 0.000000, 0.000000), r6.xyxx
        ge r7.xy, l(0.000000, 0.000000, 0.000000, 0.000000), r7.xyxx
        or r4.z, r4.z, r7.x
        or r4.z, r4.w, r4.z
        or r4.z, r7.y, r4.z
        if_z r4.z
          itof r6.z, r4.x
          mov_sat r5.x, r5.x
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.z, r6.xyzx, t2.xxxx, s2, r5.x
          add r7.xy, r6.xyxx, cb0[51].xyxx
          mov r7.zw, r6.zzzy
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r7.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          add r8.xy, r7.xyxx, cb0[51].xyxx
          mov r8.zw, r7.wwwz
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r8.xzwx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          add r9.xy, r8.xyxx, cb0[51].xyxx
          mov r9.zw, r8.zzzw
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r9.xzwx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r6.w, r7.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r6.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r7.xyzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r10.xz, r8.xxwx
          mov r10.y, r6.w
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r10.xyzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r11.xz, r9.xxwx
          mov r11.y, r10.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r11.xyzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r6.y, r8.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r6.xyzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r7.y, r6.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r7.xyzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r8.xywx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r11.w, r7.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r11.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r6.w, r9.y
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r6.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r7.w, r6.w
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r7.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mov r10.w, r7.w
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r10.xwzx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.w, r9.xywx, t2.xxxx, s2, r5.x
          add r4.z, r4.w, r4.z
          mad r4.y, -r4.z, l(0.062500), l(1.000000)
        else
          mov r4.y, l(0)
        endif
      else
        itof r5.w, r4.x
        mov_sat r5.x, r5.x
        sample_c_lz_indexable(texture2darray)(float,float,float,float) r4.z, r5.yzwy, t2.xxxx, s2, r5.x
        add r4.y, -r4.z, l(1.000000)
      endif
    endif
    max r3.w, r3.w, r4.y
    iadd r4.x, r4.x, l(1)
  endloop
  dp4_sat r0.x, cb0[33].xyzw, r2.xyzw
  mad r0.x, -r3.w, r0.x, l(1.000000)
else
  mov r0.x, l(1.000000)
endif
sample_indexable(texture2d)(float,float,float,float) r0.y, r1.xyxx, t1.yxzw, s1
add r0.y, r0.y, l(-1.000000)
mad r0.y, cb0[5].x, r0.y, l(1.000000)
min r0.x, r0.x, r0.y
add r0.x, r0.x, l(-1.000000)
mad o0.xyzw, cb0[56].xxxx, r0.xxxx, l(1.000000, 1.000000, 1.000000, 1.000000)
ret
// Approximately 281 instruction slots used
