As covered in the Implementing the Phong reflection model recipe in Chapter 3, The Basics of GLSL Shaders, the specular term in the equation involves the dot product of the vector of pure reflection (r), and the direction toward the viewer (v):
In order to evaluate the preceding equation, we need to find the vector of pure reflection (r), which is the reflection of the vector toward the light source (s) about the normal vector (n):
We can avoid calculating r by making use of the following observation. When v is aligned with r, the normal vector (n) must be halfway between v and s. Let's define the halfway vector (h) as the vector that is halfway between v and s, where h is normalized after the addition:
The following diagram shows the relative positions of...