Chapter 3. Lighting, Shading, and Optimization
In this chapter, we will cover:
- Shading with multiple positional lights
- Shading with a directional light source
- Using per-fragment shading for improved realism
- Using the halfway vector for improved performance
- Simulating a spotlight
- Creating a cartoon shading effect
- Simulating fog
- Configuring the depth test
Introduction
In Chapter 2, 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 the shading model introduced in Chapter 2, The Basics of GLSL Shaders, 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 see techniques...