- Home /
Mesh normals: per face or per vertex?
Anyone know? I'm trying to generate a complex mesh (from a file). The original files has no normals, not 2-sided, but looks fine in its native editor. In Unity, half the faces are flipped. I'm not calculating normals myself, and calling RecalculateNormals does not help. So I want to try calculating normals, but is it one per face or one per vertex per face?
Why does an editor exist, that doesn't handle normals? Thats just plain unproductive!
I see your post is 8 days ago, it does handle normals, you can recalculate normals and put their values in an array.
Answer by Bunny83 · Feb 10, 2011 at 07:30 PM
Normals are per vertex, but vertices can be shared by multiple faces/triangles.
What do you mean by "flipped"? If a face is facing to wrong way, you have to reverse the winding order. Something like "face-normals" actually doesn't exists. The winding order specifies in which direction the triangle faces.
To reverse the winding order of a triangle just swap 2 vertex indices.
example (C#):
int[] tris = mesh.triangles;
int tmp = tris[triangleindex*3 + 0];
tris[triangleindex*3 + 0] = tris[triangleindex*3 + 1];
tris[triangleindex*3 + 1] = tmp;
mesh.triangles = tris;
That's what I was afraid of. I did try swapping vertex order, all it did was turn everything around, not just the wrong-facing ones. Is it possible that not specifying normals results in per-vertex normals that are themselves facing the wrong way? The lighting looks very strange on my mesh (directional light, but looks more like a ponit light). That's why I'm thinking they've gone random.
Anyone know of a normal-generation algorithm I could drop in?
Your answer
Follow this Question
Related Questions
Books or articles about mesh recalculation 0 Answers
Calculating normals manually 0 Answers
Finding ∇∆ 1 Answer
Shader wants normal , but the mesh does not have them 2 Answers