About Normals...Welding.

I don’t know wether this post is off-topic or not.I will accept every kind of answer.

i would like to understand the correct way of calculating Vertex normals. At the moment i’m implementing the classic algorithm wich consist in averaging and normalizing the face normals that share the vertex (Goraud?).

The resulting object appear nice but with no edges.

I got some questions about “Averaging”:

  • just sum the face-normals?
  • or, sum and divide (for the # of faces)?

Second Algo: Welding (edge preserving).
This is what i really like to implement.
I got some descriptions of the above algo but they are quite obscure.

Does someone of you have or knows where to pick a clear description of it (pseudo code or some examples).

I have read a discussion on it made by Nate, and i have the code he use to implement welding, but i like to make a mine implementation.

Thanks for the patience.

There is no ‘correct’ way to produce your normals (unless you have sampled them from a real surface). Usually, the intention is to make the surface appear as smooth as possible. For this, averaging the surrounding polygon normals is usually adequate (as you say - sum them all up and divide by the number of incident polys). Some people also inverse area weight the incident normals. Of course, this will be less efficient.
To have creases in your object you will need to decide on the maximum angle between incident polys. When you generate your normals you check whether this condition has been violated - and if it has, don’t include that poly in the averaging.
BTW, Goraud shading is the way in which vertex colours are interpolated to determine the colour of each pixel in a triangle. Phong shading is the interpolation of vertex normals to produce the colour of each triangle pixel. You don’t need to worry about this - gl does it for you (it uses goraud).

jimmi

edit:
Actually the creases thing is a bit more complex - you will have to store more than one normal for vertices which lie along a crease.

[This message has been edited by jimmi (edited 04-26-2002).]

Originally posted by kandera:
[b]
I got some questions about “Averaging”:

  • just sum the face-normals?
  • or, sum and divide (for the # of faces)?
    [/b]

You only need to sum the vectors, because you are interested only on the direction of the vector, not its value (after all, after averaging you are normalizing the vector so its length is always 1, don’t you?)

Example: (1,0,0) and (0,1,0)

You have by adding these two: (1,1,0) Then you normalize it: (1/sqrt(2),1/sqrt(2),0)

Nate Robin has some code and a document that
you might find interesting:
http://www.xmission.com/~nate/smooth.html

/peter

Thanks to you all!

I appreciate your answers, they are really useful.

Now i have to pay more attention to the glm libraries from Nate.Waht i have understood from his page is that if you desire sharp edges you have to sum only vectors which angle (between one and another) respect a threshold (euristically determined, i guess).

This introduces another doubt: which normal is the referring one?

mmmmmmh…maybe my question is not clear, let me investigate about it some time…

yepa!