Been trying to find info on this issue but it’s tough due to the words being so general…
I’m noticing that when using a Particle System Trail module, when the particle count goes over 31, the indexing order “along the trail” starts getting out of order.
For example, I have a simple IParticleSystem that sets positions of particles to create a line, my expectation is that in Ribbon Mode (with max 1 ribbon), if I have 8 particles, it should be a chain like this:
0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
I ensure that my Particle System has no emission, does not auto-play. And then in the code that schedules the IParticleSystemParallelFor job, it simply does this once on initialization:
main.maxParticles = nodeCount;
fx.Clear(true);
fx.Emit(nodeCount);
then the job runs and does this to modify the particle positions:
public void Execute(ParticleSystemJobData jobData, int index)
{
var node = nodes[index];
var positions = jobData.positions;
positions[index] = node.positionWS;
var velocities = jobData.velocities;
velocities[index] = node.positionWS - node.prevPositionWS;
var times = jobData.aliveTimePercent;
times[index] = 0.5f;
}
my job code assumes that it is dealing with a long strip (like the 0 to 7 sequence example above), all works fine when my nodeCount (or particle count) is at 31 or below, but when I start to go over 31, I get “stray” particle ribbon strips connecting back, like it is indexing into the particle system incorrectly.
The thing is, I have my own Debug.DrawLines to show my where my segments are using the positions from the job, and they are always correct (never exhibiting the indexing issue the particle system has). So I’m pretty sure that the problem lies within the Particle System.
I’ve also tried each IParticleSystem job type but didn’t find any differences in behaviour. EDIT Also worth noting, I get the same issue when using GetParticles / SetParticles.
Any ideas? sorry to tag you @richardkettlewell I could probably make a repro project of this but need some time to isolate it…
Attached are screenshots showing how the Particle System indexing is out of order. I couldn’t find any number greater than 31 where the indexing is correct…
EDIT On further inspection… it looks like it is always affected in sections of 32, so at 64 particles, it looks like particle 31 is treated as connecting to particle 63, and particle 32 seems to connect to particle 0. Then at 128 particles, I get similar splits but doubled again… and so on…
Is it some issue with internally how Unity dispatches work for the particle systems?



