Search Unity

Game slows down when observing particle effects up close

Discussion in 'General Graphics' started by Anonymodesu, Dec 11, 2018.

  1. Anonymodesu

    Anonymodesu

    Joined:
    Jul 1, 2018
    Posts:
    8
    I've been playing around with free particle effects from the asset store and came up with this portal effect.
    1.png
    I then stacked 20 of them in one spot. There's a reasonable fps drop. 2.png

    However, if I rotate the camera so that the particles are up close, the game slows down even further. 3.png

    Is anyone able to explain this? The particle effects involved have materials of the Particles/Additive type and don't emit light.
     
  2. Torbach78

    Torbach78

    Joined:
    Aug 10, 2013
    Posts:
    296
    overdraw causing a bottleneck on fillrate
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Every pixel covered by a triangle has a cost. More pixels needed to draw an object, the more the cost. When you have a particle system with 20 small quads it now takes 20 times longer to render those pixels. Cover an entire screen with those particles and now you're rendering an entire screen's worth of pixels 20 times. That adds up quickly, even if each pixel is cheap on it's own. If each pixel takes just 3 microseconds to render (1/1,000,000 of a second), 3 μs * 1.33 million pixels (for 1540x866) * 20 particles = 80 ms, or less than 13 frames per second. And that's just to render the pixels for the one particle effect, and nothing else.

    The 3 μs time is just a guesstimate on my part that gets close to the delta between the first single particle and last 20 full screen particle frame time difference. The reality is far more more complicated, and each pixel probably takes much longer to render, but GPUs are highly parallel in their computation so it can do several pixels of a triangle at the same time.

    This is that fillrate thing @Torbach78 mentioned.
     
    Anonymodesu likes this.
  4. Anonymodesu

    Anonymodesu

    Joined:
    Jul 1, 2018
    Posts:
    8
    So in general I should avoid covering the screen with transparent textures?
    I'm using a billboard to render each particle.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Yes. There's a reason why by default particles have a max screen size set. A particle that's limited to 50% of the screen width will cover less than half as many pixels as one that can cover the entire screen. If you are going to cover the enitre screen, try to do so with as few particles, and with as simple a shader as possible. If, for example, you need the above effect to look like it does when there are 20 particles stacked on top of eachother, I would recommend replicating that 20 layers of one texture in photoshop and saving that out as the texture you use for your effect. Lots of old mobile games used to make very simple effects, and then bake the entire effect into a flipbook texture instead of paying the cost of overlapping particles.
     
  6. Anonymodesu

    Anonymodesu

    Joined:
    Jul 1, 2018
    Posts:
    8
    Thanks! I'll resort to limiting the max screen size.