Chapter 7. Light and Shadow

Chapter Objectives

After reading this chapter, you’ll be able to do the following:

• Code a spectrum of fragment shaders to light surfaces with ambient, diffuse, and specular lighting from multiple light sources.

• Migrate lighting code between fragment and vertex shaders, based on quality and performance trade-offs.

• Use a single shader to apply a collection of lights to a variety of materials.

• Select among a variety of alternative lighting models.

• Have the objects in your scene cast shadows onto other objects.

In the real world, we see things because they reflect light from a light source or because they are light sources themselves. In computer graphics, just as in real life, we won’t be able to see an object ...

Get OpenGL® Programming Guide: The Official Guide to Learning OpenGL®, Version 4.5 with SPIR-V, Ninth 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.