Search Unity

Shuriken particle system performance help

Discussion in 'Scripting' started by chingwa, Jul 1, 2012.

  1. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I have a rather basic particlesystem displaying 5000 billboarded particles (no sorting) and this single system is giving me a 10fps performance hit. In my project I had hoped to be able to use a number of these systems for effects work, but this fps hit is killing me. when i turn off the particlesystem renderer I see it is using only 2 draw calls. (which also seems strange, shouldn't it be 1 draw call per system?). 5000 particles seems like a lot, but when you consider the max particle range per system is around 65,000 it gets put more into perspective.

    This is not being run on a dinky machine. I have an intel core i7 2600 running at 3.4 ghz, 16 gb of system ram, and an Nvidia Geforce GTX 580 with it's own 1.5GB of onboard ram. This system should be able to handle 5000 billboarded particles.

    Does anyone here have any perspective or experience along these lines? Or advice on how the performance can be brought up to acceptable levels? I'm feeling slightly disgruntled at the moment, as 3.5 was certainly sold with shuriken as a feature, not a "half-baked" feature. :/
     
  2. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    bump! Perhaps I put this in the wrong sub forum, as it isn't coding per se. Maybe an admin can move this to the "Unity Support" sub-forum?
     
  3. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Bumpies! Anyone else have issues with ParticleSystems slowing down performance?
     
  4. robert

    robert

    Moderator

    Joined:
    Dec 21, 2008
    Posts:
    265
    I can assure you Shuriken is not a half baked feature ;) It's one of the best performing particle systems I have ever seen and on top of that it gives you crazy control of everything :)

    But judging by your post I can't tell what's wrong or if anything is actually wrong. It might be the case that each of your 5000 particles takes up a huge portion of the screen. If that's the case, even though Unity might be doing everything in an absolutely optimal way, the GPU would still be spending a ton of time overdrawing each pixel on the screen 5000 times. So if your particles are very big on the screen, you either have to make them smaller, have fewer of them or get a gpu from the future - no particle system in the world will make things faster.

    To figure out what's wrong, you can try profiling your particle effect on the GPU using your favourite profiling tool (I like Intel GPA).

    You can also try posting some screenshots here, we can take a wild guess. If you're convinced your content is ok and the GPU should easily handle what you set up, you should submit the (bare bones) project in a bug report.

    Finally I would stay away from using fps for measuring performance, especially for measuring differences in performance. If you say that particles steal 10 fps, that can mean anything:
    1. Your initial framerate was 200fps, so 5ms per frame. Now it's 190fps, so 5.3ms per frame. That means the particle system is taking 0.3ms - that's really fast!
    2. Your initial framerate was 30fps, so 33ms per frame. Now it's 20fps, so 50ms per frame. That means the particle system is taking 17ms - that's really slow!
    As you can see, it only makes sense to talk about how much time does a certain task take, not how many fps it steals. You can read more here.
     
  5. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    This just in, poor workman blames his tools!

    :)
     
  6. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Thanks for the response Robert.

    I have two particle systems as a case in point. One renders a star-field, with approximately 9000 individual particles with practically no overdraw. each particle is TINY on the screen, 1 - 4 pixels depending on the position. Unfortunately I can't just render a point, so each particle is a texture circle at the smallest texture size 32x32. when I turn the renderer for the particle on and off this is the average result...

    So there is a 0.4ms difference on the renderer, 1 extra texture, 2 extra drawcalls, and 0.5ms difference on the main thread. This gives me on average a 5-8 fps hit.

    The second particlesystem renders a cloud front. There are 5000 individual particles, with quite a bit of overdraw, the particles are each around 0.05 percent of the screen.

    There is more of a hit than the first example I assume because the particles are bigger, even though there are around half as many. You can see by having a few of these types of systems going on in my game how quick it'll eat into performance.

    I don't doubt that Shuriken is an efficient system, in fact as a test I set up the same cloud system with the legacy particle system and got these results:

    As you can see I'm suffering a larger performance hit, even though the draw calls are the same.

    If this is indeed the performance I can expect, and there isn't anything funky going on, I'm going to have to rethink how to build these systems. I've read that shuriken in future versions of Unity will handle particle culling "better"... I assume this means that only those individual particles within the screen-view will have an impact on performance. I hope this is so, even though I don't know if I can afford to upgrade to 4.0 at this point.
     
  7. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Just did a quick test 10,000 particles using a small texture with transparency and an alpha blending shader with heaps of overlap (nothing else in the scene, res 1024x768) gets around 200fps on an iMac a generation or so old.

    With animated 50k triangles of geometry and one light added it still seems to have little effect.

    I wasn't able to get a noticeable effect until I switched to a diffuse shader on the particles and upped the number of lights to 2.

    Do you need shadows on your particles?

    What else is in your scene? What shader are you using for your particles?
     
  8. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    Thanks JohnnyA, I'm using a custom shader for my particles. I don't need shadows per se, but I was hping to use pixel lighting (in deferred mode). I can see after doing a few tests that different shaders are giving me some better performance, though the performance hit still seems pretty high. I'll probably end up reformulating these for a non-lit shader anyway. Thanks for your ideas!
     
  9. WILEz1975

    WILEz1975

    Joined:
    Mar 23, 2013
    Posts:
    375
    But shuriken particles have a big problem to control it by script at runtime. Many var is not pubblic...