Skip to main content
GameDev.net gamedev.net
🔒 Locked

Optimized Unity Compute Shader Particlers

Started by hawksprite Dec 25, 2012 at 5:59 PM 1 replies 5.3k views
Original Post
hawksprite
hawksprite

So i've been toying with compute shader's to handle particle control and have run into an issue. Everything is working fine so far but there's a bottleneck. When I get up into the hundreds of thousands of particles it starts to lag, I haven't implemented other post processing effects on the particles such as blur and what have you so I'm concerned that there might be a serious performance problem later down the road.

I'll attach the script, shader, and compute shader. I haven't done much optimization yet and i'm not sure how to properly use compute shaders so any advice you guys can give me would be greatly appreciated. Thanks.

I just checked and it gets about 40-50 fps with 500k particles.

Part Controller:

http://pastebin.com/zJ9C5Ehx

Part Controller Shader

http://pastebin.com/GB24qttX

Part Controller Compute Shader

http://pastebin.com/zTw6rVAN

MJP
MJP

How large are you particles? It's very easy to become purely bandwidth or fillrate bound when you have lots of particle overdraw, particularly if you're running on a low or mid-range video card. I would suggest disabling the rendering of your particles so that you can try to isolate whether it's the simulation step or the rendering step that's taking a long time. You can also use a NULL pixel shader or disable color writes when rendering which will help determine if you're bandwidth/fillrate bound from overdraw. If that is the case, you can try making your particles smaller or you can try rendering them to a half-resolution render target.

hawksprite
hawksprite

I did some tests and here's what I found.

With rendering of the pixels on at a short distance (Not right up against it) I got about 42 F.P.S. with 500K particles. Then when you got up close it dropped to about 20-15.

With rendering off (Also not setting the buffers to the shader material) It got the same 42 F.P.S. on average (It occasionally would go to about 70fps for a few seconds). But didn't have the drop off when you got close to where they would be, which makes sense.

So there's a definite bottle neck with rendering up close, but there's also a definite 20 fps drop happening on the compute shader to just control the particles.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.