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: A vertex has three vertex normals



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


http://www.waitingfy.com/?p=425

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

瓦力冫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值