As the title suggests, I’m looking for a solution to dynamically remove and add vertices belonging to a single mesh at runtime in order to reduce draw calls. The mesh I’ve built contains approximately 400 vertices and for every 4 vertices, a square mesh is created, containing 2 triangles, each square is separate from the other square meshes. Picture something like this but with many more squares. I feel should also point out that each square will be manipulated at runtime by moving the respected vertices around. The interesting part is that amount of squares that are needed changes during runtime, so sometimes only 2 squares are needed(8 vertices) and other times all 100 squares are needed to be used(400 vertices). Currently, I take all the vertices from the squares that are not needed and move them to a single point in space in order to render them invisible(but this doesn’t physically get rid of them). All 100 of these squares belong to a single mesh that contains a single material.
Everything up to this point is fine and dandy, the problem arises when I have multiple of these meshes layered on top of each other. So let us say I have 2 of these meshes, one on top of the other in the scene. Since each mesh contains 400 vertices and as I understand it Unity’s dynamic batching only batches meshes together that equal less the 300 vertices, I will always get 2 draw calls even if I only need to visually display 1 square from each mesh.
So many questions arise for me at this point. What can I do to dynamically change the vertex count of these meshes to the number of vertices that are actually being used? Can I disable vertices temporarily? Can a potential solution be to place each square in a sub-mesh and disable the unused sub-meshes? Is having that many sub-meshes an inefficient approach? Do I need to remove the actual vertices or can I just remove the respective triangles which are attached to them? Maybe there’s a way to tell unity to not render vertices that are off screen and just throw the unused verts into the distance? Any advice help or intuition would be much appreciated!