Game Engine Architecture

(Ben Green) #1
429

In these equations, the vector Ri = [ Rxi Ryi Rzi ] is the refl ection of the light ray’s
direction vector Li about the surface normal N.
The vector Ri can be easily calculated via a bit of vector math. Any vec-
tor can be expressed as a sum of its tangential and normal components. For
example, we can break up the light direction vector L as follows:


LL L=+TN.


We know that the dot product (N · L) represents the projection of L normal
to the surface (a scalar quantity). So the normal component LN is just the unit
normal vector N scaled by this dot product:


(^) LN=⋅(N LN).
The refl ected vector R has the same normal component as L but the opposite
tangential component (–LT). So we can fi nd R as follows:
This equation can be used to fi nd all of the Ri values corresponding to the light
directions Li.
Blinn-Phong
The Blinn-Phong lighting model is a variation on Phong shading that calcu-
lates specular refl ection in a slightly diff erent way. We defi ne the vector H to
be the vector that lies halfway between the view vector V and the light direc-
tion vector L. The Blinn-Phong specular component is then (N · H)a, as op-
posed to Phong’s (R · V)α. The exponent a is slightly diff erent than the Phong
exponent α, but its value is chosen in order to closely match the equivalent
Phong specular term.
The Blinn-Phong model off ers increased runtime effi ciency at the cost of
some accuracy, although it actually matches empirical results more closely
than Phong for some kinds of surfaces. The Blinn-Phong model was used
almost exclusively in early computer games and was hard-wired into the
fi xed-function pipelines of early GPUs. See htt p://en.wikipedia.org/wiki/
Blinn%E2%80%93Phong_shading_model for more details.
BRDF Plots
The three terms in the Phong lighting model are special cases of a general local
refl ection model known as a bidirectional refl ection distribution function (BRDF ).
10.1. Foundations of Depth-Buffered Triangle Rasterization


()


2;


2( ).


NT
NN
N

=−


= −−


=−


=⋅−


RL L


L LL


LL


R N LN L

Free download pdf