Hi,
Context:
In my physics-based game, I’d like a large modular spaceship to simulate physics.
I’ve made a lot of different actor blueprints, each with quite a few static meshes.
A single rigid body has “simulate physics” ticked, and every actor of my modular spaceship is welded (aka parented) to that body.
Problem:
Obviously, the more actors in my spaceship, the more computationally intensive it will be to move it around. My problem is that it’s too heavy to compute for too few actors.
Troubleshooting so far:
I’ve done a stress test, and Chaos Rigid body simulation can perform on my computer at 60FPS with up to about 5000 convex hulls. This is enough for my game.
However, I have many times more static meshes than collision primitives in my scene. (either static meshes with collision set to “No collision”, or static meshes that have no collision shape set up) (stat unitgraph
mentions up to 400K primitives. I’m not exactly sure what that number means though.)
So even though I only have 1000 actors (with about a single hull each, and a dozen static mesh components), my game thread takes 30-40ms.
I even disabled physics, and tested with a rotating movement component. Same 30-40ms on the game thread. If I set the rotation speed to 0, the timing drops below 10ms.
The above points me to believe that for my issue, Chaos is innocent.
Current status:
The CPU is just taking too long to update the transforms of each mesh when my spaceship gets moved around.
I’d like to investigate a way to alleviate the load on the game thread without compromising scene complexity.
Ideally, we’d find a solution that is mostly independent of scene complexity. I’ve got the intuition that this may exist since the entire spaceship -mostly- moves as a rigid object. (If the nanite preprocessor was fast enough, I could literally merge all actors at runtime into a temporary single mesh)
Potential workaround so far:
Reduce the entire load somehow:
- Merge as many static meshes as possible in the actor blueprints. Each merge is one less transform to compute for the CPU. I have the intuition that this may not rise my budget enough though.
Use the GPU (Most meshes transform aren’t needed on the CPU)
- World Position Offset: I could leverage World Position Offset. I just don’t really know how.
- Niagara GPU system with mesh renderer: One would hope that when a GPU Niagara system is moved, the transform update of each mesh particle isn’t computed on the CPU. but it seems that this mesh renderer needs complexity management like a traditional raster, so I can’t just give it all my meshes, because nanite won’t work its magic.
Any help would be appreciated!