We’ve a custom build plugin to load meshes during runtime that uses procedural meshes.
The problem I’m trying to solve relates to performance of procedural mesh creation. Some meshes, upon registering, cause my game to freeze for a few minutes. Such a freeze breaks my connection to the AWS server and the game goes out of sync.
The meshes are created in a BP tick function to limit the meshes drawn per frame. This method worked so far but with our game becoming more complex, this is no longer sufficient.
In each tick, we create the mesh section, add materials, set up physics and register component. I profiled the time taken by each of these sections and found that the bottleneck is at the RegisterComponent() function.
This is reasonable given that my meshes can sometimes comprise over 100,000 vertices. But is there anything I can do about this- for ex., register them asynchronously?
Maybe if you write your own async function I’m c++
I don’t think there is a “standard” one for this specifically.
You could just write it up and expose it to BP / copy from the load async functions that do exist…
/not sure how much help on this you’ll get within the rendering sub-forum…
Is something like that even possible? UE has something about rendering needing to happen on the main thread only.
The code I’m working with is not straightforward at all. Otherwise, I’d have tried making the change before posting.
… since there is a load async function that pops in a mesh at runtime whatever it’s loaded… yes there should be a way.
You probably want to look into the soft reference stuff/ live learning talks and such to get some ideas on this.
Load levels also have an async version - not sure that’s going to matter based on what you described but, it something…
Thanks for the response.
I did manage to async the component registration but that throws up an error described in https://answers.unrealengine.com/questions/516316/view.html.
Further searching led me to this discussion- Help with Multi-Threading a RuntimeMeshComponent update. which confirms my suspicion that UE4 does not let me render from a different thread.
Will update when I find something. Thanks!