- Home /
Number of mesh vertices increase when imported into unity
Hi there, I have made a number of basic shapes in blender (ico spheres, cubes etc). When I import the shape into unity (either as a fbx or 3ds file) the amount of vertices drastically increases. I know this because I have a script which is storing the array of vertices, and then debuging the size of the array.
As an example, my ICO sphere has 962 verts in blender, and 3840 verts in unity. This is nearly, but not quite, 4 times the amount of verts. Why is this? I have read in other posts about unity's basic shapes having double verts, but nearly 4 times more is crazy (especially because it's not exactly 4 times more, that's what puzzles me the most!).
Incase it's of any consequence to the answer, I am going to procedurally ater the shapes in semi-random ways.
Cheers in advance,
Pete
Hi, are you sure you are not exporting all the objects, you should export only the one you have selected
That depends what you mean by all the objects. With the first few I exported with the camera and light aswell. After reading your answer, I thought I best check for an option to export just selected object, and I exported a basic cube with 8 verts. This time i definately just for the cube and it has 24 verts.
I understand what's going on, it's counting every corner of each of the 6 squares ins$$anonymous$$d of just counting the 8 intersecting corners, which I guess must be what's going on with my ICO cube. But is there a way to stop this happening? I'm considering writing some code to compare all vertices, find the repetitions and recreate a mesh without any repetitions. I'm hoping there's an easier way :D
Cheers for the ultra fast response man!
Do you have modifier (like subsurf) ?
I know this because I have a script which is storing the array of vertices, and then debuging the size of the array.
It's maybe an error in your script, can you provide the counting part ? To be sure, you can also use the mesh view in Unity to get vertices number.
I've just tried out the mesh viewer from the assets store if that's the one you're talking about, i can't get it to work. I'm pretty confident that that's correct though, because when I procedurally alter the positions of all the vertices, the cube is split up into 6 seperate squares. Here's the script anyway:
meshFilter = GetComponent ();
List<Vector3> vertices = new List<Vector3> ();
$$anonymous$$eshFilter meshFilter;
int vCount;
void Start () {
vertices.AddRange (meshFilter.mesh.vertices);
// I was using an array originally, and that showed the same results
// Vector3[] vertices = meshFilter.mesh.vertices;
vCount = vertices.Count;
Debug.Log (vCount);
}
}
Ah no, I've got a different mesh viewer working, and it does indeed have 24 vertices.
Answer by hexagonius · Jun 25, 2015 at 02:49 PM
I would say you're using hard edges for your icosphere. 3840 / 3 gives me a rounded 1280, and it's divided by three because an icosphere consist of triangles, not quads. This means every vertex is tripled and that is because of multiple vertex attribute per vertex, which Blender might handle but Unity doesn't. In your case that's the normals, one for each adjacent face.
Therefore the amount is perfectly valid. Same for the cube, which equals the Unity primitive cube with 24 vertices.
In blender, the icosphere had 962 verts, not 1280. 3840 / 4 = 960, so it's just under 4 times the amount, not 3.
That asside, I've read documentation that suggests making primatives in blender or similar to overcome the issue of unity primatives have multiple verts per intersecting vert. ie, a cube can have only 8 verts, but the way unity creates them makes them have 24. I'm trying to make the 8 vert version.