I’m using the Mass Entity system to spawn a large number of entities in a level. For the furthest entities, I don’t need a static mesh rendering (since it’s so far away from the player) but I still need the collision component of the static mesh to spawn in (for other calculations being done between entities).
Also I want to use an instanced static mesh because when I try to spawn in thousands of actors using this approach there’s a significant delay to spawning them in initially, while adding new instanced static mesh instances seems much faster.
I tried to do this by importing an empty .fbx file but then I get error “No meshes were found in file.”
I also tried setting the static mesh’s LOD0 “Percent Triangles” under “Reduction Settings” to 0% but then it still renders at least 1 triangle. Screenshot below is when I take a cube mesh and do this to it (I circled the mesh after taking screenshot).
Is there any way to have a static mesh with no triangles?
I learned a couple things that made this question irrelevant:
Regarding the delay of spawning thousands of actors using the Mass system, this is actually by design, to not slow down the game on spawning of lots of entities, by default it reserves a small time slice per frame to spawn actors. There is already a way to tweak this: Project Settings > Engine - Mass > Module Settings > Mass Simulation > Desired Actor Spawning Time Slice Per Tick
Even for the entities I am rendering, the engine does some auto instancing (see dynamic instancing) that seems performant enough in my use case that there’s no need to use an instanced static mesh and instead I can use an actor per entity.
Turns out you can have thousands of actors in a level and still get pretty good performance, as long as each actor isn’t doing much (just a collider in this case).
Yeah, I’m very familiar with that video. It’s a good overview, but unfortunately skips a lot of the details. I wish they had provided the source code for the project in that video. At least we have a complex example of Mass we can dig into in the City Sample project. The crowd and traffic use the Mass system there.
Well there is a couple of options. For sure to work is to use the LOD system to swap out the LOD1 material, or at the desired distance, to an opacity material set to 0. Another depending how the asset is wrapped is set render viability to off so it’s still used in game as far as collision goes but geo is hidden.
Turns out I spoke too soon above. Having thousands of actors has good performance as long as you’re not trying to move them. Once I started moving them, frame rate tanked using the actor per entity approach. I will try ISM again with one of the approaches @FrankieV mentioned. Thanks.
I went with the material opacity 0 approach @FrankieV mentioned and it works well. It seems that setting a mesh’s material opacity to 0 saves on the render thread and RHI thread performance significantly with thousands of meshes.
I also just realized, there’s a UInstancedStaticMeshComponent::SetCullDistances method which I could have used if it wasn’t for the Mass system hard-coding this here.