Particle System C# Job System support

Sure, here you go:

We have entries in the scripting docs for it too but I just checked and it looks like they haven’t been published yet. I will chase this up next week.

UPDATE: the docs are due to go live on approx May 7th!

1 Like

Is it possible to use particle systems with ECS + C# job? Maybe like bullets or explosions effects.
If yes please give me any link to a doc or just any example.

1 Like

Hi, no it’s not possible as far as I’m aware.

1 Like

I think hybred entities will do the job then.
Thank you.

1 Like

Finally got sometime to study Unity Job System (which difficulty is incredibly dwarfed by ECS), but right now (2019.1f) it feels bit redundant to cache all 3 axes of a NativeArray3 to 3 different float arrays and Set them back individually after we’re done manipulating them, I wonder if IParticleSystemJob could provide something like TransformAccess of IJobParallelForTransforml.

I just stress-tested with simple velocity-based homing logic with 100k particles in a bare scene, but the performance actually drops compared to the classic way of get-set particles. As the ParticleSystem.UpdateScriptJob is scheduled sequentially.

Here is my codes using IParticleSystemJob in an ECS project:
I passed the pawns’ positions to the Job .
Job:
struct FollowEffects : IParticleSystemJob
{
[ReadOnly][DeallocateOnJobCompletion]
internal NativeArray Positions;
[ReadOnly][DeallocateOnJobCompletion]
internal NativeArray Rotations;
public void ProcessParticleSystem(ParticleSystemJobData particles)
{

}
}

Below is some codes in my ComponentSystem:

void OnCreateSystem()
{

particleJob = new FollowEffects ();

particlesystem.setJob(particleJob);

}

protected override void OnUpdate()
{

particleJob.Positions = LivingPawns.ToComponentDataArray(Allocator.TempJob);
particleJob.Rotations = LivingPawns.ToComponentDataArray(Allocator.TempJob);

}
When I run the project ,I got array data leak’ error.
How can I pass ComponentDataArray to the particle Job correctly ?

Is it possible to do custom sort of particles using a job? The built in Unity distance sort falls short with alpha blended mesh particles. Is get/set particles still the only way?

̶Y̶e̶s̶ ̶g̶e̶t̶/̶s̶e̶t̶ ̶i̶s̶ ̶t̶h̶e̶ ̶o̶n̶l̶y̶ ̶w̶a̶y̶ ̶t̶o̶ ̶d̶o̶ ̶̶t̶h̶i̶s̶.̶ ̶̶T̶h̶i̶s̶ ̶n̶e̶w ̶f̶e̶a̶t̶u̶r̶e̶ ̶w̶o̶n̶’̶t̶ ̶h̶e̶l̶p̶ ̶y̶o̶u̶ ̶̶y̶e̶t̶,̶ ̶̶a̶l̶t̶h̶o̶u̶g̶h̶ ̶̶m̶̶̶̶a̶y̶b̶e̶ ̶̶i̶t̶ ̶c̶a̶n̶ ̶b̶e̶ ̶u̶s̶e̶d̶ ̶t̶o̶ ̶d̶̶i̶s̶p̶a̶t̶c̶h̶ ̶̶t̶h̶e̶ ̶̶n̶e̶c̶e̶s̶s̶a̶r̶y̶ ̶̶j̶o̶b̶ ̶̶̶c̶̶h̶a̶i̶n̶ ̶o̶n̶c̶e̶ ̶̶w̶e̶ ̶̶a̶l̶̶l̶̶o̶̶w̶̶̶ ̶̶̶̶a̶c̶c̶e̶s̶̶s̶ ̶̶̶t̶o̶ ̶̶t̶h̶e̶ ̶̶j̶o̶b̶h̶a̶n̶d̶l̶e̶.̶.̶̶̶̶̶

EDIT: Actually, it was a bit early in the morning and I wasn’t thinking about this correctly. My first answer was in the context of being able to dispatch a multi-job multi-threaded sort, which you can’t do at the moment. However, you could totally perform a single-threaded sort in the job. you have access to all the elements and could swap them via any sorting algorithm you like :slight_smile:

1 Like

Talking about it, any news of the job handle ? =)

Soon :slight_smile: there will be a new experimental build available once it’s ready.

3 Likes

Is it correct that IParticleSystemJob cannot be compilled with Burst or is that a bug?

I will speak to the Burst team about why this is the case. Thanks for raising it.

1 Like

I’ve spoken with the Burst team and they have advised me how to fix this. The fix is simple and is working well :slight_smile:

1 Like

That’s great! Thanks Richard. Can’t wait to sprinkle some more [BurstCompile] here and there and see the huge speedups :slight_smile:

Hey all, there is a new preview version of this feature now available here: Particle System C# Job System support

Including:

  • Exposed JobHandles, allowing you to chain jobs together
  • ParallelFor support, so 1 system can distribute its work over multiple cores
  • Burst Compiler support
3 Likes

Woah, wasn’t even going to ask for those other features but exactly what I need :slight_smile: Amazing!

1 Like

Thank you ! I’ll test it this whole weekend :slight_smile:

1 Like

Installing the Jobs package causes a compilation error :

Library\PackageCache\com.unity.burst@1.0.4\Editor\BurstAotCompiler.cs(638,32): error CS7036: There is no argument given that corresponds to the required formal parameter ‘exceptionType’ of ‘BuildReport.AddMessage(LogType, string, string)’

Reported here : Unity Issue Tracker - Installing Burst package yields a compilation error

Oh no, indeed that was reported internally too on our latest 2019.3 alpha :frowning:

You can comment out the line in your package cache, or copy the package to a local folder, comment it out, and point the package manager at the local folder.

Annoying, sorry… I will make a new build as soon as this is fixed (unless the fix is made purely in package code).

3 Likes

Thank you ! No problem, just to let you know :wink:

1 Like