Multiple Lights and Materials
Typically, a scene has many light sources and many surface materials. Normally, you shade one material at a time, but many lights will light that material. We’ll show a shading model where each invocation of the shader selects a material and then applies all of, or a subset of, the lights to light it.
Normally, we need to light with multiple lights, while we’ve been writing example shaders for just one. A scene might have a street light, a flashlight, and the moon, for example, with each surface fragment getting a share of light from all three. You’d likely model these three lights as a point light, a spotlight, and a directional light, respectively, and have a single shader invocation perform all ...