I’m importing a model into Unity iPhone (though I expect this isn’t a Unity iPhone-specific issue) and just this one certain mesh makes the vertex count show up in stats as approximately double what it should. It’s approx. 4,500 vertices, and when I disable the object, the scene’s vertex count drops by 9,000 (basically twice what the model actually contains).
At first I had a problem with “phantom” vertices from faces I had deleted but didn’t remove the vertices. This was bloating the vertex count, but I fixed it by optimizing the meshes to remove the unused verts (I’m using Cheetah). But I still can’t seem to get this one mesh (one of three in the .jas/fbx file) to stop showing up with double the verts.
Edit: I should add that the number of tris appears correct, just not the number of vertices.
Are there any well-known gotchas I should be aware of that would cause this? I thought perhaps it’s showing that because I might be using a shader that is registering two passes (lightmapping), but it turns out that’s done in a single pass and wasn’t the culprit. So I’m at a loss as to why I’m getting double the verts! As you can imagine, this is pretty important on a platform like the iPhone.
Vertices that have multiple normals or UV coordinates get separated out. That’s just how the graphics cards want 'em. So you’ll have multiple vertices generated on UV boundaries and multiple vertices generated for any hard edges.
Interesting… that makes sense I guess. So it turns out, my mesh, with the exception of just a handful of polys, is all contiguous, so that’s not the culprit. But it does have a second set of UVs for a lightmap. Problem is, I can’t find a way in Cheetah to delete the other set of UVs, and if I set the shader to Diffuse in Unity, it doesn’t help. Do you know of any way to otherwise get rid of this second set of normals?
So I guess even though the hardware supports using combiners to lightmap in a single pass, it’s still incurring a heavy penalty by doubling your vertex count.
Hmmm… that’s strange then. I only have a handful of polys that aren’t mapped contiguously. And I just figured out I can only export a single UV set from Cheetah if I use FBX, and that actually INCREASED the vertex count (slightly). So you’re right, a second UV set doesn’t do it. So now I’m back and square one.
I just re-mapped the UVs on my model so that they’re all 100% contiguous, and it actually substantially INCREASED the vertex count. Now instead of it being double what it should be, it is now triple! I went back to my original mesh and it is still double, so now I’m really confused!
Another update: I noticed if I turn off “Automatically calculate normals”, then the vertex count triples (as opposed to doubles). If I turn it on, then it is merely doubled. Which lead me to export to OBJ and look at the results. Turns out, I have the correct number of vertices and UVs in the OBJ, but instead of about 4,700 normals to go with my 4,700 vertices, I have over 12,000 normals! So it looks as if Cheetah is producing way too many normals per vertex. Having Unity calculate normals seems to reduce the problem, but not eliminate it.
To be fair, I’m probably doing something wrong that’s causing this output, but I’ve yet to figure out what. It sounds like each vertex is getting a separate normal for each face that adjoins it.
Alright, I found in Cheetah where I can set the normal smoothing and set it to “phong”. Then I had to turn “Automatically calculate normals” off when importing to Unity. This got me down close to where I should be. The model is 4,797 verts, and Unity shows 5.9k. It still seems like an extra 1.1k verts is a bit much considering I only have a small handful of non-contiguous UVs, but it’s much, much closer to where it should be.