cnq3/code/renderer/shaders/crp/vl_particles_dispatch.hlsl
myT 30150e889e added sunlight and volumetric lighting
fixed depth linearization
2024-03-29 04:19:38 +01:00

55 lines
1.7 KiB
HLSL

/*
===========================================================================
Copyright (C) 2024 Gian 'myT' Schellenbaum
This file is part of Challenge Quake 3 (CNQ3).
Challenge Quake 3 is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
Challenge Quake 3 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Challenge Quake 3. If not, see <https://www.gnu.org/licenses/>.
===========================================================================
*/
// volumetric lighting: update indirect dispatch buffer for particle injection
#include "common.hlsli"
cbuffer RootConstants
{
uint3 tileResolution;
uint tileBufferIndex;
uint dispatchBufferIndex;
uint particleTileBufferIndex;
}
[numthreads(4, 4, 4)]
void cs(uint3 id : SV_DispatchThreadID)
{
if(any(id >= tileResolution))
{
return;
}
RWByteAddressBuffer dispatchBuffer = ResourceDescriptorHeap[dispatchBufferIndex];
RWByteAddressBuffer tileHitBuffer = ResourceDescriptorHeap[tileBufferIndex];
RWStructuredBuffer<uint3> tileWorkBuffer = ResourceDescriptorHeap[particleTileBufferIndex];
uint tileIndex = FlattenIndex(id, tileResolution);
uint hasParticle = tileHitBuffer.Load(tileIndex * 4);
if(hasParticle != 0)
{
uint workIndex;
dispatchBuffer.InterlockedAdd(0, 1, workIndex);
tileWorkBuffer[workIndex] = id;
}
}