// Volumetric light. NO FIX REQUIRED
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
//   using 3Dmigoto v1.3.14 on Fri Mar 22 00:19:37 2019
//
//
// Buffer Definitions:
//
// cbuffer CB_SHADER_COMMON_PARAM
// {
//
//   uint4 VolumeSize;                  // Offset:    0 Size:    16 [unused]
//   float4 InvVolumeSize;              // Offset:   16 Size:    16
//   float4 DepthRangeInfo;             // Offset:   32 Size:    16
//   float4 LogDepthRangeInfo;          // Offset:   48 Size:    16
//   float4 PreComputed;                // Offset:   64 Size:    16 [unused]
//   float4x4 ViewMatrix;               // Offset:   80 Size:    64 [unused]
//   float2 ViewTangent;                // Offset:  144 Size:     8
//   float2 DepthComputeParam;          // Offset:  152 Size:     8 [unused]
//   float4 g_HeightFactor;             // Offset:  160 Size:    16 [unused]
//   float4 Global;                     // Offset:  176 Size:    16 [unused]
//   float3 AmbientColor;               // Offset:  192 Size:    12 [unused]
//   float AmbientHeightAtten;          // Offset:  204 Size:     4 [unused]
//   float4 g_HeightFogParam;           // Offset:  208 Size:    16 [unused]
//   uint SampleCount;                  // Offset:  224 Size:     4
//   float DitherIntensity;             // Offset:  228 Size:     4
//   float DirLightShadowDither;        // Offset:  232 Size:     4 [unused]
//   float CancelInScatteringRate;      // Offset:  236 Size:     4 [unused]
//   float3 DirLightDirection;          // Offset:  240 Size:    12 [unused]
//   float DirLightAngleInvCos;         // Offset:  252 Size:     4 [unused]
//   float3 DirLightDirectColor;        // Offset:  256 Size:    12 [unused]
//   float DirLightHeightAtten;         // Offset:  268 Size:     4 [unused]
//   float3 DirLightOppositeColor;      // Offset:  272 Size:    12 [unused]
//   uint DirLightShadowSampleCount;    // Offset:  284 Size:     4 [unused]
//   float4x4 mtxViewToShadowMap[4];    // Offset:  288 Size:   256 [unused]
//   float4 vCascadeParam;              // Offset:  544 Size:    16 [unused]
//   float3 ExtinctionScale;            // Offset:  560 Size:    12 [unused]
//   float PreExposure;                 // Offset:  572 Size:     4
//   uint2 ScaledSceneSize;             // Offset:  576 Size:     8 [unused]
//   bool EnableAnalyticalFog;          // Offset:  584 Size:     4 [unused]
//   float4 aRandomVec[32];             // Offset:  592 Size:   512 [unused]
//   float3 ShadowSubpixelOffset;       // Offset: 1104 Size:    12 [unused]
//   float ReprojectionFeedback;        // Offset: 1116 Size:     4 [unused]
//   float4x3 mtxNowToPrevView;         // Offset: 1120 Size:    48 [unused]
//   float4 PrevLogDepthRangeInfo;      // Offset: 1168 Size:    16 [unused]
//   float2 PrevViewTangent;            // Offset: 1184 Size:     8 [unused]
//   float DirLightStartDist;           // Offset: 1200 Size:     4 [unused]
//
// }
//
// cbuffer CB_LOCAL_LIGHT
// {
//
//   struct LocalLight
//   {
//
//       float4 PositionAndRadius;      // Offset:    0
//       float4 Color;                  // Offset:   16
//       float4x4 mtxViewToLight;       // Offset:   32
//       float ScatteringG;             // Offset:   96
//       float dmy1;                    // Offset:  100
//       float2 dmy2;                   // Offset:  104
//
//   } g_LocalLight;                    // Offset:    0 Size:   112
//   int3 VoxelOffset;                  // Offset:  112 Size:    12
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_DitherTex                       texture  float4          2d    2        1
// g_SceneMaxDepth                   texture   float          2d    5        1
// rwLocalDensityAcc                     UAV    uint          3d    1        1
// rwLocalLightRGAcc                     UAV    uint          3d    2        1
// CB_SHADER_COMMON_PARAM            cbuffer      NA          NA    0        1
// CB_LOCAL_LIGHT                    cbuffer      NA          NA    1        1
//
//
//
// 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[36], immediateIndexed
dcl_constantbuffer cb1[8], immediateIndexed
dcl_resource_texture2d (float,float,float,float) t2
dcl_resource_texture2d (float,float,float,float) t5
dcl_uav_typed_texture3d (uint,uint,uint,uint) u1
dcl_uav_typed_texture3d (uint,uint,uint,uint) u2
dcl_input vThreadID.xyz

dcl_temps 34
dcl_resource_texture2d (float,float,float,float) t125

dcl_thread_group 8, 8, 1
iadd r0.xyz, vThreadID.xyzx, cb1[7].xyzx
ld_uav_typed_indexable(texture3d)(uint,uint,uint,uint) r1.x, r0.xyzz, u1.xyzw
ld_uav_typed_indexable(texture3d)(uint,uint,uint,uint) r1.y, r0.xyzz, u2.yxzw
ushr r1.zw, r1.yyyx, l(0, 0, 16, 16)
and r1.xy, r1.xyxx, l(0x0000ffff, 0x0000ffff, 0, 0)
f16tof32 r2.xyz, r1.zywz
f16tof32 r1.x, r1.x
mov r0.w, l(0)
ld_indexable(texture2d)(float,float,float,float) r0.w, r0.xyww, t5.yzwx
utof r1.y, r0.z
mul r1.y, r1.y, cb0[1].z
mad r1.y, r1.y, cb0[3].z, cb0[3].x
exp r1.y, r1.y
add r1.y, r1.y, -cb0[2].w
ge r0.w, r0.w, r1.y
if_nz r0.w
  and r3.xy, r0.xyxx, l(3, 3, 0, 0)
  mov r3.zw, l(0,0,0,0)
  ld_indexable(texture2d)(float,float,float,float) r0.w, r3.xyzw, t2.xyzw
  add r0.w, r0.w, l(-0.500000)
  mad r0.w, r0.w, cb0[14].y, l(0.500000)
  utof r1.y, cb0[14].x
  utof r3.xyz, r0.xyzx
  mad r1.z, -cb1[6].x, cb1[6].x, l(1.000000)
  mul r1.z, r1.z, l(0.250000)
  mad r1.w, cb1[6].x, cb1[6].x, l(1.000000)
  add r2.w, cb1[6].x, cb1[6].x
  mov r4.xy, l(0.500000,0.500000,0,0)
  mov r5.w, l(1.000000)
  mov r3.w, l(0)
  mov r4.w, l(0)
  loop
    uge r6.x, r4.w, cb0[14].x
    breakc_nz r6.x
    utof r6.x, r4.w
    add r6.x, r0.w, r6.x
    div r4.z, r6.x, r1.y
    add r6.xyz, r3.xyzx, r4.xyzx
    mul r6.xyz, r6.xyzx, cb0[1].xyzx
    mad r4.z, r6.z, cb0[3].z, cb0[3].x
    exp r4.z, r4.z
    add r5.z, r4.z, -cb0[2].w
    mad r6.xy, r6.xyxx, l(2.000000, -2.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
    mul r6.xy, r5.zzzz, r6.xyxx
    mul r5.xy, r6.xyxx, cb0[9].xyxx
    dp3 r4.z, r5.xyzx, r5.xyzx
    rsq r4.z, r4.z
    mul r6.xyz, r4.zzzz, r5.xyzx
    
	// depth
dp4 r32.w, r5.xyzw, cb1[5].xyzw

// correction
ld_indexable(texture2d)(float,float,float,float) r33.xyzw, l(0, 0, 0, 0), t125.xyzw
mul r33.w, r32.w, r33.y
add r33.w, r33.w, l(-1.0)
mul r33.w, r33.w, r33.x

//mul r33.w, r33.w, l(0.1)
//add r5.x, r5.x, -r33.w

	
	
	dp4 r7.x, r5.xyzw, cb1[2].xyzw
    dp4 r7.y, r5.xyzw, cb1[3].xyzw
    dp4 r4.z, r5.xyzw, cb1[4].xyzw
    dp4 r6.w, r5.xyzw, cb1[5].xyzw
	
	
	
	
    lt r4.z, l(0.000000), r4.z
    div r7.xy, r7.xyxx, r6.wwww
    add r5.xyz, r5.xyzx, -cb1[0].xyzx
    dp3 r6.w, r5.xyzx, r5.xyzx
    rsq r7.z, r6.w
    mul r5.xyz, r5.xyzx, r7.zzzz
    sqrt r7.z, r6.w
    dp3 r5.x, -r5.xyzx, r6.xyzx
    mul r5.y, r1.x, -r7.z
    mul r5.y, r5.y, l(1.442695)
    exp r5.y, r5.y
    mad_sat r5.z, -r6.w, cb1[0].w, l(1.000000)
    mul r6.x, r7.z, cb1[1].w
    mul r6.x, r6.x, r6.x
    mad r6.x, r6.x, l(0.700000), l(1.000000)
    div r5.z, r5.z, r6.x
    mad r6.x, r7.z, cb1[1].w, l(1.400000)
    div r6.x, l(1.400000), r6.x
    mul r6.y, r6.x, r6.x
    mad r6.x, -r6.x, r6.x, l(1.000000)
    mad r5.x, r6.x, r5.x, r6.y
    dp2 r6.x, r7.xyxx, r7.xyxx
    add r6.x, -r6.x, l(1.000000)
    max r6.x, r6.x, l(0.000000)
    mul r6.x, r6.x, r6.x
    mad r5.x, -r2.w, r5.x, r1.w
    log r5.x, r5.x
    mul r5.x, r5.x, l(1.500000)
    exp r5.x, r5.x
    div r5.x, r1.z, r5.x
    mul r5.x, r5.y, r5.x
    mul r5.x, r1.x, r5.x
    mul r5.x, r6.x, r5.x
    mul r5.x, r5.z, r5.x
    and r4.z, r4.z, r5.x
    add r3.w, r3.w, r4.z
    iadd r4.w, r4.w, l(1)
  endloop
  mul r3.xyz, r3.wwww, cb1[1].xyzx
  div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r1.y
  mul r1.yzw, r0.wwww, r3.xxyz
else
  mov r1.yzw, l(0,0,0,0)
endif
mad r1.yzw, r1.yyzw, cb0[35].wwww, r2.xxyz
f32tof16 r2.xyzw, r1.yzwx
imad r1.xy, r2.zxzz, l(0x00010000, 0x00010000, 0, 0), r2.wyww
store_uav_typed u1.xyzw, r0.xyzz, r1.xxxx
store_uav_typed u2.xyzw, r0.xyzz, r1.yyyy
ret
// Approximately 102 instruction slots used