// 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:38:55 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 lppmultipasslightrightdir;  // Index:    9.xyzw           Components:     4
//   float4 lppmultipasslightspotdir;   // Index:   10.xyzw           Components:     4
//   float4 lppmultipasslightcenter;    // Index:   11.xyzw           Components:     4
//   float4 volumelightparms3;          // Index:   12.xyzw           Components:     4
//   float4 volumelightparms2;          // Index:   13.xyzw           Components:     4
//   float4 volumelightparms4;          // Index:   14.xyzw           Components:     4
//   float4 lppmultipasslightextents;   // Index:   15.xyzw           Components:     4
//   float4 volumelightparms5;          // Index:   16.xyzw           Components:     4
//   float4 lightclipboundingvolumeextent;// Index:   17.xyzw           Components:     4
//   float4 lightclipboundingvolumeorigin;// Index:   18.xyzw           Components:     4
//   float4 localtolights;              // Index:   19.xyzw           Components:     4
//   float4 localtolightt;              // Index:   20.xyzw           Components:     4
//   float4 localtolightr;              // Index:   21.xyzw           Components:     4
//   float4 localtolightq;              // Index:   22.xyzw           Components:     4
//   float4 lightshaderflags;           // Index:   23.xyzw           Components:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// viewdepthmap_samp_state           sampler      NA          NA    0        1
// shadowstexarray_samp_state      sampler_c      NA          NA    1        1
// viewdepthmap_samp                 texture  float4          2d    0        1
// shadowstexarray_samp              texture  float4     2darray    1        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[24], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s1, mode_comparison
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2darray (float,float,float,float) t1
dcl_input_ps_siv linear noperspective v0.xy, position
dcl_output o0.xyzw
dcl_temps 27
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) r12.xyzw, l(0, 0, 0, 0), t125.xyzw
mov r14.xyzw, r1.xyzw
//dp4 r13.w, r14.xyzw, cb0[4].xyzw
//mad r13.x, r13.w, r12.y, l(-1.0)
//mad r14.x, r13.x, r12.x, r14.x

add r14.x, -r12.x, r14.x

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


//Fix here. Where r17 is used. Unused.
mov r17.xyzw, cb0[6].xyzw
mul r25.x, r12.y, cb0[1].x
mul r25.y, r12.y, cb0[2].x
mul r25.z, r12.y, cb0[3].x
mad r17.xyz, r12.xxxx, r25.xyzx, r17.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.w, r1.xyzx, r1.xyzx
sqrt r1.w, r1.w
div r2.xyz, r1.xyzx, r1.wwww
dp3 r1.w, -r2.xyzx, cb0[10].xyzx
lt r1.w, cb0[9].w, r1.w
dp3 r1.x, -r1.xyzx, cb0[10].xyzx
lt r1.x, r1.x, cb0[11].w
and r1.x, r1.x, r1.w
add r1.yzw, r17.xxyz, -cb0[7].xxyz
dp3 r2.x, r0.xyzx, cb0[10].xyzx
dp3 r2.y, r0.xyzx, r0.xyzx
dp3 r2.z, r1.yzwy, cb0[10].xyzx
dp3 r2.w, r1.yzwy, r0.xyzx
dp3 r1.y, r1.yzwy, r1.yzwy
mul r1.z, cb0[9].w, cb0[9].w
mul r1.w, r1.z, r2.y
mad r1.w, r2.x, r2.x, -r1.w
mul r2.y, r1.z, r2.w
mad r2.y, r2.z, r2.x, -r2.y
add r2.y, r2.y, r2.y
mul r1.y, r1.z, r1.y
mad r1.y, r2.z, r2.z, -r1.y
mul r1.y, r1.w, r1.y
mul r1.y, r1.y, l(4.000000)
mad r1.y, r2.y, r2.y, -r1.y
lt r2.w, l(0.000000), r1.y
sqrt r3.y, r1.y
lt r1.y, l(0.000000), r1.w
lt r3.z, r1.w, l(0.000000)
iadd r1.y, -r1.y, r3.z
itof r1.y, r1.y
mov r3.x, -r3.y
mad r3.xy, r1.yyyy, r3.xyxx, -r2.yyyy
add r1.y, r1.w, r1.w
div r1.yw, r3.xxxy, r1.yyyy
mad r2.yz, r2.xxxx, r1.yywy, r2.zzzz
lt r2.yz, l(0.000000, 0.000000, 0.000000, 0.000000), r2.yyzy
and r3.xy, r2.yzyy, l(0x3f800000, 0x3f800000, 0, 0)
movc r2.yz, r2.yyzy, l(0,-0.000000,-0.000000,0), l(0,-10000000000.000000,-10000000000.000000,0)
mad r1.yw, r1.yyyw, r3.xxxy, r2.yyyz
movc r3.xy, r2.wwww, r1.ywyy, l(-10000000000.000000,-10000000000.000000,0,0)
mad r1.y, -cb0[9].w, cb0[9].w, l(1.000000)
div r1.y, r1.y, r1.z
mul r1.z, cb0[11].w, cb0[11].w
mul r1.y, r1.y, r1.z
mad r2.yzw, cb0[10].xxyz, cb0[11].wwww, cb0[7].xxyz
add r4.xyz, r2.yzwy, -cb0[6].xyzx
dp3 r1.z, cb0[10].xyzx, r4.xyzx
div r1.z, r1.z, r2.x
mad r4.xyz, r1.zzzz, r0.xyzx, cb0[6].xyzx
add r2.yzw, -r2.yyzw, r4.xxyz
dp3 r1.w, r2.yzwy, r2.yzwy
lt r1.y, r1.w, r1.y
movc r3.w, r1.y, r1.z, l(-10000000000.000000)
lt r1.y, l(0.000000), r3.w
min r1.zw, r3.wwww, r3.xxxy
movc r4.zw, r1.yyyy, r1.zzzw, r3.xxxy
lt r2.yz, r4.zzwz, r0.wwww
lt r5.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000), r3.xyxy
movc r4.xy, r2.yzyy, r4.zwzz, r0.wwww
lt r2.y, r3.w, r0.w
movc r3.z, r2.y, r3.w, r0.w
movc r2.yz, r5.yyyy, r4.yywy, r3.zzwz
movc r2.yz, r5.xxxx, r4.xxzx, r2.yyzy
and r2.w, r5.w, r5.z
lt r2.x, l(0.000000), r2.x
movc r4.xy, r2.xxxx, r3.xwxx, r3.wyww
movc r4.xy, r1.yyyy, r4.xyxx, r3.xyxx
lt r2.x, r4.y, r0.w
movc r2.x, r2.x, r4.y, r0.w
add r6.x, -r4.x, r2.x
add r6.y, -r4.x, r4.y
max r3.xy, r3.xyxx, r3.wwww
lt r3.zw, r3.xxxy, r0.wwww
movc r3.zw, r3.zzzw, r3.xxxy, r0.wwww
and r4.yz, r1.yyyy, r5.xxyx
add r5.xyzw, -r1.zwzw, r3.zwxy
mov r3.x, l(0)
mov r3.y, cb0[11].w
movc r3.xy, r4.zzzz, r5.ywyy, r3.xyxx
movc r3.xy, r4.yyyy, r5.xzxx, r3.xyxx
movc r3.xy, r2.wwww, r6.xyxx, r3.xyxx
movc r2.xy, r1.xxxx, r2.yzyy, r3.xyxx
max r0.w, r2.x, l(0.000000)
eq r1.y, r0.w, l(0.000000)
mov o0.xyzw, l(0,0,0,1.000000)
retc_nz r1.y
mad r3.xyz, r4.xxxx, r0.xyzx, cb0[6].xyzx
mad r5.xyz, r1.zzzz, r0.xyzx, cb0[6].xyzx
mad r1.yzw, r1.wwww, r0.xxyz, cb0[6].xxyz
movc r1.yzw, r4.zzzz, r1.yyzw, cb0[6].xxyz
movc r1.yzw, r4.yyyy, r5.xxyz, r1.yyzw
movc r1.yzw, r2.wwww, r3.xxyz, r1.yyzw
movc r1.xyz, r1.xxxx, cb0[6].xyzx, r1.yzwy
div r1.w, r0.w, cb0[12].w
mul r2.x, cb0[12].w, l(0.950000)
ftou r2.x, r2.x
utof r2.z, r2.x
div r2.z, cb0[13].y, r2.z
mul r0.w, r0.w, r2.z
max r2.y, r2.y, l(0.000001)
div r0.w, r0.w, r2.y
eq r2.y, cb0[9].x, l(0.000000)
add r2.z, -cb0[14].y, cb0[15].x
div r2.z, l(1.000000, 1.000000, 1.000000, 1.000000), r2.z
add r2.w, cb0[11].w, -cb0[14].y
div r2.w, l(1.000000, 1.000000, 1.000000, 1.000000), r2.w
movc r2.z, r2.y, r2.z, r2.w
lt r2.w, l(0.000000), cb0[16].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
add r3.x, -cb0[14].y, cb0[14].z
div r3.x, l(1.000000, 1.000000, 1.000000, 1.000000), r3.x
ge r3.y, l(0.000000), cb0[9].w
lt r3.z, l(0.000000), cb0[13].w
add r3.w, cb0[18].w, l(9.999999960E-12)
ne r4.x, cb0[17].w, l(0.000000)
add r4.y, cb0[11].w, l(9.999999717E-10)
mov r5.w, l(1.000000)
mov r6.w, cb0[23].y
mov r7.xyz, l(0,0,0,0)
mov r4.z, l(0)

mul r25.x, r12.y, cb0[1].x
mul r25.y, r12.y, cb0[2].x
mul r25.z, r12.y, cb0[3].x
mad r1.xyz, r12.xxxx, r25.xyzx, r1.xyzx

loop
  uge r4.w, r4.z, r2.x
  breakc_nz r4.w
  utof r4.w, r4.z
  add r4.w, r2.w, r4.w
  mul r4.w, r1.w, r4.w
  mad r8.xyz, r4.wwww, r0.xyzx, r1.xyzx
  add r9.xyz, -r8.xyzx, cb0[7].xyzx
  dp3 r4.w, r9.xyzx, r9.xyzx
  rsq r4.w, r4.w
  mul r9.xyz, r4.wwww, r9.xyzx
  dp3 r4.w, r9.xyzx, -cb0[10].xyzx
  add r4.w, r4.w, -cb0[9].w
  mul_sat r4.w, r4.w, cb0[10].w
  mul r4.w, r4.w, r4.w
  ge r7.w, l(0.000000), r4.w
  if_nz r7.w
    iadd r7.w, r4.z, l(1)
    mov r4.z, r7.w
    continue
  endif
  add r5.xyz, r8.xyzx, -cb0[7].xyzx
  dp3 r7.w, r5.xyzx, cb0[10].xyzx
  add r8.x, r7.w, -cb0[14].y
  if_nz r2.y
    div_sat r8.yzw, |r5.xxyz|, cb0[15].xxyz
    add r8.yzw, -r8.yyzw, l(0.000000, 1.000000, 1.000000, 1.000000)
    mul r8.y, r8.z, r8.y
    mul r8.y, r8.w, r8.y
    log r8.y, r8.y
    mul r8.y, r8.y, cb0[7].w
    exp r8.y, r8.y
    mad r8.z, -r8.x, r2.z, l(1.000000)
    max r8.z, r8.z, l(0.000001)
    min r8.z, r8.z, l(1.000000)
    log r8.z, r8.z
    mul r8.z, r8.z, cb0[12].x
    exp r8.z, r8.z
    mul r8.y, r8.z, r8.y
  else
    mul r9.xyz, r5.xyzx, l(0.020000, 0.020000, 0.020000, 0.000000)
    dp3 r8.z, |r9.xyzx|, |r9.xyzx|
    if_nz r3.y
      mul r9.xyz, r5.xyzx, l(0.500000, 0.500000, 0.500000, 0.000000)
      dp3 r8.w, |r9.xyzx|, |r9.xyzx|
      div r8.w, r8.w, r3.w
    else
      div_sat r7.w, r7.w, r4.y
      mul r7.w, r7.w, r7.w
      mul r7.w, r7.w, r7.w
      and r8.w, r4.x, r7.w
    endif
    mad r7.w, -r8.w, r8.w, l(1.000000)
    max r7.w, r7.w, l(0.000000)
    mul r7.w, r7.w, r7.w
    add r8.z, r8.z, cb0[7].w
    div r8.z, l(1.000000, 1.000000, 1.000000, 1.000000), r8.z
    mul r7.w, r7.w, r8.z
    mul r7.w, r7.w, l(0.0795798153)
    mad r8.z, -r8.x, r2.z, l(1.000000)
    max r8.z, r8.z, l(0.000001)
    min r8.z, r8.z, l(1.000000)
    log r8.z, r8.z
    mul r8.z, r8.z, cb0[12].x
    exp r8.z, r8.z
    mul r8.y, r7.w, r8.z
  endif
  ge r7.w, l(0.000000), r8.y
  if_nz r7.w
    iadd r7.w, r4.z, l(1)
    mov r4.z, r7.w
    continue
  endif
  mul_sat r7.w, r3.x, r8.x
  mad r8.x, r7.w, l(-2.000000), l(3.000000)
  mul r7.w, r7.w, r7.w
  mul r7.w, r7.w, r8.x
  if_nz r3.z
    dp4 r9.x, r5.xyzw, cb0[19].xyzw
    dp4 r9.y, r5.xyzw, cb0[20].xyzw
    dp4 r9.z, r5.xyzw, cb0[21].xyzw
    dp4 r5.x, r5.xyzw, cb0[22].xyzw
    div r5.xyz, r9.xyzx, r5.xxxx
    mad r6.xy, r5.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000), l(0.500000, 0.500000, 0.000000, 0.000000)
    max r5.x, r5.z, l(1.000000012E-07)
    add r6.z, -r6.y, l(1.000000)
    sample_c_lz_indexable(texture2darray)(float,float,float,float) r5.x, r6.xzwx, t1.xxxx, s1, r5.x
  else
    mov r5.x, l(1.000000)
  endif
  mul r6.xyz, r8.yyyy, cb0[8].xyzx
  mul r6.xyz, r4.wwww, r6.xyzx
  mul r6.xyz, r7.wwww, r6.xyzx
  mul r6.xyz, r0.wwww, r6.xyzx
  mad r7.xyz, r6.xyzx, r5.xxxx, r7.xyzx
  iadd r4.z, r4.z, l(1)
endloop
mul o0.xyz, r7.xyzx, cb0[16].xxxx
mov o0.w, l(1.000000)
ret
// Approximately 251 instruction slots used
