2020-06-18 02:19:34 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
2024-01-13 21:40:13 +00:00
|
|
|
Copyright (C) 2024 Gian 'myT' Schellenbaum
|
2020-06-18 02:19:34 +00:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
===========================================================================
|
|
|
|
*/
|
2024-07-02 00:06:15 +00:00
|
|
|
// GPU particle system: emitter and particle free list initialization
|
2020-06-18 02:19:34 +00:00
|
|
|
|
|
|
|
|
2024-01-13 21:40:13 +00:00
|
|
|
#include "common.hlsli"
|
2024-07-02 00:06:15 +00:00
|
|
|
#include "scene_view.h.hlsli"
|
2020-06-18 02:19:34 +00:00
|
|
|
|
|
|
|
|
2024-03-29 03:19:27 +00:00
|
|
|
cbuffer RootConstants
|
2020-06-18 02:19:34 +00:00
|
|
|
{
|
2024-07-02 00:06:15 +00:00
|
|
|
uint emitterBufferIndex;
|
|
|
|
uint deadBufferIndex;
|
|
|
|
uint emitterIndex;
|
|
|
|
uint firstParticle;
|
|
|
|
uint particleCount;
|
|
|
|
float maxSeconds;
|
2024-03-29 03:19:27 +00:00
|
|
|
}
|
|
|
|
|
2024-07-02 00:06:15 +00:00
|
|
|
[numthreads(64, 1, 1)]
|
2024-03-29 03:19:27 +00:00
|
|
|
void cs(uint3 id : SV_DispatchThreadID)
|
|
|
|
{
|
2024-07-02 00:06:15 +00:00
|
|
|
if(id.x >= particleCount)
|
2022-12-28 19:49:18 +00:00
|
|
|
{
|
2024-03-29 03:19:27 +00:00
|
|
|
return;
|
2022-12-28 19:49:18 +00:00
|
|
|
}
|
|
|
|
|
2024-07-02 00:06:15 +00:00
|
|
|
if(id.x == 0)
|
2024-03-29 03:19:27 +00:00
|
|
|
{
|
2024-07-02 00:06:15 +00:00
|
|
|
RWStructuredBuffer<ParticleEmitter> emitterBuffer = ResourceDescriptorHeap[emitterBufferIndex];
|
|
|
|
ParticleEmitter e;
|
|
|
|
e.deadCount = particleCount;
|
|
|
|
e.firstIndex = firstParticle;
|
|
|
|
e.liveCount = 0;
|
|
|
|
e.liveCount2 = 0;
|
|
|
|
e.totalCount = particleCount;
|
|
|
|
e.emitCount = 0;
|
|
|
|
e.maxSeconds = maxSeconds;
|
|
|
|
emitterBuffer[emitterIndex] = e;
|
2024-03-29 03:19:27 +00:00
|
|
|
}
|
2024-07-02 00:06:15 +00:00
|
|
|
|
|
|
|
RWStructuredBuffer<uint> deadBuffer = ResourceDescriptorHeap[deadBufferIndex];
|
|
|
|
deadBuffer[firstParticle + id.x] = particleCount - 1 - id.x;
|
2020-06-18 02:19:34 +00:00
|
|
|
}
|