calculating face normals

Started by
5 comments, last by haegarr 16 years ago
hi, how would you normally calculate face normals when you have the vertex normals the make up the face, I've tried adding them together and dividing by the number of vertices but it's not working, I have these unit normals: 0.577349; 0.577349; -0.577349;, 0.577349; -0.577349; -0.577349;, -0.577349; -0.577349; -0.577349;, -0.577349; 0.577349; -0.577349;, and the result is: 0.000000, 0.000000, -0.577349 but should it not be (0, 0, -1)? how would I do this
Advertisement
Just normalize your result vector.
Strength without justice is no vice; justice without strength is no virtue.
How did you calculate the vertex normals without a face normal in the first place?

I'm unsure if you can 'revert back' to a face normal from a set of vertex normals.

But then again, I'm not the world's best mathematician.

"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2

A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk

Quote:Original post by deadstar
How did you calculate the vertex normals without a face normal in the first place?

I'm unsure if you can 'revert back' to a face normal from a set of vertex normals.

But then again, I'm not the world's best mathematician.


there pre-calculated in .x files for each vertex but not for faces.


Quote:
Just normalize your result vector.


thanx.
Also, don't bother dividing by the number of vertices. Just add the vectors and normalize the sum.
Strength without justice is no vice; justice without strength is no virtue.
It will only be accurate (in all situations) if you make a new normal from the triangle's vertices.
A vertex normal is computed by the normalized sum of the normals of surrounding faces if the corners are smoothed. They are identical to the face normal for sharp corners. Perhaps, before summed up, they are weighted with the enclosed angle with which the face participates on the vertex (other weighting schemes exist as well).

Summing up the normals of all verices of a face definitely considers the orientations of neighbouring faces, too. Therefore, it will definitely not yield in the original normal for the general case. If you want to yield in the correct normal, compute and re-normalize the cross-product of the difference vectors between vertices. I.e. for a face with at least 3 vertex positions p1, p2, p3 use
normalize( ( p2 - p1 ) x ( p3 - p1) )
(For quads and faces with even more vertices some possibilities exist to suffer as least as possible from numeric inaccuraries.) You can, of course, look at the vertex normals to determine whether the direction of the cross-product is correct or has to be inverted.


EDIT: Okay, jezham has mentioned it already :)

This topic is closed to new replies.

Advertisement