Hi, I am trying to make a voxel effect on a skeletal mesh and it is somewhat working. My only problem is that when I filter my particles with a neighbor grid 3d to remove overlapping particles, the youngest particle always destroy de old one wich cause my particles animations to restart before it is finished, does anyone know how to make it so that if anew particle spawn on top of an existing particle, the new one gets deleted?
i followed this tutorial but there is a lot of overlapping voxels
this this the HLSL Code I am using (If AddedToGrid = false, I destroy the particle)
AddedToGrid = false;
#if GPU_SIMULATION
// Derive the Neighbor Grid Index from the world position
float3 UnitPos;
NeighborGrid.SimulationToUnit(Position, SimulationToUnit, UnitPos);
int3 Index;
NeighborGrid.UnitToIndex(UnitPos, Index.x,Index.y,Index.z);
// Verify that the derived index is valid.
int3 NumCells;
NeighborGrid.GetNumCells(NumCells.x, NumCells.y, NumCells.z);
if (Index.x >= 0 && Index.x < NumCells.x &&
Index.y >= 0 && Index.y < NumCells.y &&
Index.z >= 0 && Index.z < NumCells.z)
{
int LinearIndex;
NeighborGrid.IndexToLinear(Index.x, Index.y, Index.z, LinearIndex);
// Increment the neighbor count for this cell. This records the number of overlaps
// and can return a higher count than the MaxNeighborsPerCell
int PreviousNeighborCount;
NeighborGrid.SetParticleNeighborCount(LinearIndex, 1, PreviousNeighborCount);
int MaxNeighborsPerCell = 1;
// Limit the number of neighbors added to each cell
if (PreviousNeighborCount < MaxNeighborsPerCell)
{
AddedToGrid = true;
int NeighborGridLinear;
NeighborGrid.NeighborGridIndexToLinear(Index.x, Index.y, Index.z, PreviousNeighborCount, NeighborGridLinear);
int IGNORE;
NeighborGrid.SetParticleNeighbor(NeighborGridLinear, ExecIndex, IGNORE);
}
}
#endif