We have a Skeletal Mesh crowd around the ring in our game, 275 of them in total. ~60-75% are always in view. The Skeleton has 22 bones (too much? But it’s the basic biped skeleton setup) and the mesh has 2,400 polys.
Skeletal Mesh optimizations are enabled, so those that are not in-view do not get animated or rendered and those further away tick less.
The biggest issue is the draw call overhead of rendering this many skeletal meshes: they alone amount up to ~550 draw calls which is quite a lot. Shadows are off on them and they only receive dynamic lighting from up to 4 point lights which go through the crowd to mimic spot lights. No shadowing.
Are there better ways to do a crowd like this? Or techniques I’m not aware of? Any suggestions are appreciated! Happy to post any further details if needed.
imo 275 skeletal meshes can be shown without too much performance loss (in my RTS when 200 units are spawned the FPS remains 62, only when more created it starts to decrease).
as you mentioned, it really depends on bone quantity (22 seems to be fine), and also on material complexity (I use a single texture, no other stuff like normal maps, indeed slower with shadowing enabled). try to decrease vertex quantity below 1000 or use LOD if possible… instead of anim BP you can use single node animation. ticking also has a cost, I don’t use Tick() for my RTS units, I update them from a for loop.
You could write own instanceSkeletalMeshCompont, just combine the codes of InstancedStaticMeshComponent and SkeletalMeshComponent. Every frame you pass a T-pose skeletal mesh and draw number of instances (275 or 2750, no difference) You also need to add a viertex factory shader to sample bone-animation matrix data(BGRA32 Texture) in vertex shader to transform your vertices. Update each instance’s animation frame index by per instance data.
Well there is not a formal ways and means of doing a crowd simulation in UE4…yet…but can be hacked in at the content level by using morph injectors. Injectors are a fancy way of saying full body morphs that will make use of the same resources that a single character would and in more than a few ways would be considered an instance copy.
The upside is now that morphs are hardware rendered the performance impact is a lot less than it once was and would make NPC inclusion a lot more data driven.
In my case disabling the shadow option and skeletal mesh collisions was a huge bottleneck.
I agree replication is another topic and should be considered when multiplayer is a use case for the game. I really doubt that this is possible for instanced meshes like mentioned above.
I started to implement my own plugin as the detour crowd controller does not perform very well for my zombie horde base game.