Search Unity

Particle System "Rate over Distance" doesn't scale with the rest of the system

Discussion in 'General Graphics' started by Devil_Inside, Feb 23, 2022.

  1. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    In my game, I need to scale the world to different sizes. I've noticed that while a particle system can have the "Scaling mode" set to Hierarchy, the behavior of the system won't be the same when scaled down.
    I haven't checked all the modules, but specifically the "Emission - Rate over Distance" needs to be adjusted manually if I want a scaled particle system to behave the same.
    Here's an example:


    As you can see, the second and third examples have the world scaled to 0.1, however the "Rate over Distance" needs to be multiplied by 10 for it to have the same effect.
    I think that the "unit" used internally by the "Rate over Distance" should use the same scale as the particle system, so the particle system could look the same at any scale. At least an option (a checkbox) that would enable proper scaling would be very welcome.
     
    mgear likes this.
  2. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    Just experienced the same issue.
    The point is that rateOverDistance seems to be in feet, not in Meter. This produces a problem when calculating the maxParticles you need when the distanceToTravel is known (like it may be in a beam).

    Code (CSharp):
    1.    
    2. // this is because particlesPerMeter are actually particles/feet it seems
    3.       pMain.maxParticles = Mathf.FloorToInt(maxDist * particlesPerMeter* 3.28084f);
    4.  
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    It's in "units", which is whatever you decide 1 unit to mean in Unity. (i.e. it depends if you're modelling your world in mm,cm,m,yards, etc etc)

    We decided not to make it scale with the system so that we didn''t break this promise (1 unit = 1 rate over distance's worth of particles)

    I agree it may be nice to have an option to scale it based on system scale, but that does lead to other questions, such as how would it behave if the system is scaled non-uniformly?
     
  4. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    Nope. The whole engine counts in meters and seconds, just because they are the units used in every physical calculation. The standard. So anyone working with Unity assumes these Units. Having feet instead of meters in RateOverDistance is breaking this convention.
     
  5. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I develop the Particle System at Unity. And have done for a lot of years.

    Parts of HDRP (as an example) do indeed require you to use meters for some of its physical calculations. I'm sure some other parts of the engine require certain SI units too. But almost nothing in the Particle System cares what units you represent your world in. The exception is the particle physics gravity. It's hardcoded to 9.81m/s/s.

    I can assure you there is no concept of feet/inches anywhere in the Particle System. 100%.
    If you think the Rate over Distance is being applied incorrectly though, you can submit a bug and we'll investigate your use case.
     
  6. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Thanks for the reply! @richardkettlewell
    In my scenario - when I scale the particle system, I expect it to look the same, just at a different scale. The current behavior of the Rate over Distance module doesn't allow for that and I need to add scripts to each particle system that will override the Rate over Distance value based on scale.
    Are there really scenarios where you wouldn't want the particle system to maintain it's look when scaled?

    As for the non-uniform scale - I'm not sure how exactly this module is implemented, but why can't it use non-uniform scale in such a way, that the distance on each axis is scaled accordingly before the total distance is calculated?
     
  7. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    EDIT: Holy Maria. You are right.It is the scaling. I scaled the whole thing by 3 at some point and that was the issue.
    Just because I think I deserve it, I let my blubbering exist for now.

    Previous complain:
    The rest of the engine does count in Meters.
    Here is a quiz. So when i set RateOverDist= 1 and move my ParticleEmitter in it's forward axis from 0 to 10, how many Particles do I get?
    Spoiler: It is not 10 (or 11) as you would expect.

    Sorry for being a bit salty.
    But this is what I experience every day going deeper into any Unity sub system and really use it. They never tried it out in a real world (read: Game) application. So it is our task to stumble over all these inconsistencies.

    I found this by coding a beam. It wasn't working anymore after changing weapon distance. I debugged the hell out of it, of course I thought it was something else, maybe physics, maybe some CoRoutine timing... whatever. Until finally I calculated the particles needed. Uups 5k? So much?
    I decided to set maxParticles dependent on distance (in code) and pressed F7 happy to surely have found this bugger.
    Yeah. After testing another hour or so I found it's around one third of weapon distance. Luckily I had a good day and it made a pling- sound Fx right in my head. So I multiplied by 3.nnn and all was good.

    The point of all my blabber is not to insult you.
    It is just that the more I work with Unity, the more it seems not to be an engine. It is a Tool Box. You have lots of tools, made by different people, who never have seen each other. And never directly worked together. And most importantly: Never used their tools to create anything. And this is my concern.

    90% of day-to-day problems of working with Unity wouldn't be there if you engine developers would have people around you actually using your engine. And I don't say that out of thin air but from first hand experience. You quickly realize what people *really* need after they come after you.

    Nevertheless. Have a nice day. Sorry for my insulting tone.
     
    Last edited: Jun 25, 2022
  8. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    If you submit a bug report we will investigate it.

    I don't know - we have so many people with so many use-cases. Based on the volume alone, I'm inclined to guess yes :)
    Plus, if we change it now, we would potentially mess with people's pre-authored content, which would be undesirable.

    It's a good point - I think you're right that we could/should do it this way.

    I'll add something to our roadmap for an option to allow rate over distance to be affected by scale. Thanks for the feedback!
     
  9. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    Awesome! Thank you!
     
    richardkettlewell likes this.
  10. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    All good! It was just my scaling. Have a nice day.