Search Unity

Batching particlesystems

Discussion in 'General Graphics' started by ElysianOne, Dec 18, 2018.

  1. ElysianOne

    ElysianOne

    Joined:
    Aug 16, 2017
    Posts:
    7
    Hey all,

    I'm working on a little program to generate stars. Each star is instantiated at runtime and is comprised of a single-particle particlesystem. Currently, I have just four different types of stars, each with their own material.

    For some reason, my batch counts go sky high whenever I run the program, and it seems as though the particlesystems aren't batching at all. Every new star creates a new batch, quickly reaching the 1000s. Obviously this is a nightmare for performance, any idea why the particlesystems aren't batching dynamically?

    upload_2018-12-18_16-54-52.png

    Thanks for your time!
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    Why don't you draw all stars of the same material with just one ParticleSystem? It should be more efficient, performance any memory wise, than having a gazillion unique particle system instances.

    The ParticleSystem API allows you to emit a star at a specific position. Rather than instantiating a star, you would emit that one with ParticleSystem.Emit:
    https://docs.unity3d.com/ScriptReference/ParticleSystem.Emit.html
     
    karl_jones and richardkettlewell like this.
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    FWIW, if the systems use the same material, they should batch, but as Peter suggests, you would be far smarter to put all stars into one particle system.

    Even if batching was working, this is a very inefficient setup. You will see far better memory usage and performance by using only 1 system.
     
    Peter77 likes this.