I have a scene with one particle effect, a waterfall, with an emission rate of 120. In the Editor on MacOS, whether or not the particles are in frame or not has no effect on frame rate. However on iOS, whenever the camera moves to a view where the particles are visible, the frame rate drops significantly. It’s very obvious because as soon as the particles come into view, the camera’s movement gets slow and jerky. I assume it will be even worse on older iPads.
I’ve used particles in iOS apps before with no noticeable effect, so this surprised me a little. These particles use a simple vertex shader on a 32-bit compressed texture with transparency. Could it have something to do with the size of the particles? Depending on the camera position, they can cover up to a third of the screen. Is there any way to improve performance on iOS short of getting rid of the particles?
I’ve been doing some testing, and the shader/texture I’m using is by far the fastest in the Editor, even though it has transparency. I see there is a small drop in frame rate on my Mac, I guess it’s just not noticeable because of the higher overall frame rate. On iOS the frame rate drops from 60 to 28-30, so it’s significant.
The only thing I’ve found to have a noticeable effect on iOS is reducing the number of particles. Cutting the particles in half from 120 to 60 brings the frame rate up to around 45.
I’m not sure what else to try. Is there a shader that might give me better performance on iOS, even though it’s performance is worse in the editor?
I assume this is Shuriken, not the legacy particle system? I tried Shuriken and decided to stay on the legacy system for now because of the performance hit, and hope Unity change their mind about depreciating it. Otherwise it looks like I will be writing my own system, even though I use Unity to avoid that kind of thing.
I’ve been testing on an iPad Air, so I assume performance would be better on newer models and worse on older ones. We’ll see after I get some more people testing. And yes, this is the new particle system.
It looks to me like size and number of particles are the main factors affecting performance. If a slower shader is used, that impacts performance even more.
I ended up replacing most of the area covered by particles (the upper portion of the waterfall) with an animated texture. I reduced the size, number, and lifetime of particles, and limited their area (the froth at the bottom), and that did the trick. The performance drop when the particles are in view is now negligible, a couple of frames at most. I’m starting to think I like the animating texture effect better.
Below is the shader I’m using. It came with EZGUI, and I’ve always found it to be very fast.
// Simplified Alpha Blended Particle shader. Differences from regular Alpha Blended Particle one:
// - no Tint color
// - no Smooth particle support
// - no AlphaTest
// - no ColorMask
Shader "Sprite/Vertex Colored, Fast" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
SetTexture [_MainTex] {
combine texture * primary
}
}
}
}
}