I have a skinned character model that's imported from an FBX file. In play mode the stats show that this model has 13.5k vertices. With the script below attached the stats say the model uses only 4.4k vertices. The script simply adds a SkinnedMeshRenderer to the model's gameobject and then copies all the relevant mesh data over from the original SkinnedMeshRenderer (gameobject child) to the newly added one. The original model has a several materials that are all the same (except hair), and the copy simply uses one material (looks fine, except for the hair of course). Can anyone explain why the copy has a much lower vertex count than the original? Code (CSharp): using UnityEngine; public class CopyMesh : MonoBehaviour { void Start() { // original SkinnedMeshRenderer originalSkin = transform.GetComponentInChildren<SkinnedMeshRenderer>(); Mesh originalMesh = originalSkin.sharedMesh; // copy SkinnedMeshRenderer copySkin = transform.gameObject.AddComponent<SkinnedMeshRenderer>(); Mesh copyMesh = new Mesh(); // set up copy's SkinnedMeshRenderer copySkin.sharedMesh = copyMesh; copySkin.material = originalSkin.materials[0]; copySkin.bones = originalSkin.bones; copySkin.rootBone = originalSkin.rootBone; // copy over required vertex data copyMesh.bindposes = originalMesh.bindposes; copyMesh.vertices = originalMesh.vertices; copyMesh.normals = originalMesh.normals; copyMesh.uv = originalMesh.uv; copyMesh.boneWeights = originalMesh.boneWeights; copyMesh.triangles = originalMesh.triangles; // disable original SkinnedMeshRenderer so that only the copy shows up originalSkin.enabled = false; } }
The stats show the number of vertices going through the whole pipeline, so if you have multiple passes due to things like shadows or multiple lights then the count will increase, from your figures 13.5k vertices is 3 times 4.4k so there is probably three passes going on.
I highly doubt that that's what's going on here. When I split the model into separate meshes for each material in Blender, then the vertex count in Unity is small as well. Basically, when I have one material for each mesh the vertex count is low, when I have one mesh with several materials then the vertex count is three times as high. Fixing this isn't the problem, I just want to know what's going on here.