Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question How to optimize a lot of particle systems on mobile devices

Discussion in 'General Graphics' started by electricpunch, Dec 6, 2022.

  1. electricpunch

    electricpunch

    Joined:
    Feb 18, 2014
    Posts:
    22
    Hello, I have a question about particle systems optimization.
    I'm developing Match-3 game and at some points there can be a lot of bombs on the field that can explode at the same time. I have a complex explosion effect with few particle system and this explosion can appear 100-150 times in 1 frame.
    I tried to use dynamic batching to batch the same particle systems, but it does not work. I have 1 material with mobile/particles/additive shader and attached to all particle systems, but each particle system adds 1 drawcall anyway. I know that there is a feature to use 1 particle system and Emit in different positions, but my effect is complex, i.e. I'm using emission by curve and start delay and EmitParams doesn't have it.
    I want to know if it is possible to have 1 drawcall for 100 similar particle systems on scene at the same time?
    Thanks in advance.
     
  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,299
    If your systems share the same material, all the material set-up should be batched, and you should see far fewer SetPass calls than Draw Calls.

    Particle Systems always use dynamic batching. All the geometry for all visible systems is built into 1 large buffer, so we can do very fast draw calls with minimal state changing. It's similar in theory to how static batching works:

    * Setup material state
    * Bind vertex buffers
    * Draw each system (the only state that changes between the draw calls is the offset into the shared vertex buffer)

    The only real caveat is that your systems must be drawn together, so, if some other object is drawn in between the particle effects, it will break the batches and cause more SetPass calls.

    Draw Calls should be very cheap if the SetPass calls are shared.

    There is a bit more info here: https://docs.unity3d.com/Manual/DrawCallBatching.html
     
  3. electricpunch

    electricpunch

    Joined:
    Feb 18, 2014
    Posts:
    22

    Thanks for answer. Now I understand...I just looked at the drawcalls indicator and it was more than 1000 that's why I thought that batching not working.
    In this case, the problem of performance loss not due to batching, but due to overdraw. Explosion effect has several nested particle systems, each with transparent areas, and they overlap each other. As I understand, there is no solution to this problem other than simplifying the effects or converting the particle system to sprite sheet and use animation.
     
  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,299
    It's possible to render things like particles at a reduced resolution (eg 1/2), and then composite them over the full-resolution scene, to reduce the fill-rate requirements to 25% (and therefore reducing overdrawn pixels by the same amount).

    However, Unity doesn't provide a good built-in solution for this in the built-in render pipeline. And I'm not sure if URP/HDRP provides anything (sorry). It could be worth looking into though. Last I heard, there were Asset Store solutions for this for the built-in renderer, at least.

    Other ideas:
    * have you got empty space around your particle billboard textures? Minimize this!
    * reduce particle counts :(
    * use Max Particle Size in the renderer module, so close/large particles don't overdraw large parts of the screen.