In Chapter 3, The Basics of GLSL Shaders, we covered a number of techniques for implementing some of the shading effects that were produced by the former fixed-function pipeline. We also looked at some basic features of GLSL such as functions and subroutines. In this chapter, we'll move beyond those introductory features, and see how to produce shading effects such as spotlights, fog, and cartoon style shading. We'll cover how to use multiple light sources and how to improve the realism of the results with a technique called per-fragment shading.
We'll also cover the very popular and important Blinn-Phong reflection model and directional light sources.
Finally, we'll cover how to fine-tune the depth test by configuring the early depth test optimization.