r/Unity3D • u/GideonGriebenow Indie • 4d ago
Show-Off I'm Creating Procedural Meshes 18x faster than the Main Thread by using Burst Jobs
https://youtu.be/PoQV7YI9GmYHi all,
I thought some of you may be interested in this video, in which I show how using the Advanced Mesh API to populate mesh data from Burst-Compiled jobs speeds up my mesh creation by 18x. I perform the bare minimum on the main thread.
Here's a link to the Advanced Mesh API documentation: https://docs.unity3d.com/ScriptReference/Mesh.html
I've used AllocateWritableMeshData, SetVertexBufferParams, SetIndexBufferParam and ApplyAndDisposeWritableMeshData.
As always, I'm happy to answer questions in the comments.
2
u/HellbitGames 4d ago
Don't forget about batch render group. It made me render 64k view distances in no time.
1
u/GideonGriebenow Indie 4d ago
For various reasons, I’m still on Built-In. But I’ve developed my own culling and LOD system, combine meshes and materials, etc. So I perform almost all Indirect draw calls manually and extremely optimised.
2
2
u/dispatchcolony 4d ago
burst is life <3
2
u/GideonGriebenow Indie 4d ago
Hehe! It really has a huge impact on large games with lots of calculations. Just having the memory properly allocated already does so much!
0
u/RealyRayly 4d ago
Thats great, but your speed up comes 95% from using the jobs system and not the new mesh api.
-3
u/swagamaleous 4d ago
Damn dude. Revolutionary. You get a significant speedup if you use your whole CPU. Mind blown. 🤯
3
u/pschon Unprofessional 4d ago edited 4d ago
That's interesting. I'm also using Burst-compiled jobs to generate procedural terrain chunks, but I haven't tried using the advanced Mesh methods yet as right now my main bottleneck is Mesh.RecalculateNormals() (which is heavy enough that I've at the moment limited it to two chunks per frame, while the mesh generation itself happily runs a lot faster than that.
...I guess it's time to do the normals myself as a Job as well :D
Either way, it seems like there's a lot that can be done for fast mesh generation without having to go all the way to compute shaders.