// CS Shadows Lights + Light Shafts (DSS)
// Generated by Microsoft (R) HLSL Shader Compiler 10.0.10011.16384
//
//   using 3Dmigoto v1.3.11 on Tue Mar 05 19:41:32 2019
//
//
// Buffer Definitions:
//
// cbuffer _cbSharedPerViewData
// {
//
//   struct S_cbSharedPerViewData
//   {
//
//       row_major float4x4 mProjection;// Offset:    0
//       row_major float4x4 mProjectionPrev;// Offset:   64
//       row_major float4x4 mViewToViewport;// Offset:  128
//       row_major float4x4 mViewToWorld;// Offset:  192
//       row_major float4x4 mViewToWorldPrev;// Offset:  256
//       row_major float4x4 mFxWorldToSampleSpace;// Offset:  320
//       float4 vViewRemap;             // Offset:  384
//       float4 vViewDepthRemap;        // Offset:  400
//       float4 vEyeVectorUL;           // Offset:  416
//       float4 vEyeVectorLR;           // Offset:  432
//       float4 vEyeVectorDelta;        // Offset:  448
//       float4 vPixelToEyeVectorScaleBias;// Offset:  464
//       float4 vViewSpaceUpVector;     // Offset:  480
//       float4 vViewportSize;          // Offset:  496
//       float4 vTesselationEnabled;    // Offset:  512
//       float4 vEngineTime;            // Offset:  528
//       uint nFrameCounter;            // Offset:  544
//       float4 vShaderColor0;          // Offset:  560
//       float4 vShaderColor1;          // Offset:  576
//       float4 vShaderColor2;          // Offset:  592
//       float4 vShaderColor3;          // Offset:  608
//       float4 vShaderColor4;          // Offset:  624
//       float4 vClipPlane;             // Offset:  640
//       float4 vClipPlane0;            // Offset:  656
//       float4 vClipPlane1;            // Offset:  672
//       float4 vClipPlane2;            // Offset:  688
//       float4 vClipPlane3;            // Offset:  704
//       float4 vClipPlane4;            // Offset:  720
//       float4 vClipPlane5;            // Offset:  736
//       float4 vMippedDepthRemap;      // Offset:  752
//       float4 vSpecularOcclusionSettings;// Offset:  768
//       float4 vSaturatedAmbientOcclusionSettings;// Offset:  784
//       float4 vLightModelSettings;    // Offset:  800
//       float4 vHDRScale;              // Offset:  816
//       float4 vTweakableShaderParams; // Offset:  832
//       float4 vAtmosphericScatteringParameters;// Offset:  848
//       float4 vAtmosphericScatteringParameters2;// Offset:  864
//       float4 vAtmosphericScatteringParameters3;// Offset:  880
//       float3 vAtmosphericScatteringMieBeta;// Offset:  896
//       float3 vAtmosphericScatteringRayleighBeta;// Offset:  912
//       float3 vAtmosphericScatteringShadowedMieBeta;// Offset:  928
//       float3 vAtmosphericScatteringShadowedRayleighBeta;// Offset:  944
//       float3 vAttenuatedSunColor;    // Offset:  960
//       float3 vSunDirectionVS;        // Offset:  976
//       row_major float4x4 mViewToGlobalShadowVSPT;// Offset:  992
//       float4 vWindDirectionAndStrength;// Offset: 1056
//       float4 vWindDirectionAndStrengthPrev;// Offset: 1072
//       float4 vWindInitialDirectionAndStrength;// Offset: 1088
//       float4 vFxFadeParameters;      // Offset: 1104
//       float2 vFxSize;                // Offset: 1120
//       int nEnableGBufferSpecPowerAdjustment;// Offset: 1128
//       int nNumCSMCascades;           // Offset: 1132
//       float fCSMFadeAdd;             // Offset: 1136
//       int nEnableClothBias;          // Offset: 1140
//       int nEnableCloth;              // Offset: 1144
//       int2 viNumTiles;               // Offset: 1152
//       int nLightTileDebugFlags;      // Offset: 1160
//       int nEnableBoxReflections;     // Offset: 1164
//       int nSelectedBoxReflectionId;  // Offset: 1168
//       int nEnableAtmosphericScatteringBackdrop;// Offset: 1172
//       int nEnableSampleFromUICameraBackbuffer;// Offset: 1176
//       int nFallbackRoomMask;         // Offset: 1180
//       float4 vClearColor;            // Offset: 1184
//       float3 vGlobalLightDirectionVS;// Offset: 1200
//       float3 vGlobalLightFrontColor; // Offset: 1216
//       float3 vGlobalLightBackColor;  // Offset: 1232
//       float4 vShadowAtlasSize;       // Offset: 1248
//       float2 vShadowPoissonScale;    // Offset: 1264
//       int nShadowSpotKernel;         // Offset: 1272
//       int nShadowCSMKernel;          // Offset: 1276
//       float4 vJitter;                // Offset: 1280
//       float4 vUnjitter;              // Offset: 1296
//       int nHashedAlphaPeriod;        // Offset: 1312
//       int nIsRenderingOffscreen;     // Offset: 1316
//       int nMirrorsDisabled;          // Offset: 1320
//
//   } cbSharedPerViewData;             // Offset:    0 Size:  1324
//
// }
//
// cbuffer _cbCalculateEpipolarInscatter
// {
//
//   struct S_cbCalculateEpipolarInscatter
//   {
//
//       int nNumCSMCascades;           // Offset:    0
//       float fDitherOffset;           // Offset:    4
//       float fCSMFadeAdd;             // Offset:    8
//       float4 vSignedFullResToUnsignedHalfRes;// Offset:   16
//       float4 vRow0;                  // Offset:   32
//       float4 vRow1;                  // Offset:   48
//       float4 vRow2;                  // Offset:   64
//       float4 vBleedReduction;        // Offset:   80
//       float4 avParams[9];            // Offset:   96
//       float3 vSunColor;              // Offset:  240
//       float3 vSunDirWS;              // Offset:  256
//       float3 vSunDirVS;              // Offset:  272
//       float2 vSunUVPos;              // Offset:  288
//       float2 vUVClampingUpper;       // Offset:  296
//       row_major float4x4 mViewToWorld;// Offset:  304
//       row_major float4x4 mViewToPrevViewProj;// Offset:  368
//       int2 viHalfRes;                // Offset:  432
//       float2 vRcpHalfRes;            // Offset:  440
//       int2 viHalfResRT;              // Offset:  448
//       float2 vRcpHalfResRT;          // Offset:  456
//
//   } cbCalculateEpipolarInscatter;    // Offset:    0 Size:   464
//
// }
//
// Resource bind info for uavWorkItems
// {
//
//   uint $Element;                     // Offset:    0 Size:     4
//
// }
//
//
// Resource Bindings:
//
// Name                                 Type  Format         Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// samplerPointClamp                 sampler      NA          NA    0        1
// samplerLinearClamp                sampler      NA          NA    4        1
// samplerLinearClampWrap            sampler      NA          NA   15        1
// srvDepthBuffer                    texture  float4          2d    0        1
// srvEpipolarTexture                texture  float4          2d    1        1
// srvPrevHalfResInscatterTexture    texture  float4          2d    2        1
// uavRectangularHalfResOutputTexture        UAV  float4          2d    0        1
// uavWorkItems                          UAV  struct      append    1        1
// _cbSharedPerViewData              cbuffer      NA          NA    2        1
// _cbCalculateEpipolarInscatter     cbuffer      NA          NA    5        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 cb2[32], immediateIndexed
dcl_constantbuffer cb5[29], immediateIndexed
dcl_sampler s0, mode_default
dcl_sampler s4, mode_default
dcl_sampler s15, 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_uav_typed_texture2d (float,float,float,float) u0
dcl_uav_structured u1, 4
dcl_input vThreadID.xy
//dcl_temps 10
dcl_temps 38



dcl_thread_group 8, 8, 1

dcl_resource_texture2d (float,float,float,float) t125

// Correct cbCalculateEpipolarInscatter.vSunUVPos.xy -DarkStarSword
ld_indexable(texture2d)(float,float,float,float) r34.xyzw, l(0, 0, 0, 0), t125.xyzw
mov r36.xyzw, cb5[18].xyxx
mad r36.x, r34.x, l(0.5), r36.x

ige r0.xy, vThreadID.xyxx, cb5[27].xyxx
or r0.x, r0.y, r0.x
if_nz r0.x
  ret
endif
ishl r0.xy, vThreadID.xyxx, l(1, 1, 0, 0)
mov r0.zw, l(0,0,0,0)
ld_indexable(texture2d)(float,float,float,float) r0.z, r0.xyzw, t0.yzxw
mad r0.z, cb2[24].z, r0.z, -cb2[24].y
div r1.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z

itof r0.xy, r0.xyxx
mad r2.xy, r0.xyxx, cb2[29].xyxx, cb2[29].zwzz
mov r2.z, l(-1.000000)

// DHR ShaderRegex GLACIER Pattern 1:
add r35.x, r1.w, -r34.y
mul r35.x, r34.x, r35.x
div r35.x, r35.x, cb2[0].x
mul r35.x, r35.x, r1.w
add r2.x, r2.x, -r35.x

mul r3.xyz, r1.wwww, r2.xyzx
add r0.xy, r0.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000)
mad r0.zw, r0.yyyx, cb2[31].yyyx, -r36.yyyx
lt r2.zw, l(0.000000, 0.000000, 0.000000, 0.000000), r0.wwwz
and r2.zw, r2.zzzw, l(0, 0, 0x3f800000, 0x3f800000)
add r4.xy, r2.zwzz, -r36.xyxx
div r4.xy, r4.xyxx, r0.wzww
lt r3.w, r4.x, r4.y
mad_sat r0.zw, r4.xxxy, r0.zzzw, r36.yyyx
add r4.x, -r0.z, l(4.000000)
mad r0.z, r0.z, l(2.000000), l(-3.000000)
mad r0.z, r0.z, r2.z, r4.x
mad r2.z, -r0.w, l(2.000000), l(3.000000)
mad r0.w, r2.z, r2.w, r0.w
mul r0.zw, r0.zzzw, l(0.000000, 0.000000, 128.000000, 128.000000)
movc r0.z, r3.w, r0.z, r0.w
round_z r0.w, r0.z
mad r2.zw, r0.wwww, l(0.000000, 0.000000, 0.00781250000, 0.00781250000), l(0.000000, 0.000000, -1.500000, -2.500000)
add_sat r2.zw, -|r2.zzzw|, l(0.000000, 0.000000, 1.500000, 1.500000)
add r4.xy, r2.zwzz, -r36.xyxx
lt r4.zw, r4.xxxy, l(0.000000, 0.000000, 0.000000, 0.000000)
and r4.zw, r4.zzzw, l(0, 0, 0x3f800000, 0x3f800000)
add r4.zw, r4.zzzw, -r36.xxxy
div r4.zw, r4.zzzw, r4.xxxy
max r0.w, r4.w, r4.z
max r0.w, r0.w, l(0.000000)
mad r4.xy, r0.wwww, r4.xyxx, r36.xyxx
add r2.zw, r2.zzzw, -r4.xxxy
mad r4.xy, r0.xyxx, cb2[31].xyxx, -r4.xyxx
dp2 r0.w, r4.xyxx, r2.zwzz
dp2 r2.z, r2.zwzz, r2.zwzz
max r2.z, r2.z, l(1.000000012E-007)
div_sat r0.w, r0.w, r2.z
mul r2.z, r0.w, l(127.000000)
mad r4.x, r0.w, l(127.000000), l(0.500000)
add r4.y, r0.z, l(0.500000)
frc r5.y, r2.z
frc r5.z, r0.z
mul r0.zw, r4.xxxy, l(0.000000, 0.000000, 0.00390625000, 0.00195312500)
gather4_indexable(texture2d)(float,float,float,float) r4.xyzw, r0.zwzz, t1.xyzw, s15.x
gather4_indexable(texture2d)(float,float,float,float) r6.xyzw, r0.zwzz, t1.xyzw, s15.y
gather4_indexable(texture2d)(float,float,float,float) r7.xyzw, r0.zwzz, t1.xyzw, s15.z
gather4_indexable(texture2d)(float,float,float,float) r8.xyzw, r0.zwzz, t1.xyzw, s15.w
min r0.z, r1.w, l(50000.000000)
div r0.w, l(50.000000), r0.z
add r8.xyzw, -r0.zzzz, r8.wzxy
mul r8.xyzw, r0.wwww, r8.xyzw
mad r8.xyzw, -r8.xyzw, r8.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
max r8.xyzw, r8.xyzw, l(0.000000, 0.000000, 0.000000, 0.000000)
mad r8.xyzw, r8.xyzw, r8.xyzw, l(9.999999960E-013, 9.999999960E-013, 9.999999960E-013, 9.999999960E-013)
add r0.zw, -r5.zzzy, l(0.000000, 0.000000, 1.000000, 1.000000)
mul r9.x, r0.z, r0.w
mul r9.yz, r0.zzwz, r5.yyzy
mul r9.w, r5.z, r5.y
mul r5.xyzw, r8.xyzw, r9.xyzw
dp4 r0.z, r5.xyzw, l(1.000000, 1.000000, 1.000000, 1.000000)
dp4 r4.x, r4.wzxy, r5.xyzw
dp4 r4.y, r6.wzxy, r5.xyzw
dp4 r4.z, r7.wzxy, r5.xyzw
div r0.w, l(1.000000, 1.000000, 1.000000, 1.000000), r0.z
mul r1.xyz, r0.wwww, r4.xyzx
mul r5.xyzw, r3.yyyy, cb5[24].xyzw
mad r5.xyzw, r3.xxxx, cb5[23].xyzw, r5.xyzw
mad r3.xyzw, r3.zzzz, cb5[25].xyzw, r5.xyzw
add r3.xyzw, r3.xyzw, cb5[26].xyzw
div r3.xyz, r3.xyzx, r3.wwww
mad r2.zw, r3.xxxy, cb5[1].xxxy, cb5[1].zzzw
itof r3.xy, cb5[28].xyxx
mad r3.z, cb2[24].z, r3.z, -cb2[24].y
div r3.z, l(1.000000, 1.000000, 1.000000, 1.000000), r3.z
mad r5.xy, r2.zwzz, r3.xyxx, l(-0.500000, -0.500000, 0.000000, 0.000000)
round_ni r5.xy, r5.xyxx
add r5.zw, r5.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000)
div r5.zw, r5.zzzw, r3.xxxy
min r5.zw, r5.zzzw, cb5[18].zzzw
gather4_indexable(texture2d)(float,float,float,float) r6.xyzw, r5.zwzz, t2.xyzw, s4.w
add r6.xyzw, -r3.zzzz, r6.wzxy
min r5.zw, |r6.yyyw|, |r6.xxxz|
min r3.w, r5.w, r5.z
eq r6.xyzw, r3.wwww, |r6.xyzw|
and r5.zw, r6.xxxx, l(0, 0, 0x3f000000, 0x3fc00000)
movc r5.zw, r6.yyyy, l(0,0,1.500000,1.500000), r5.zzzw
movc r5.zw, r6.zzzz, l(0,0,1.500000,0.500000), r5.zzzw
movc r5.zw, r6.wwww, l(0,0,0.500000,0.500000), r5.zzzw
add r5.xy, r5.zwzz, r5.xyxx
div r3.xy, r5.xyxx, r3.xyxx
min r3.xy, r3.xyxx, cb5[18].zwzz
sample_l_indexable(texture2d)(float,float,float,float) r5.xyzw, r3.xyxx, t2.xyzw, s0, l(0.000000)
mul r3.xyw, r2.yyyy, cb2[13].xyxz
mad r3.xyw, r2.xxxx, cb2[12].xyxz, r3.xyxw
add r3.xyw, r3.xyxw, -cb2[14].xyxz
lt r2.x, l(1000.000000), r3.z
dp3 r2.y, r3.xywx, r3.xywx
rsq r2.y, r2.y
mul r2.y, r2.y, r3.w
lt r2.y, r2.y, l(0.100000)
and r2.x, r2.y, r2.x
min r2.y, r3.z, l(50000.000000)
min r3.x, r5.w, l(50000.000000)
add r2.y, r2.y, -r3.x
mul r3.x, r3.x, l(0.020000)
lt r2.y, |r2.y|, r3.x
mov_sat r3.xy, r2.zwzz
eq r2.zw, r2.zzzw, r3.xxxy
and r2.z, r2.w, r2.z
and r2.y, r2.z, r2.y
not r2.z, r2.x
and r2.y, r2.z, r2.y
if_nz r2.y
  mad r0.xy, -r0.xyxx, cb2[31].xyxx, r36.xyxx
  dp2 r0.x, r0.xyxx, r0.xyxx
  sqrt r0.x, r0.x
  mul r0.x, r0.x, l(5.000000)
  min r0.x, r0.x, l(1.000000)
  mul r0.x, r0.x, l(0.850000)
  mad r2.yzw, -r4.xxyz, r0.wwww, r5.xxyz
  mad r1.xyz, r0.xxxx, r2.yzwy, r1.xyzx
else
  lt r0.x, r0.z, l(9.999999939E-009)
  or r0.x, r2.x, r0.x
  if_nz r0.x
    ishl r0.x, vThreadID.y, l(16)
    iadd r0.x, r0.x, vThreadID.x
    imm_atomic_alloc r2.x, u1
    store_structured u1.x, r2.x, l(0), r0.x
    ret
  endif
endif
store_uav_typed u0.xyzw, vThreadID.xyyy, r1.xyzw
ret
// Approximately 143 instruction slots used
