Contents
How to calculate normals in a triangle mesh?
Adding the normal vectors of the adjacent triangles for each vertex and then normalising is the way to go. I just want to push the answer a little bit and have a closer look at the particular but quite common case of a rectangular, smooth mesh that has a constant x/y step. In other words, a rectangular x/y grid with a variable height at each point.
How to calculate the normal vector for a triangle?
If the normal vector points in the Z direction towards you : And the resulting normal vector for each point P is the sum of N1 to N6. We normalise after summing. It’s very easy to create a loop, calculate the values of each normal vector, add them and then normalise.
How do you get normal vector for vertex?
So we can get the vertex normal vector by simply summing up all the face normals. In lighting calculations the normal vector must be unit length, i.e. normalized to be useable. So after summing up, we normalize the newly found vertex normal and use that.
How to calculate normals in a smooth surface?
In smooth surfaces vertices are shared between faces (or you could say those faces share a vertex). In that case the normal at the vertex is not one of the face normals of the faces it is part of, but a linear combination of them: ↑Nv = ∑ p ↑Nf ; where p is a weighting for each face.
How to calculate normals in a square grid?
On a square grid ax = ay. Thus each vertex has 6 adjacent triangles each one with its own normal vector (denoted N1 to N6). These can be calculated using the cross product of the two vectors defining the side of the triangle and being careful on the order in which we do the cross product.
How to calculate vertex normals of a mesh overflow?
Closed 8 years ago. I have legitimately done every research possible for this, and it all just says to simply calculate the surface normals of each adjacent face. Calculating surface normals is easy, but how the heck do you find the adjacent faces for each vertex? What kind of storage do you use? Am I missing something?
How to calculate the normal of a vertex?
Think it otherway round: Iterate over the faces and add to the normal of the vertex. Once you processed all faces, normalize the vertex normal to unit length. I described it in detail here If you really want to find the faces for a vertex, the naive approach is to perform (linear) search for the vertex in the list of faces.
How to find the adjacent faces for each vertex?
Any guidance would be greatly appreciated. but how the heck do you find the adjacent faces for each vertex? Think it otherway round: Iterate over the faces and add to the normal of the vertex. Once you processed all faces, normalize the vertex normal to unit length.