More on lights: positional lights
Before we finish the chapter, let's revisit the topic of lights. So far we have assumed that our light source is infinitely far away from the scene. This assumption allows us to model the light rays as being parallel to each other. An example of this is sunlight. These lights are called directional lights; now we are going to consider the case where the light source is relatively close to the object that it is going to illuminate. Think, for example, of a lamp desk illuminating the document you are reading. These lights are called positional lights.
As we experienced before, when working with directional lights, only one variable is required. This is the light direction that we have represented in the uniform uLightDirection
.
Contrastingly, when working with positional lights, we need to know the location of the light. We can represent it using a uniform that we will name uLightPosition
. As when using positional lights, the light rays are not parallel to each...