Title: Graphics CSCI 343, Fall 2005 Lecture 19 Lighting and Shading II
1Graphics CSCI 343, Fall 2005Lecture
19Lighting and Shading II
2The Phong Reflection Model
The phong reflection model leads to efficient
computation of surface lighting and gives
reasonably realistic renderings. It uses 4
vectors to calculate the color and intensity of a
point on a surface.
l
n
n normal to the surface at p l direction to
light source v direction to viewer (COP) r
direction of perfectly reflected ray (determined
by n and l)
v
p
r
I Ia Id Is LaRa LdRd LsRs
3The complete Phong reflection model
Putting all the terms together gives the full
Phong reflection model
4Computing Dot Products
Computing Dot Products in 2 dimensions. Recall
that
where q is the angle between the two vectors.
What is this dot product in terms of x1, y1, x2,
y2?
(x1, y1)
q
(x2, y2)
Similarly, in 3D
5Finding the Normal to a plane
A plane can be defined by 3 non-colinear points,
p0, p1, and p2. These points define 2 vectors,
p1-p0, and p2-p0 The normal to the plane is the
cross product between the two vectors
(p1-p0)x(p2-p0). The direction of the
normal determines the outward facing side of the
plane.
p2
p1
p0
6Computing a cross product
Suppose
Then
7Example of a cross product
Suppose
Then
8Normalizing the length to 1
The length of the normal vector should always be
set to 1.
Suppose
Then
and
9Special Cases of NormalsA plane
For a surface defined as a function of x, y and
z, the normal is specified as
For a plane defined as ax by cz d
0, we can show that the normal is (but we
still need to normalize the length to 1).
10Special Cases of Normals A sphere
For a point, p (x, y, z) on a sphere defined
as x2 y2 z2 -1 0
n ?
Normalized, n' ?
11Computation of r
n
r must lie in the same plane as l and
n. Therefore,
r
l
qi
qr
From the above three equations we can derive r in
terms of l and n (we will do this in class)
12The halfway vector
Computing r takes a lot of computation. We can
approximate the angle between r and v by
computing the halfway vector.
h
n
r
l
y
qi
v
f
What is f in terms of y?
2y f
The angle between n and h, y, is 1/2 the angle
between r and v, f.
We can use y instead of f in our calculation of
specular reflection
We adjust a' to account for the fact that y lt f