Fragment Shaders for Different Light Styles
We’ll next discuss how fragment shaders compute the ambient, diffuse, and speculative amounts for several types of light, including directional lighting, point lighting, and spotlight lighting. These will be complete with a vertex and fragment shader pair built up as we go from simplest to more complex. The later shaders may seem long, but if you start with the simplest and follow the incremental additions, it will be easy to understand.
The comments in each example highlight the change or difference from the previous step, making it easy to look and identify the new concepts.
We’ll start with the simplest lighting—no lighting! By this, we don’t mean everything will be black, but ...