Mesh Compute Normals


#1

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 ?


#2

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:


#3

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.


(Travis Serio) #4

@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.


(Dale Fugier) #5

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


#6

Thank you :slight_smile: