Face Normals & Vertex Normals(面法线跟顶点法线的区别)

网友投稿 221 2022-11-30

Face Normals & Vertex Normals(面法线跟顶点法线的区别)

What is a face normal?

A face normal is a vector that describesthe direction a polygon is facing(see figure 1)

Figure 1: The face normal of a surface

What is a vertex normal?

Vertex normal have some relationships with face normal. We will discuss it in "How to calculate face normal and vertex normal?" Sometimes we can set vertex normal just as same as face normal,  however, using face normals as vertex normals does not produce smooth results when spproximating curved surfaces with triangles.

Vertex normal’s function:

Direct3D or Opengl needs to know the vertex normals so that it can determine the angle at which light strikes a surface,and since lighting calculations are done per vertex, Direct3D or Opengl needsto know the surface orientation(normal) per vertex.

How to calculate face normal and vertex normal?

For simple objects such as cubes and spheres, we can see the vertex normals by inspection. For more complex meshes, we need a more mechanical method. Suppose a triangle is formed by the vertices po,p1 and p2, and we need to compute the vertex normal for each of the vertices n0,n1 and n2.

First compute two vectors that lie on the triangle:

p1 - p0 = a

p2 - p0 = b

Then the face normal is :

n = a * b  (* means cross product)

Since each vertex normal is the same as the face normal

n0 = n1 = n2 = n

A better method for finding a vertex normal is normal averaging. To find the vertex normal vn of a vertex v, we find the face normals for all the triangles in the mesh that share vertex v. then vn is given by averaging all of these face normals. Here's an example to illustrate. Suppose three triangles, whose face normals are given by n0,n1 and n2, share the vertex v. Then vn is given by averaging the face normals: vn = (n0 + n1 + n2) /3.

During the transformation stages, it is possible for vertex normals to become non-normal. Therefore, it is best to be safe and renormalize all of your normals after the transformation stages.

Two different type of vertex normal:

Vertex normal can be the same as the face normal (see figure 5)。When we set the vertex normal as the same as the face normal in a .X file, a blue cube will looks like what in below figure, every face has its max brightness when we directly face it.

Figure 5:

When we set the vertex normal as the average of the three face normal, when we rotate the cube, the angle will has its max brightness.

Figure 6: A vertex's vertex normal is average of three face normals

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:DirectX 9.0 C++ 教程 第一个程序
下一篇:Java那点儿事之Map集合不为人知的秘密有哪些
相关文章

 发表评论

暂时没有评论,来抢沙发吧~