Combine static meshes at runtime?

I’m combining different static meshes using sockets at runtime to form all sorts of different combinations of looks for my player’s character.

I’d like to combine these meshes into one mesh for two reasons

  1. I’m using a mesh render target to display the character in the inventory menu. And that requires a single static mesh as a target.

  2. Seems like its more performant to combine meshes so that only a single draw call is made. Otherwise each static mesh has its own draw call. (not 100% sure this is true).

There’s easy solutions for combining meshes with the editor but that won’t work because my meshes are generated at runtime.
I might be able to use an Instanced Mesh. That should solve problem #2. But I’m not sure that will work for problem #1. I’m not sure i can use an instanced mesh as a target for the Render Target.

The attached blueprint is a function that combines static mesh components together

https://blueprintue.com/render/8y16jkx-/

I’m not sure if any of this can be applied to static meshes, but i also can’t recall too many products that have used static meshes for characters.

I’m not sure if any of this can be applied to static meshes, but i also can’t recall too many products that have used static meshes for characters.

Those all seem to use skeletal meshes. A lot of player characters have animations which utilize skeletal meshes. Mine don’t need any such animations.

I suppose i could look into using that solution and just not use the skeletal animations. Just seems like overkill for what i need with just static meshes.

There might be some way to combine meshes at runtime using a Procedural Mesh.
Looks like I’d have to pull all the geometry and material information from each mesh and add it to a procedural mesh.

Procedural Mesh BP Nodes:
Add Procedural Mesh Component - Creates Procedural Mesh component
Get Section From Static Mesh - pull geometry information from a static mesh.
Create Mesh Section - adds geometry information to a procedural mesh.
Copy Procedural Mesh from Static Mesh Component - copies material information from a static mesh component to the procedural mesh.

1 Like

I did NOT find a way to combine static meshes easily at runtime.
Instead i just built the combined meshes twice. Luckily, pointing the Render Target to the middle mesh is sufficient since it captures the surrounding meshes too.

This doesn’t resolve the excessive draw calls being made but hopefully that won’t an issue since its 3-20 meshes max for each character. I guess I’ll find out later near release when i start performance testing.