Hi all, I’m profiling my game with a native profiler, so getting lots of Unity internal stuff popping up. This method TransformParticleMeshAnimatedUVs
seems to eating up 20% of my frame time but I can’t figure out what it relates to. I’m guessing something to do with the particle system, my first guess was texture sheet animation, but we don’t use that on any of our particle systems. Any ideas?
Hi!
It is part of the particle system code that builds particle geometry for rendering.
The code that takes each particle position, size, rotation etc, and figures out the 4 corners of the billboard, plus any other stuff like its color, for example.
That function is called with a parameter “true” or “false” based on whether texture sheet animations are being used, so it will always be there, but doesn’t necessarily mean that you are using that feature.
If you are spending too long in this code, you have some mesh particle systems that are:
- Not using GPU instancing (your platform and/or shader doesn’t support it)
- Has too many particles, or the particle mesh is too high poly (or both!)
Mesh particles that don’t use GPU instancing, are very cpu-intensive.
Thanks! I think we had forgotten to tick GPU instancing on the particle materials. Although there are only 1-2 of each particle system playing at once, and only maybe a dozen total. Maybe the number of particles and the mesh complexity is more the issue.
If you are able to use GPU instancing, the cost should come down loads.
It’s not the same workflow as using instancing on meshes though, it doesn’t use the gpu instancing checkbox on the material.
Your easiest route to using it is:
- make sure your target platform supports compute (the instancing doesn’t actually use compute, but it does use a buffer type that is generally only available on compute-capable hardware)
- use one of the Standard Particle Shaders (Unlit or Surface)
- make sure the gpu instancing checkbox is ticked in the particle renderer inspector
If you need to use a custom shader, there are docs on how to make it work with instancing, but it requires some modifications.
Here is the relevant docs page: https://docs.unity3d.com/Manual/PartSysInstancing.html
But your first step is definitely figuring out if your target platform(s) can use it at all.
Ah ok, that’s interesting. Yeah we are using a custom Amplify shader so maybe gpu instancing is not supported. It does seem like the different particle systems are being drawn together when looking at the frame debugger in the editor at least, but maybe I’m misreading that. How can I confirm that they are being instanced?
The platform is Switch which does appear to support compute shaders.
I don’t think Amplify shaders will support particle gpu instancing.