Game Development Reference
In-Depth Information
Understanding surface normals for lighting
calculations
A
surface normal
(or just normal) is a vector that is perpendicular to a surface
at a particular position. Surface normals and vector normals are explained in the
following diagram:
Vertex Normals
Surface Normals
A
normal
is defined as the cross-product of any two nonparallel vectors that are
tangent to the surface at a point. We have to have a normal for each vertex of an
object. To calculate the normal of a vertex, we will need to do as depicted in the
following diagram:
Vector 1 = (V -V )
12
Vector 2 = (V -V )
23
Normal = (V -V )X(V -V )
12
N
23
V
1
V
2
V
3
Normal=cross product
ot
fwo
n
on parallel vector
Hence, for the vertex
V2
, its normal would be as follows:
V2
= (
V1
-
V2
) x (
V2
-
V3
)
The value of the first vector is as follows:
Vector 1
=
V1
-
V2