Search Unity

Particle jobs feedback

Discussion in '2019.1 Beta' started by snacktime, Mar 1, 2019.

  1. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,236
    It's really not that useful an api. A lot of cases where you want to control particles it's in relation to some other data. Data we have no way of getting into the job with the way the flow works. We can't chain the job with say raycasting, we can't access spatial structures or any of our own data.


    Why not something like a callback that passes the particle data in a native container and returns a job handle?
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    1,750
    Hi,

    Thanks for the feedback. We are looking at improving the flexibility of this API before it comes out of experimental. In particular, supporting ForEach jobs and giving you access to JobHandles for dependency chaining.

    I'm not sure why you think you can't get external data into the job though - just pass it to your job struct instance just like you would with any other C# job. Just remember to call ParticleSystem.SetJob again once you've passed data in. If there is a use-case I'm overlooking here, feel free to share some more details.

    There is an example here that passes in a few floats. Modifying it to pass in a NativeArray or whatever, ought to be trivial: https://docs.unity3d.com/2019.1/Doc...IParticleSystemJob.ProcessParticleSystem.html
     
    karl_jones likes this.
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    5,599
    Why do you provide the ParticleSystemJobData.aliveTimePercent in range 0..100, rather than 0..1 (beside that it's called percent)? I would assume it's 0..1 internally?

    Working with 0..1 is much nicer and more flexible imo, plus, if it's internally in that range already, then you could get rid of those multiplications when building the array. Users of the job data then also don't need to remap 0..100 to 0..1 again.
     
  4. snacktime

    snacktime

    Joined:
    Apr 15, 2013
    Posts:
    3,236
    Without being part of a dependency chain the data can't be anything you also use in other jobs. I realize that's not every use case but for example a common use case would be map height data for ground effects. That's my primary use case and I have an existing spatial structure for that, which is used by multiple jobs in another job chain.
     
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    1,750
    It’s 0-100 internally. All the data exposed here is in exactly the format that it is stored in internally because it is the internal data. No copies :)

    It’s 0-100 because 0-1 provided poorer precision for particles with really long lifetimes, if I remember correctly. Tbh I’d prefer it if we simply stored age, but some design decisions cannot be undone. I seem to also recall that this storage format made the maths more efficient in the modules. More multiplies, less divides.

    And thanks for the extra info about the job chaining - it sounds like you will have much more success with this system once we give you some JobHandles to chain jobs with :)
     
unityunity