// DLC - Reflections
// Generated by Microsoft (R) D3D Shader Disassembler
//
//   using 3Dmigoto v1.2.57 on Fri Jul 07 17:31:27 2017
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Input
//
// Output signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// no Output
cs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[5], immediateIndexed
dcl_constantbuffer cb1[157], immediateIndexed
dcl_constantbuffer cb2[2387], dynamicIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t3
dcl_resource_texture2d (float,float,float,float) t4
dcl_resource_texture2d (float,float,float,float) t5
dcl_resource_texture2d (float,float,float,float) t6
dcl_resource_texturecubearray (float,float,float,float) t7
dcl_resource_texture2d (float,float,float,float) t8
dcl_resource_texture2d (float,float,float,float) t9
dcl_uav_typed_texture2d (float,float,float,float) u0
dcl_input vThreadGroupID.xy
dcl_input vThreadIDInGroup.xy
dcl_input vThreadID.xy
//dcl_temps 13
dcl_temps 14


dcl_tgsm_raw g0, 4
dcl_tgsm_raw g1, 4
dcl_tgsm_raw g2, 4
dcl_tgsm_structured g3, 4, 341
dcl_tgsm_structured g4, 4, 341
dcl_tgsm_structured g5, 4, 256
dcl_thread_group 16, 16, 1

// 3DMigoto StereoParams:
dcl_resource_texture2d (float,float,float,float) t125
ld_indexable(texture2d)(float,float,float,float) r14.xyzw, l(0, 0, 0, 0), t125.xyzw

imad r0.x, vThreadIDInGroup.y, l(16), vThreadIDInGroup.x
iadd r1.xy, vThreadID.xyxx, cb0[4].xyxx
iadd r0.yz, -cb0[4].xxyx, cb0[4].zzwz
utof r0.yz, r0.yyzy
mov r1.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.w, r1.xyww, t4.yzwx
mad r2.x, r0.w, cb1[51].x, cb1[51].y
mad r0.w, r0.w, cb1[51].z, -cb1[51].w
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.w
add r0.w, r0.w, r2.x
store_structured g5.x, r0.x, l(0), r0.w
sync_g_t
ult r2.xy, r0.xxxx, l(32, 8, 0, 0)
if_nz r2.x
  iadd r2.x, r0.x, l(32)
  mov r2.zw, r0.wwww
  mov r3.x, r2.x
  loop 
    ige r3.y, r3.x, l(256)
    breakc_nz r3.y
    ld_structured r3.y, r3.x, l(0), g5.xxxx
    min r2.z, r2.z, r3.y
    max r2.w, r2.w, r3.y
    iadd r3.x, r3.x, l(32)
  endloop 
  store_structured g5.x, r0.x, l(0), r2.z
  store_structured g5.x, r2.x, l(0), r2.w
endif 
sync_g_t
if_nz r2.y
  ld_structured r2.x, r0.x, l(0), g5.xxxx
  iadd r3.xyzw, r0.xxxx, l(32, 8, 40, 16)
  ld_structured r2.y, r3.x, l(0), g5.xxxx
  ld_structured r2.z, r3.y, l(0), g5.xxxx
  min r2.x, r2.z, r2.x
  ld_structured r2.z, r3.z, l(0), g5.xxxx
  max r2.y, r2.z, r2.y
  ld_structured r2.z, r3.w, l(0), g5.xxxx
  min r2.x, r2.z, r2.x
  iadd r3.xyzw, r0.xxxx, l(48, 24, 56, 64)
  ld_structured r2.z, r3.x, l(0), g5.xxxx
  max r2.y, r2.z, r2.y
  ld_structured r2.z, r3.y, l(0), g5.xxxx
  min r2.x, r2.z, r2.x
  ld_structured r2.z, r3.z, l(0), g5.xxxx
  max r2.y, r2.z, r2.y
  store_structured g5.x, r3.w, l(0), r2.x
  iadd r2.x, r0.x, l(96)
  store_structured g5.x, r2.x, l(0), r2.y
endif 
sync_g_t
if_z r0.x
  ld_structured r2.x, l(64), l(0), g5.xxxx
  ld_structured r2.y, l(96), l(0), g5.xxxx
  mov r3.xy, r2.xyxx
  mov r2.z, l(1)
  loop 
    ige r2.w, r2.z, l(8)
    breakc_nz r2.w
    iadd r3.zw, r2.zzzz, l(0, 0, 64, 96)
    ld_structured r2.w, r3.z, l(0), g5.xxxx
    min r3.x, r2.w, r3.x
    ld_structured r2.w, r3.w, l(0), g5.xxxx
    max r3.y, r2.w, r3.y
    iadd r2.z, r2.z, l(1)
  endloop 
  store_raw g0.x, l(0), r3.x
  store_raw g1.x, l(0), r3.y
endif 
sync_g_t
ld_raw r2.x, l(0), g0.xxxx
ld_raw r2.y, l(0), g1.xxxx
utof r2.zw, vThreadGroupID.xxxy
mad r2.zw, r2.zzzw, l(0.000000, 0.000000, 16.000000, 16.000000), l(0.000000, 0.000000, 0.500000, 0.500000)
div r2.zw, r2.zzzw, r0.yyyz
mad r2.zw, r2.zzzw, l(0.000000, 0.000000, 2.000000, -2.000000), l(0.000000, 0.000000, -1.000000, 1.000000)
lt r3.x, cb1[27].w, l(1.000000)
add r3.yw, r2.xxxy, cb1[51].wwww
mul r3.yw, r3.yyyw, cb1[51].zzzz
div r3.y, l(1.000000, 1.000000, 1.000000, 1.000000), r3.y
mad r2.x, r2.x, cb1[26].z, cb1[27].z
movc r2.x, r3.x, r3.y, r2.x
iadd r3.yz, vThreadGroupID.xxyx, l(0, 1, 1, 0)
utof r3.yz, r3.yyzy
mad r3.yz, r3.yyzy, l(0.000000, 16.000000, 16.000000, 0.000000), l(0.000000, -0.500000, -0.500000, 0.000000)
div r3.yz, r3.yyzy, r0.yyzy
mad r3.yz, r3.yyzy, l(0.000000, 2.000000, -2.000000, 0.000000), l(0.000000, -1.000000, 1.000000, 0.000000)
div r3.w, l(1.000000, 1.000000, 1.000000, 1.000000), r3.w
mad r2.y, r2.y, cb1[26].z, cb1[27].z
movc r2.y, r3.x, r3.w, r2.y
mul r4.xyzw, r2.wwww, cb1[29].xyzw
mad r4.xyzw, r2.zzzz, cb1[28].xyzw, r4.xyzw
mad r5.xyzw, r2.yyyy, cb1[30].xyzw, r4.xyzw
add r5.xyzw, r5.xyzw, cb1[31].xyzw
div r5.xyz, r5.xyzx, r5.wwww
mul r6.xyzw, r3.zzzz, cb1[29].xyzw
mad r3.xyzw, r3.yyyy, cb1[28].xyzw, r6.xyzw
mad r3.xyzw, r2.yyyy, cb1[30].xyzw, r3.xyzw
add r3.xyzw, r3.xyzw, cb1[31].xyzw
div r2.yzw, r3.xxyz, r3.wwww
mad r3.xyzw, r2.xxxx, cb1[30].xyzw, r4.xyzw
add r3.xyzw, r3.xyzw, cb1[31].xyzw
div r3.xyz, r3.xyzx, r3.wwww
min r4.xyz, r2.yzwy, r5.xyzx
min r4.xyz, r3.xyzx, r4.xyzx
max r2.xyz, r2.yzwy, r5.xyzx
max r2.xyz, r2.xyzx, r3.xyzx
add r3.xyz, r4.xyzx, r2.xyzx
add r2.xyz, -r4.xyzx, r2.xyzx
if_z r0.x
  store_raw g2.x, l(0), l(0)
endif 
sync_g_t
mov r2.w, r0.x
loop 
  ult r3.w, r2.w, cb0[3].x
  ult r4.x, r2.w, l(341)
  and r3.w, r3.w, r4.x
  breakc_z r3.w
  add r4.xyz, cb1[56].xyzx, cb2[r2.w + 0].xyzx
  mul r5.xyz, r4.yyyy, cb1[9].xyzx
  mad r4.xyw, r4.xxxx, cb1[8].xyxz, r5.xyxz
  mad r4.xyz, r4.zzzz, cb1[10].xyzx, r4.xywx
  add r4.xyz, r4.xyzx, cb1[11].xyzx
  mad r4.xyz, r3.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), -r4.xyzx
  mad r4.xyz, -r2.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000), |r4.xyzx|
  max r4.xyz, r4.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  dp3 r3.w, r4.xyzx, r4.xyzx
  mul r4.x, cb2[r2.w + 0].w, cb2[r2.w + 0].w
  lt r3.w, r3.w, r4.x
  if_nz r3.w
    imm_atomic_iadd r4.x, g2, l(0), l(1)
    store_structured g3.x, r4.x, l(0), r2.w
  endif 
  iadd r2.w, r2.w, l(256)
endloop 
sync_g_t
ld_raw r2.x, l(0), g2.xxxx
mov r2.y, r0.x
loop 
  uge r2.z, r2.y, r2.x
  breakc_nz r2.z
  ld_structured r2.z, r2.y, l(0), g3.xxxx
  mov r2.w, l(0)
  mov r3.x, l(0)
  loop 
    uge r3.y, r3.x, r2.x
    breakc_nz r3.y
    ld_structured r3.y, r3.x, l(0), g3.xxxx
    ilt r3.y, r3.y, r2.z
    iadd r2.w, r2.w, -r3.y
    iadd r3.x, r3.x, l(1)
  endloop 
  ld_structured r2.z, r2.y, l(0), g3.xxxx
  store_structured g4.x, r2.w, l(0), r2.z
  iadd r2.y, r2.y, l(256)
endloop 
sync_g_t
ld_indexable(texture2d)(float,float,float,float) r3.xyzw, r1.xyww, t1.xyzw
mul r0.x, r3.w, l(255.000000)
round_ne r0.x, r0.x
ftou r0.x, r0.x
and r2.y, r0.x, l(15)
ine r2.zw, r2.yyyy, l(0, 0, 0, 7)
and r2.z, r2.w, r2.z
if_nz r2.z
  utof r2.zw, vThreadID.xxxy
  add r2.zw, r2.zzzw, l(0.000000, 0.000000, 0.500000, 0.500000)
  div r0.yz, r2.zzwz, r0.yyzy
  mad r0.yz, r0.yyzy, l(0.000000, 2.000000, -2.000000, 0.000000), l(0.000000, -1.000000, 1.000000, 0.000000)
  ld_indexable(texture2d)(float,float,float,float) r4.xyz, r1.xyww, t0.xyzw
  ld_indexable(texture2d)(float,float,float,float) r5.xyzw, r1.xyww, t2.xyzw
  ld_indexable(texture2d)(float,float,float,float) r2.zw, r1.xyww, t3.zwxy
  ftou r3.w, cb1[133].x
  iadd r4.w, r1.y, r1.x
  iadd r3.w, r3.w, r4.w
  and r3.w, r3.w, l(1)
  mad r4.xyz, r4.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)
  dp3 r4.w, r4.xyzx, r4.xyzx
  rsq r4.w, r4.w
  mul r6.xyz, r4.wwww, r4.xyzx
  mad r6.w, r5.w, l(16.000000), l(-8.000000)
  exp r6.w, r6.w
  add r6.w, r6.w, l(-0.00390625000)
  and r0.x, r0.x, l(16)
  movc r2.zw, r0.xxxx, l(0,0,0,0), r2.zzzw
  ieq r7.xy, r2.yyyy, l(5, 4, 0, 0)
  movc r8.xy, r3.wwww, l(1.000000,0,0,0), l(0,1.000000,0,0)
  mul r8.z, r3.y, r8.y
  mov r5.w, r3.y
  movc r5.xyzw, r7.xxxx, r8.xxxz, r5.xyzw
  mul r0.x, r5.w, l(0.080000)
  mad r5.xyz, -r5.wwww, l(0.080000, 0.080000, 0.080000, 0.000000), r5.xyzx
  mad r5.xyz, r3.xxxx, r5.xyzx, r0.xxxx
  mad r5.xyz, r5.xyzx, cb1[119].wwww, cb1[119].xyzx
  utof r7.xz, r1.xxyx
  add r7.xz, r7.xxzx, l(0.500000, 0.000000, 0.500000, 0.000000)
  mul r7.xz, r7.xxzx, cb1[116].zzwz
  sample_l_indexable(texture2d)(float,float,float,float) r0.x, r7.xzxx, t5.xyzw, s0, l(0.000000)
  mul r0.yz, r0.wwww, r0.yyzy
  
  // Move environment reflections to infinity:
mad r0.y, -r14.x, r0.w, r0.y
  
  mul r8.xyzw, r0.zzzz, cb1[41].xyzw
  mad r8.xyzw, r0.yyyy, cb1[40].xyzw, r8.xyzw
  mad r8.xyzw, r0.wwww, cb1[42].xyzw, r8.xyzw
  add r8.xyzw, r8.xyzw, cb1[43].xyzw
  div r0.yzw, r8.xxyz, r8.wwww
  add r7.xzw, r0.yyzw, -cb1[53].xxyz
  dp3 r2.y, r7.xzwx, r7.xzwx
  rsq r2.y, r2.y
  mul r7.xzw, r2.yyyy, r7.xxzw
  dp3 r3.x, -r7.xzwx, r6.xyzx
  add r2.y, r3.x, r3.x
  mad r7.xzw, r2.yyyy, r6.xxyz, r7.xxzw
  mov_sat r3.x, r3.x
  mul r2.y, r3.z, r3.z
  mad r3.w, -r3.z, r3.z, l(1.000000)
  sqrt r5.w, r3.w
  mad r5.w, r3.z, r3.z, r5.w
  mul r3.w, r3.w, r5.w
  mad r4.xyz, -r4.xyzx, r4.wwww, r7.xzwx
  mad r4.xyz, r3.wwww, r4.xyzx, r6.xyzx
  ld_indexable(texture2d)(float,float,float,float) r8.xyzw, r1.xyww, t8.xyzw
  add r3.w, -r8.w, l(1.000000)
  mad r9.xyzw, r8.xyzw, l(1.000000, 1.000000, 1.000000, -1.000000), l(0.000000, 0.000000, 0.000000, 1.000000)
  add r10.xyzw, -r9.xyzw, l(0.000000, 0.000000, 0.000000, 1.000000)
  mad r10.xyzw, r2.zzzz, r10.xyzw, r9.xyzw
  movc r9.xyzw, r7.yyyy, r10.xyzw, r9.xyzw
  add r4.w, r0.x, r3.x
  log r4.w, r4.w
  mul r2.y, r2.y, r4.w
  exp r2.y, r2.y
  add r0.x, r0.x, r2.y
  add_sat r0.x, r0.x, l(-1.000000)
  mul r2.y, r0.x, r9.w
  log r4.w, r3.z
  mad r4.w, -r4.w, l(1.200000), l(1.000000)
  add r5.w, cb1[156].z, l(-1.000000)
  add r4.w, -r4.w, r5.w
  mov r6.xyz, r9.xyzx
  mov r8.w, r2.y
  mov r9.w, l(0)
  loop 
    uge r10.x, r9.w, r2.x
    breakc_nz r10.x
    lt r10.x, r8.w, l(0.001000)
    if_nz r10.x
      break 
    endif 
    ld_structured r10.x, r9.w, l(0), g4.xxxx
    add r10.yzw, r0.yyzw, -cb2[r10.x + 0].xxyz
    dp3 r11.x, r10.yzwy, r10.yzwy
    sqrt r11.y, r11.x
    lt r11.z, r11.y, cb2[r10.x + 0].w
    if_nz r11.z
      div_sat r11.y, r11.y, cb2[r10.x + 0].w
      dp3 r11.z, r4.xyzx, r10.yzwy
      mad r11.x, -cb2[r10.x + 0].w, cb2[r10.x + 0].w, r11.x
      mad r11.x, r11.z, r11.z, -r11.x
      sqrt r11.x, r11.x
      add r11.x, -r11.z, r11.x
      mad r10.yzw, r11.xxxx, r4.xxyz, r10.yyzw
      add r12.xyz, r10.yzwy, -cb2[r10.x + 2046].xyzx
      mad r10.y, r11.y, l(2.500000), l(-1.500000)
      max r10.y, r10.y, l(0.000000)
      mul r10.z, r10.y, r10.y
      mad r10.y, -r10.y, l(2.000000), l(3.000000)
      mad r10.y, -r10.z, r10.y, l(1.000000)
      mov r12.w, cb2[r10.x + 341].y
      sample_l_indexable(texturecubearray)(float,float,float,float) r11.xyzw, r12.xyzw, t7.xyzw, s2, r4.w
      mul r11.xyz, r6.wwww, r11.xyzx
      mul r10.xzw, r11.xxyz, cb2[r10.x + 341].xxxx
      mul r10.xzw, r10.yyyy, r10.xxzw
      mad r6.xyz, r10.xzwx, r8.wwww, r6.xyzx
      mad r10.x, -r11.w, r10.y, l(1.000000)
      mul r8.w, r8.w, r10.x
    endif 
    iadd r9.w, r9.w, l(1)
  endloop 
  if_nz r7.y
    mov r3.y, r3.z
    sample_l_indexable(texture2d)(float,float,float,float) r4.xy, r3.xyxx, t6.xyzw, s1, l(0.000000)
    mul_sat r2.y, r5.y, l(50.000000)
    mul r2.y, r2.y, r4.y
    add r3.y, -r2.z, l(1.000000)
    mul r2.y, r2.y, r3.y
    mad r4.xyz, r5.xyzx, r4.xxxx, r2.yyyy
    mul r4.xyz, r4.xyzx, r6.xyzx
    add r2.y, -r3.x, l(1.000000)
    mul r3.y, r2.y, r2.y
    mul r3.y, r3.y, r3.y
    mul r4.w, r2.y, r3.y
    mad r2.y, -r3.y, r2.y, l(1.000000)
    mad r2.y, r2.y, l(0.040000), r4.w
    mul r3.y, r2.z, r2.y
    mad r2.y, -r2.y, r2.z, l(1.000000)
    mul r8.xyz, r3.yyyy, r8.xyzx
    mad r4.xyz, r4.xyzx, r2.yyyy, r8.xyzx
    mul r2.y, r3.w, r3.y
    mul r0.x, r0.x, r2.y
    log r2.y, r2.w
    mad r2.y, -r2.y, l(1.200000), l(1.000000)
    add r2.y, -r2.y, r5.w
    mov r8.xyz, r4.xyzx
    mov r2.z, r0.x
    mov r2.w, l(0)
    loop 
      uge r3.y, r2.w, r2.x
      breakc_nz r3.y
      lt r3.y, r2.z, l(0.001000)
      if_nz r3.y
        break 
      endif 
      ld_structured r3.y, r2.w, l(0), g4.xxxx
      add r9.xyz, r0.yzwy, -cb2[r3.y + 0].xyzx
      dp3 r3.w, r9.xyzx, r9.xyzx
      sqrt r4.w, r3.w
      lt r5.w, r4.w, cb2[r3.y + 0].w
      if_nz r5.w
        div_sat r4.w, r4.w, cb2[r3.y + 0].w
        dp3 r5.w, r7.xzwx, r9.xyzx
        mad r3.w, -cb2[r3.y + 0].w, cb2[r3.y + 0].w, r3.w
        mad r3.w, r5.w, r5.w, -r3.w
        sqrt r3.w, r3.w
        add r3.w, -r5.w, r3.w
        mad r9.xyz, r3.wwww, r7.xzwx, r9.xyzx
        add r9.xyz, r9.xyzx, -cb2[r3.y + 2046].xyzx
        mad r3.w, r4.w, l(2.500000), l(-1.500000)
        max r3.w, r3.w, l(0.000000)
        mul r4.w, r3.w, r3.w
        mad r3.w, -r3.w, l(2.000000), l(3.000000)
        mad r3.w, -r4.w, r3.w, l(1.000000)
        mov r9.w, cb2[r3.y + 341].y
        sample_l_indexable(texturecubearray)(float,float,float,float) r9.xyzw, r9.xyzw, t7.xyzw, s2, r2.y
        mul r9.xyz, r6.wwww, r9.xyzx
        mul r9.xyz, r9.xyzx, cb2[r3.y + 341].xxxx
        mul r9.xyz, r3.wwww, r9.xyzx
        mad r8.xyz, r9.xyzx, r2.zzzz, r8.xyzx
        mad r3.y, -r9.w, r3.w, l(1.000000)
        mul r2.z, r2.z, r3.y
      endif 
      iadd r2.w, r2.w, l(1)
    endloop 
  else 
    sample_l_indexable(texture2d)(float,float,float,float) r0.xy, r3.xzxx, t6.xyzw, s1, l(0.000000)
    mul_sat r0.z, r5.y, l(50.000000)
    mul r0.y, r0.y, r0.z
    mad r0.xyz, r5.xyzx, r0.xxxx, r0.yyyy
    mul r8.xyz, r0.xyzx, r6.xyzx
  endif 
else 
  mov r8.xyz, l(0,0,0,0)
endif 
ult r0.xy, vThreadID.xyxx, cb0[4].zwzz
and r0.x, r0.y, r0.x
if_nz r0.x
  min r0.xyz, -r8.xyzx, l(0.000000, 0.000000, 0.000000, 0.000000)
  mov r0.xyz, -r0.xyzx
  ld_indexable(texture2d)(float,float,float,float) r2.xyzw, r1.xyzw, t9.xyzw
  mov r0.w, l(0)
  add r0.xyzw, r0.xyzw, r2.xyzw
  store_uav_typed u0.xyzw, r1.xyyy, r0.xyzw
endif 
ret 
// Approximately 0 instruction slots used
