Mesh Compute Normals

Hi,

What is the difference between these two methods for meshes?

mesh.Normals.ComputeNormals();
mesh.FaceNormals.ComputeFaceNormals();

One is for vertex normals other one for face normals?
Or it is enough to call one of them ?

That’s correct, whether or not it’s enough to call either depends on the case I suppose. I always just call both, better safe than sorry and such :wink:

Thank you. I was also doing the same calling both, not knowing which case is which.

By any change do you know the secret behind unify windings component in weaver bird?
I have some issues when I create mesh with ngons from series of polylines, some of them are clockwise and some of them anticlockwise. This results in shading issues, as mesh faces have flipped normals.

The workaround I used was to weld everything using:
mesh.WeldUsingRTree(0.001);
mesh.Vertices.CombineIdentical(true, true);
mesh.Vertices.CullUnused();
mesh.Weld(3.14159265358979);
mesh.UnifyNormals();
mesh.FaceNormals.ComputeFaceNormals();
mesh.Normals.ComputeNormals();
mesh.Compact();
and then unweld the mesh.

But I do believe there is a smarter way of checking the winding direction.

@Petras_Vestartas if the mesh doesn’t have normals created yet then you’ll want to run mesh.Normals.ComputeNormals before you run mesh.UnifyNormals.

Hi All,

Also, Mesh.ComputeNormals uses face normals to cook up a vertex normal. If the mesh doesn’t have face normals, they are calculated and then used to compute the vertex normals. So you should only need to call this member…

– Dale

1 Like

Thank you :slight_smile: