- Home /
Mesh duplication under the hood: What's duplicated?
When i use Instantiate(myMesh) or retrieve meshFilter.mesh (not sharedMesh), a copy of the mesh is created. I use duplicate meshes for per-vertex damage modelling and i only change colors buffer. My question is, what is really duplicated in the memory? Are all other hardware buffers shared? Or are they duplicated the moment i duplicate the mesh object?
Answer by Joyrider · Aug 21, 2013 at 02:26 PM
In memory, it duplicates everything that is used to build the mesh (i.e. what you see as the mesh asset in Unity > subMeshList, triangleList, vertexList, UVs, ...). All the rest will stay the same, and won't thus be duplicated. It will a.o. still use the same material as the original mesh.
Is it possible to somehow spare memory and only replace vertex colors buffer when rendering?
And for that I'd refer you to Paulius Liekis' answer ;) All data related to a mesh comes as a bundle.
But the data is stored twice, for CPU and GPU access right?
Nope, both accès the data from the same place and it is usually stored in VRA$$anonymous$$, but not necessarily, it depends on usage (static or dynamic meshes) and cpu flags, and handled by the driver. In some cases it is stored in RA$$anonymous$$ and then sent to GPU upon request, making all your mesh data be transfered through the bus. One of those cases is if you lack free VRA$$anonymous$$. Transfers in the opposite direction happen too of course.
Answer by Paulius-Liekis · Aug 21, 2013 at 02:30 PM
Whole mesh will be duplicated since in runtime memory vertex data has to be grouped together, i.e. it's not separate streams.
Your answer
Follow this Question
Related Questions
Shader Shininess based on vertex color 0 Answers
Mesh Colors Problem 0 Answers
How I can get InteractiveCloth vertices and apply to MeshFilter 0 Answers
Mesh.colors returns zero 1 Answer