- Home /
Sharing vertex buffer between mesh objects
Is there possibility to share vertex buffers between Mesh Objects. I have baked some bezier patches to Mesh objects. I would like to create a LOD version of a bezier patch; can I re-use the vertices from one mesh and just use different triangles (index buffer) to reduce poly count. This is trivial to do with pure graphics API but I have not found a way to do it with Unity meshes.
Answer by Bunny83 · Jul 11, 2019 at 10:18 AM
No, Unity does not support that. A Mesh instance actually "owns" its native vertex and index buffers. Unity provides methods like "GetNativeVertexBufferPtr" for native code plugin usage. However there is no way to set the vertex buffer of a Mesh class instance. You would have to assign the same vertex array / List to both Meshes which of course would duplicate the vertex buffer on the GPU. Though since you said it's pre baked it would make more sense to actually use a trimmed down vertex list as well.
However if it's important for you to save GPU memory you can do this if you handle everything in a native plugin. Of course native rendering plugins have to consider the actual used graphics interface which is different on most platforms. For more information see NativePluginInterface
Seems to be more trouble than it's worth then. I was just thinking to replace far-away patches to meshes with simpler geometry; but the GPU memory is more important than the $$anonymous$$or performance gain I can get from reducing polys. (in my system there are already simplified shaders for faraway objects etc..).
$$anonymous$$eep in $$anonymous$$d that Unity already has an LOD system. All you have to do is provide seperate meshes, name them with the right suffix and use an LODGroup
Yes I am aware of that. I am using procedural bezier patches in my own terrain system (allows overhangs and stuff) so I decided to incorporate custom LOD system for it. It would be trivial to create LOD versions of the patches on the fly but it wastes quite a lot of memory (bez patches have relatively high triangle counts) so I think I will not use any polygon reduction LODs.
For static objects like cliffs the builtin LOD system works well though.
Your answer
Follow this Question
Related Questions
Ways of modificating mesh triangles 3 Answers
Differentiate an overlapping collision from just touching 1 Answer
mesh into smaller triangles 0 Answers
instanced mesh won't collide with raycast anymore 1 Answer
Procedural mesh creation issue 1 Answer