[Shader筆記]法向量Normal Vector
“ shader development using Unity” + Unity shader 入門精要筆記
p.s.尚未整理文章
in this chpater we will understand
what is normal ,
how it is mathematiclally represented
what it means for a straight and ccurve surface
how it is represented for 2d and 3d object
def:
(a) In 2D world
Plane
curved surface
(b) In 3D world
Straight
Curved
now we talk about the geometry
Geometry
our geometry makes it a bit easier to pick a point on the surface on the surface to draw a tangent , so we know that geometry are made up of vertices which from faces components of our geometry are vertex and face,and bace on the two components we will have vertex normal and face normal
so here’s the types of normal vector
(a) Face Normal
face are formed by vertices when we talk about geometry in 3d space face are always planar even for the curved geometries
the curve face are formed by several planar surface
if you have a curved surface and if you take a look at face of this that is forming a curve surface it will composed of several straight faces ,so the face will always be a planar sruface and the direction perpendicular to the center of the face is the normal
(b) Vertex Normal
vertex normal are calculated based on the face normals to which the vertex is contributing so if we have three vertices forming a face we will find out the normal of the face based on the position of the verticies
how to calculate the vertex normal with only a face?
if the geometry is made up of only one face we will just gives the face normal value we will copy this face normal value for all the vertices ,so the face normal will become vertex normal as well
how to calculate the vertex normal with multiple faces?
we will first find out the face normals
the sceond thing that we will do is that we will find which vertices are contributing to which faces
so the vertex below is contributing to the three faces, because three different faces are connected to this vertex or three different daces are formed by the contribution of this vertex so based on our previous calculation , we will copy the face normal value of all the faces and then we will add up the face normal value of all these tree contributing faces
then on the third step we will combine the value of all these three faces and the final value will become the verex normal
summarize
(1) Find the face normal of all faces to which vertex is contributing
(2) add all the face normals
(3) normalize the combined value
and we get the vertex normal