- Home /
Unity Skinned Mesh Renderer & Rendering Optimization
I have been researching for a long time about how to run min 100-200 characters (skinned mesh) on mobile in an optimized way.
Ways i tried:
Animation Instancing
LOD
Decimating Meshes (3000-6000 tris max I got)
Culling
Instanced blob shadows (just quads)
Simple Shaders (Just texture no extra things like mobile shaders)
Mipmaps
I don't have a problem with the code (2-3 ms max) 200-300 NPCs going around are just structs and a different mono behavior manipulates them.
But while trying all these, all the usability of the game almost disappeared thanks to the animation instance. I can't use Animator the way I want, animations have become pure torture.
And also in the SRP batcher, I guess it doesn't cover skinned mesh.
I'm very curious what you can suggest.
Thanks
Answer by Pangamini · May 07 at 01:58 PM
You could try Vertex Animation Textures to allow instancing of animated characters, however I've been researching a similar problem recently (I even had a target of 200 characters), testes various techniques, evaluating their pros and cons... and ended up doing skinned meshes with animator. The triangle count was a bottleneck and instancing, SRP batches, dynamic batching, or any draw call reduction technique had basically no effect on the final FPS. Animator ended up being more performant than VAT, although not by much.
I convinced the art team to produce 500 triangle characters for the lower end devices, and it works.
Actually, you're right, if I had an art team, iteration could be provided and intervened in this way, but it is very difficult on my own.
At the moment, I take ready-made asset packages and try to decimate them with some plugins and create my own lod's in Unity because they do not have lod's.
But this process becomes unbearable.
So today, for the last time, I'm going to combine and test the performance of the skinned meshes, combining and testing wave after wave of drops (for example, wave 1 combined with 100 characters)
I'm considering using Mesh Baker here, but the pros and cons of events in this method are still annoying.
I hope unity will soon release a method that will allow us to use these skinned meshes in a cheaper way, without destroying the usability of other methods like animator.
Also the package that I target with 200-300 character is this https://assetstore.unity.com/packages/3d/environments/fantasy/human-orcs-undead-elves-rts-mega-pack-170078
Baking or "cheaper way of using skinned mesh" won't hep you if your bottleneck is the same as mine, and that is triangle count. The only thing you can do is to reduce it, by reducing the number of characters or by decimating the meshes. Or, by incrementing your target hardware requirements, of course. Unfortunately, there are some situations where you can't have everything and have it for free.
One option, if viable for your game, would be to generate sprite sheets, do it the old fashioned way. The only reason why I didn't use sprite sheets for the project is that there's a lot of customizations and dynamic content and the sprite sheets would be either impossible to store on the device, huge to download, or take a very long time to generate at runtime. But if you can generate spritesheets offline, you could have many more characters on the screen while using the fraction of phone's power.
I suggest that you decimate the meshes regardless of the output quality, just to see the effect on performance in your case. Just use some quick method, be it ugly af. Find your bottleneck.
I found a solution this is the best on mobile
https://assetstore.unity.com/packages/tools/animation/mesh-animator-animate-massive-crowds-26009
More than 500 character limit to polygon tris count up to 1M it works 60 FPS. Also, I configured the pack shader a little bit for my own purposes and optimization.
Other solutions on animation instance theory might be a little bit buggy (texture creators, their own vertex shaders, etc.)
Also, I take a little bit trick on these repo's shader https://github.com/chenjd/Render-Crowd-Of-Animated-Characters
Lastly don't use real-time shadow just create an instanced shadow with quads and cull them
I hope it helps the others