Search Unity

Particle System Bounds too large - dynamic lights influence

Discussion in 'General Graphics' started by AlcoleponeHome, Feb 11, 2020.

  1. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    I am finding the bounds calculated for a particle system is too large. I can view the bounds and the volume appears much to large for the particles drawn. I believe this causes a dynamic lighting issue with the shader used on the particles. Due to the large bounds some "important" lights override closer non important lights and cause the lighting of the particle to pop harshly. Because the bounds are too large the important lights radius doesn't reach the particles inside the bound, and so the important lights do not affect the final lighting of the particle.

    Is there a way i can manually override the bounds of the system to reduce it?
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    Why do you think the bounds are too large? Could you share the system?
     
    richardkettlewell likes this.
  3. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    I'll need to post the system later tonight, but i can see via wireframe the particles occupy a much smaller area the yellow bounds box that the system uses.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    If it's a procedural system then the bounds are the max size the system will become during its lifetime. I'll need to see the system to say for sure.
     
  5. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    am i right in assuming the bounds are used to check which lights should affect a system?
     
  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    richardkettlewell likes this.
  7. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    here is a picture of the system, the bounds seems particularly large, can i over ride the values and set the bounds myself?
    upload_2020-2-24_21-20-32.png
     
  8. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    actually setting to world space seemed to have helped...but i'll lose some performance this way?

    upload_2020-2-24_21-22-45.png
     
  9. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Where possible, we auto-calculate the max possible bounds of a system. It uses the max speed and lifetime, etc.

    Where not possible, we build a box by building it from the position of every particle.

    The latter is slower, but guarantees a minimal box. The auto-calculation is sometimes a bit “generous”.

    This is what you are seeing.

    There is currently no clean way to switch between modes, but, as you’ve found, setting certain properties affects which mode is used. Using certain modules also affects it, such as limit velocity, or collision. And modifying any property from script while the effect is playing.
     
    karl_jones likes this.
  10. AlcoleponeHome

    AlcoleponeHome

    Joined:
    Jun 9, 2018
    Posts:
    47
    seems a shame to lose performance in order to get a smaller bounds : (...
     
  11. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    340
    Hi !

    Would it be possible to disable this bounds calculation and set my own by script ?
     
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    No this is not possible. Why do you want to do this?
     
  13. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    340
    I'm moving particle along a spline, and sometime the particles are not displayed while the camera is very near (inside the bounds)
    But if I rotate the camera toward the origin of the particle emiter, than they show up again.
    Since my spline is not moving I know the bounds, and I wanted to set this bounding box to the particle system once en for all and see if it could fix it... else recomputing the bounds to always be in front of the camera would be my second option.

    But since it's not possible... I'll try to find what else could cause this problem.
     
  14. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    If that's an issue with the bounds then I would say it's a bug although it doesn't sound like that's the issue.
    Could it be the camera near clipping plane?
     
  15. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    340
    It's not the clipping plane.

    I have a first person controller on the camera.
    When the particles are gone, I just have to rotate the camera to look away (in the direction of the particles transform origin), then I rotate back and they are visible again.

    Note : this is occuring only when I stop the simulation and restart it on the fly with a new particles emission rate (+prewarm).

    EDIT : if the transform origin of the particles emitter is in the camera fov, the bug is gone.
     
  16. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    What culling mode do you have on the system?
    https://docs.unity3d.com/ScriptReference/ParticleSystem.MainModule-cullingMode.html
    Try setting it to https://docs.unity3d.com/ScriptReference/ParticleSystemCullingMode.AlwaysSimulate.html
     
    Alesk likes this.
  17. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    340
    karl_jones and richardkettlewell like this.
  18. OUTERDARKNESS

    OUTERDARKNESS

    Joined:
    Feb 27, 2013
    Posts:
    35
    I tried 'Automatic' but the bounds did not scale. Particles are set in code using ParticleSystem.SetParticles, but the bounds do no represent the actual bounds of the particles. If the camera frustum leaves the PS bounds, the particles do not render.



    If the bounds cannot be set through code, how does one get around this error?
     
  19. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    That's a bug. Could you please file a bug report.
     
    richardkettlewell likes this.
  20. OUTERDARKNESS

    OUTERDARKNESS

    Joined:
    Feb 27, 2013
    Posts:
    35
    Karl,
    After some noodling, I discovered that the bounds would update if I enabled (then disabled) the emission module after calling SetParticles. Hope this helps.


    Code (CSharp):
    1. PS.SetParticles(particles, particles.Length);
    2.  
    3. var emis = PS.emission;
    4. emis.enabled = true;
    5. emis.enabled = false;
     
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    Could you file a bug report so we can look Into it? We really need an example project for this as it's not something we have encountered.
     
  22. OUTERDARKNESS

    OUTERDARKNESS

    Joined:
    Feb 27, 2013
    Posts:
    35
    I took the time to pack up a nice clean project to demo the behavior, and submitted a bug report.
    (Case 1273773)
     
    richardkettlewell and karl_jones like this.
  23. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,276
    Hey, I took a look at the bug. Its a problem with our procedural mode. When you call SetParticles, we invalidate the mode so that it uses a different approach to generate the bounds however when you call Play, we reset this flag and it goes back to procedural. We will try and get a fix out in the future, for now you can fix this by calling Play and then SetParticles instead of SetParticles and then Play.
     
    richardkettlewell likes this.
  24. M4R5

    M4R5

    Joined:
    Apr 11, 2013
    Posts:
    33
    Has this been fixed? As of what version?
     
  25. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285