The Blinn-Phong reflection model

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):

This equation is implemented using the GLSL function reflect.

We can avoid calculating r by making use of the following observation. When v is aligned with r, the normal vector ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.