3 ${VFXGlobalDeclaration}
6 RWByteAddressBuffer attributeBuffer;
7 ByteAddressBuffer sourceAttributeBuffer;
9 CBUFFER_START(initParams)
10 #if !VFX_USE_SPAWNER_FROM_GPU
11 uint nbSpawned; // Numbers of particle spawned
12 uint spawnIndex; // Index of the first particle spawned
15 uint offsetInAdditionalOutput;
21 #if VFX_USE_ALIVE_CURRENT
22 RWStructuredBuffer<uint> deadListIn;
23 ByteAddressBuffer deadListCount; // This is bad to use a SRV to fetch deadList count but Unity API currently prevent from copying to CB
26 #if VFX_USE_SPAWNER_FROM_GPU
27 StructuredBuffer<uint> eventList;
28 ByteAddressBuffer inputAdditional;
31 ${VFXGeneratedBlockFunction}
33 [numthreads(NB_THREADS_PER_GROUP,1,1)]
34 void CSMain(uint3 groupId : SV_GroupID,
35 uint3 groupThreadId : SV_GroupThreadID)
37 uint id = groupThreadId.x + groupId.x * NB_THREADS_PER_GROUP;
38 #if !VFX_USE_SPAWNER_FROM_GPU
39 id += groupId.y * dispatchWidth * NB_THREADS_PER_GROUP;
42 #if VFX_USE_SPAWNER_FROM_GPU
43 uint maxThreadId = inputAdditional.Load((offsetInAdditionalOutput * 2 + 0) << 2);
44 uint currentSpawnIndex = inputAdditional.Load((offsetInAdditionalOutput * 2 + 1) << 2) - maxThreadId;
46 uint maxThreadId = nbSpawned;
47 uint currentSpawnIndex = spawnIndex;
50 #if VFX_USE_ALIVE_CURRENT
51 maxThreadId = min(maxThreadId, deadListCount.Load(0x0));
52 #elif VFX_USE_SPAWNER_FROM_GPU
53 maxThreadId = min(maxThreadId, nbMax); //otherwise, nbSpawned already clamped on CPU
58 #if VFX_USE_SPAWNER_FROM_GPU
59 int sourceIndex = eventList[id];
61 uint particleIndex = id + currentSpawnIndex;
63 #if !VFX_USE_SPAWNER_FROM_GPU
64 ${VFXComputeSourceIndex}
67 #if VFX_USE_PARTICLEID_CURRENT
68 particleId = particleIndex;
70 #if VFX_USE_SEED_CURRENT
71 seed = WangHash(particleIndex ^ systemSeed);
76 #if VFX_USE_ALIVE_CURRENT
79 uint deadIndex = deadListIn.DecrementCounter();
80 uint index = deadListIn[deadIndex];
84 uint index = particleIndex;