// MANUALLY DUMPED [ShaderRegexDecalsMain_backup] Volumetric lighting.
//
// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384
//
//   using 3Dmigoto v1.3.16 on Sat Oct  2 11:56:35 2021
//
//
// Buffer Definitions:
//
// cbuffer fblock
// {
//
//   float4 renderpositiontoviewtexture;// Index:    0.xyzw           Components:     4
//   float4 inverseviewprojectionmatrixx;// Index:    1.xyzw           Components:     4
//   float4 inverseviewprojectionmatrixy;// Index:    2.xyzw           Components:     4
//   float4 inverseviewprojectionmatrixz;// Index:    3.xyzw           Components:     4
//   float4 inverseviewprojectionmatrixw;// Index:    4.xyzw           Components:     4
//   float4 lightprepassinverseparams;  // Index:    5.xyzw           Components:     4
//   float4 globalvieworigin;           // Index:    6.xyzw           Components:     4
//   float4 lppmultipasslightposition;  // Index:    7.xyzw           Components:     4
//   float4 lppmultipasslightcolor;     // Index:    8.xyzw           Components:     4
//   float4 lppmultipasslightextents;   // Index:    9.xyzw           Components:     4
//   float4 volumelightparms3;          // Index:   10.xyzw           Components:     4
//   float4 volumelightparms2;          // Index:   11.xyzw           Components:     4
//   float4 lppmultipasslightrightdir;  // Index:   12.xyzw           Components:     4
//   float4 volumelightparms5;          // Index:   13.xyzw           Components:     4
//   float4 lppmultipasslightcenter;    // Index:   14.xyzw           Components:     4
//   float4 lightclipboundingvolumeextent;// Index:   15.xyzw           Components:     4
//   float4 lppmultipasslightspotdir;   // Index:   16.xyzw           Components:     4
//   float4 lightclipboundingvolumeorigin;// Index:   17.xyzw           Components:     4
//   float4 localtolights;              // Index:   18.xyzw           Components:     4
//   float4 localtolightt;              // Index:   19.xyzw           Components:     4
//   float4 localtolightr;              // Index:   20.xyzw           Components:     4
//   float4 localtolightq;              // Index:   21.xyzw           Components:     4
//   float4 lightshaderflags;           // Index:   22.xyzw           Components:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// viewdepthmap_samp_state           sampler      NA          NA    0        1
// shadowcubestrqmap_samp_state      sampler      NA          NA    1        1
// shadowstexarray_samp_state      sampler_c      NA          NA    2        1
// viewdepthmap_samp                 texture  float4          2d    0        1
// shadowcubestrqmap_samp            texture  float4   cubearray    1        1
// shadowstexarray_samp              texture  float4     2darray    2        1
// fblock                            cbuffer      NA          NA    0        1
//
//
//
// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position              0   xyzw        0      POS   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[23], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_default
dcl_sampler s2, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texturecubearray (float,float,float,float) t1
dcl_resource_texture2darray (float,float,float,float) t2
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 31
dcl_resource_texture2d (float,float,float,float) t125
mad r0.xy, v0.xyxx, cb0[0].zwzz, cb0[0].xyxx
mad r0.xy, r0.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
mad r0.xy, r0.xyxx, l(0.500000, -0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
sample_aoffimmi_indexable(0,0,0)(texture2d)(float,float,float,float) r0.w, r0.xyxx, t0.yzwx, s0
min r1.z, r0.w, l(0.999999)
add r0.z, -r0.y, l(1.000000)
mad r1.xy, r0.xzxx, l(2.000000, 2.000000, 0.000000, 0.000000), l(-1.000000, -1.000000, 0.000000, 0.000000)
mov r1.w, l(1.000000)


ld_indexable(texture2d)(float,float,float,float) r16.xyzw, l(0, 0, 0, 0), t125.xyzw
mov r18.xyzw, r1.xyzw
//dp4 r17.w, r18.xyzw, cb0[4].xyzw
//mad r17.x, r17.w, r16.y, l(-1.0)
//mad r18.x, r17.x, r16.x, r18.x

add r18.x, -r16.x, r18.x

dp4 r0.x, r18.xyzw, cb0[1].xyzw
dp4 r0.y, r18.xyzw, cb0[2].xyzw
dp4 r0.z, r18.xyzw, cb0[3].xyzw
dp4 r0.w, r18.xyzw, cb0[4].xyzw
div r0.xyz, r0.xyzx, r0.wwww

//Fix here. Where r27 is used. Unused.
mov r27.xyzw, cb0[6].xyzw
mul r25.x, r16.y, cb0[1].x
mul r25.y, r16.y, cb0[2].x
mul r25.z, r16.y, cb0[3].x
mad r27.xyz, r16.xxxx, r25.xyzx, r27.xyzx

add r0.xyz, r0.xyzx, cb0[5].xyzx
add r0.xyz, r0.xyzx, -cb0[6].xyzx
dp3 r0.w, r0.xyzx, r0.xyzx
sqrt r0.w, r0.w
div r0.xyz, r0.xyzx, r0.wwww
add r1.xyz, -cb0[6].xyzx, cb0[7].xyzx
dp3 r1.x, r1.xyzx, r1.xyzx
sqrt r1.x, r1.x
lt r1.x, r1.x, cb0[9].x
add r1.yzw, r27.xxyz, -cb0[7].xxyz
dp3 r2.x, r1.yzwy, r1.yzwy
dp3 r1.y, r0.xyzx, r1.yzwy
mad r1.z, -cb0[9].x, cb0[9].x, r2.x
mad r1.z, r1.y, r1.y, -r1.z
lt r1.w, l(0.000000), r1.z
sqrt r2.z, r1.z
mov r2.y, -r2.z
add r1.yz, -r1.yyyy, r2.yyzy
movc r2.yz, r1.wwww, r1.yyzy, l(0,-10000000000.000000,-10000000000.000000,0)
lt r1.y, r2.z, r0.w
movc r2.x, r1.y, r2.z, r0.w
lt r1.yz, l(0.000000, 0.000000, 0.000000, 0.000000), r2.yyzy
and r0.w, r1.z, r1.y
add r1.yz, -r2.yyyy, r2.xxzx
and r1.yz, r0.wwww, r1.yyzy
movc r1.yz, r1.xxxx, r2.xxzx, r1.yyzy
max r1.y, r1.y, l(0.000000)
eq r1.w, r1.y, l(0.000000)
mov o0.xyzw, l(0,0,0,1.000000)
retc_nz r1.w
mad r2.xyz, r2.yyyy, r0.xyzx, cb0[6].xyzx
movc r2.xyz, r0.wwww, r2.xyzx, cb0[6].xyzx
movc r2.xyz, r1.xxxx, cb0[6].xyzx, r2.xyzx
div r0.w, r1.y, cb0[10].w
mul r1.x, cb0[10].w, l(0.950000)
ftou r1.x, r1.x
utof r1.w, r1.x
div r1.w, cb0[11].y, r1.w
mul r1.y, r1.y, r1.w
max r1.z, r1.z, l(0.000001)
div r1.y, r1.y, r1.z
eq r1.z, cb0[12].x, l(0.000000)
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), cb0[9].x
lt r2.w, l(0.000000), cb0[13].z
ftou r3.xy, v0.xyxx
ubfe r3.z, l(1), l(1), r3.x
iadd r3.w, -r3.z, l(1)
imul null, r3.z, r3.z, l(0x596ad1e2)
imad r3.z, l(0x7b48f3c0), r3.w, r3.z
bfi r3.x, l(1), l(4), r3.x, l(0)
bfi r3.x, l(2), l(2), r3.y, r3.x
ushr r3.x, r3.z, r3.x
and r3.x, r3.x, l(15)
utof r3.x, r3.x
mul r3.x, r3.x, l(0.0666666701)
and r2.w, r2.w, r3.x
ge r3.x, l(0.000000), cb0[12].w
lt r3.y, l(0.000000), cb0[11].w
add r3.z, cb0[17].w, l(9.999999960E-12)
ne r3.w, cb0[15].w, l(0.000000)
add r4.x, cb0[14].w, l(9.999999717E-10)
mov r5.w, l(1.000000)
mov r6.w, l(0)
mov r7.w, l(1.000000)
mov r8.w, l(2.000000)
mov r9.w, l(3.000000)
mov r10.z, cb0[22].y
mov r4.yzw, l(0,0,0,0)
mov r10.w, l(0)

//Fix here for real.
mul r25.x, r16.y, cb0[1].x
mul r25.y, r16.y, cb0[2].x
mul r25.z, r16.y, cb0[3].x
mad r2.xyz, r16.xxxx, r25.xyzx, r2.xyzx

loop
  uge r11.x, r10.w, r1.x
  breakc_nz r11.x
  utof r11.x, r10.w
  add r11.x, r2.w, r11.x
  mul r11.x, r0.w, r11.x
  mad r5.xyz, r11.xxxx, r0.xyzx, r2.xyzx
  add r11.xyz, r5.xyzx, -cb0[7].xyzx
  dp3 r11.w, r11.xyzx, r11.xyzx
  sqrt r11.w, r11.w
  if_nz r1.z
    div_sat r12.xyz, |r11.xyzx|, cb0[9].xyzx
    add r12.xyz, -r12.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)
    mul r12.x, r12.y, r12.x
    mul r12.x, r12.z, r12.x
    log r12.x, r12.x
    mul r12.x, r12.x, cb0[7].w
    exp r12.x, r12.x
    mad r12.y, -r11.w, r1.w, l(1.000000)
    max r12.y, r12.y, l(0.000001)
    min r12.y, r12.y, l(1.000000)
    log r12.y, r12.y
    mul r12.y, r12.y, cb0[10].x
    exp r12.y, r12.y
    mul r12.x, r12.y, r12.x
  else
    mul r12.yzw, r11.xxyz, l(0.000000, 0.020000, 0.020000, 0.020000)
    dp3 r12.y, |r12.yzwy|, |r12.yzwy|
    if_nz r3.x
      mul r13.xyz, r11.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000)
      dp3 r12.z, |r13.xyzx|, |r13.xyzx|
      div r12.z, r12.z, r3.z
    else
      dp3 r11.x, cb0[16].xyzx, r11.xyzx
      div_sat r11.x, r11.x, r4.x
      mul r11.x, r11.x, r11.x
      mul r11.x, r11.x, r11.x
      and r12.z, r3.w, r11.x
    endif
    mad r11.x, -r12.z, r12.z, l(1.000000)
    max r11.x, r11.x, l(0.000000)
    mul r11.x, r11.x, r11.x
    add r11.y, r12.y, cb0[7].w
    div r11.y, l(1.000000, 1.000000, 1.000000, 1.000000), r11.y
    mul r11.x, r11.x, r11.y
    mul r11.x, r11.x, l(0.0795798153)
    mad r11.y, -r11.w, r1.w, l(1.000000)
    max r11.y, r11.y, l(0.000001)
    min r11.y, r11.y, l(1.000000)
    log r11.y, r11.y
    mul r11.y, r11.y, cb0[10].x
    exp r11.y, r11.y
    mul r12.x, r11.y, r11.x
  endif
  ge r11.x, l(0.000000), r12.x
  if_nz r11.x
    iadd r11.x, r10.w, l(1)
    mov r10.w, r11.x
    continue
  endif
  if_nz r3.y
    dp4 r6.x, r5.xyzw, cb0[18].xyzw
    dp4 r6.y, r5.xyzw, cb0[19].xyzw
    dp4 r6.z, r5.xyzw, cb0[20].xyzw
    dp4 r11.w, r5.xyzw, cb0[21].xyzw
    sample_indexable(texturecubearray)(float,float,float,float) r13.xyzw, r6.xyzw, t1.xyzw, s1
    mov r11.xyz, r6.xyzx
    dp4 r5.x, r13.xyzw, r11.xyzw
    mov r7.xyz, r11.xyzx
    sample_indexable(texturecubearray)(float,float,float,float) r13.xyzw, r7.xyzw, t1.xyzw, s1
    dp4 r5.y, r13.xyzw, r11.xyzw
    mov r8.xyz, r7.xyzx
    sample_indexable(texturecubearray)(float,float,float,float) r13.xyzw, r8.xyzw, t1.xyzw, s1
    dp4 r5.z, r13.xyzw, r11.xyzw
    mov r9.xyz, r8.xyzx
    sample_indexable(texturecubearray)(float,float,float,float) r13.xyzw, r9.xyzw, t1.xyzw, s1
    dp4 r6.x, r13.xyzw, r11.xyzw
    div r5.xyz, r5.xyzx, r6.xxxx
    max r5.z, r5.z, l(1.000000012E-07)
    mad r10.xy, r5.xyxx, l(1.000000, -1.000000, 0.000000, 0.000000), l(0.000000, 1.000000, 0.000000, 0.000000)
    sample_c_lz_indexable(texture2darray)(float,float,float,float) r5.x, r10.xyzx, t2.xxxx, s2, r5.z
  else
    mov r5.x, l(1.000000)
  endif
  mul r6.xyz, r12.xxxx, cb0[8].xyzx
  mul r6.xyz, r1.yyyy, r6.xyzx
  mad r4.yzw, r6.xxyz, r5.xxxx, r4.yyzw
  iadd r10.w, r10.w, l(1)
endloop
mul o0.xyz, r4.yzwy, cb0[13].xxxx
mov o0.w, l(1.000000)
ret
// Approximately 174 instruction slots used
