I’m currently trying to spawn a huge number of actors with PCG. For example, I’m testing with this mud pool Blueprint, which is composed of a simple StaticMesh and a BoxCollision :
I’ve learned about this new experimental plugin called InstancedActors (+ PCG Instanced Actors Interop plugin to use them in PCG), which makes it possible to generate tons of Actors, but that are just rendered as InstancedStaticMeshes when you see them from a long range, then get replaced by the actual BP Actor under a certain distance (like explained in this video : https://www.youtube.com/watch?v=B9s_1qkTRfI )
So I tried doing exactly this, and it works, but the performances are far worse than with regular Actors spawning :
So, what the hell is happening? Did I do something wrong or is the plugin too experimental and unoptimized to be used at the moment? The whole point of this feature is supposedly to gain performances, and this is the most simple setup I could imagine, so I really don’t understand how this can happen…
Ok, after some deeper research and many tests, I’ve realized that all those mud meshes were casting shadows (in both instanced and regular Actor versions)
After deactivating shadows entirely, the framerate suddenly increased drastically in both scenarios, so I increased the number of Actors to run new relevant tests.
Now, the performances are indeed slightly better with Instanced Actors than with regular Actors, but with StatUnit running, It seems there is still a huge tradeoff when using InstancedActors :
As you can see, the number of draw calls is drastically reduced, as is the memory usage… but the RHI thread skyrocketed from 1ms to 8ms, and the GPU Time from 10ms to 16ms!
Even worse: if I just add a wall in front of the player (no other change in the scene), the regular actors version suddenly booms to ~120fps, as there is much less to render, but the InstancedActors version stalls to 60fps:
This huge difference is apaprently caused by the occlusion culling not working with InstancedActors, as confirmed by using the console command FreezeRendering from the pawn PoV:
So… at the moment, I’m not sure if this is the intended behavior or if this is still a work in progress issue. And If this is normal, I don’t really see in which use case spawning InstancedActors would be recommended over simply Spawning Actors.
You’re onto the problem, the RHI spike is it throwing all instances every frame to the GPU, not having any culling. Consider breaking up your pcg into smaller instance groups that can cull out. Better yet use partitioned or hierarchical generation if it fits your needs: