More on Lights: Positional Lights

Before finishing this chapter, let's revisit the topic of lights. So far, for the purpose of our examples, we’ve 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 directional lights. Now, we are going to consider a case where the light source is relatively close to the object it needs to illuminate. Think, for example, of a desk lamp illuminating the document you’re reading. These lights are positional lights:

As we experienced before, when working with directional lights, only one variable is required. This is the light direction we represented in the uLightDirection uniform.

In contrast, when working with positional lights, we need to know the location of the light. We can represent it by using a uniform that we will name uLightPosition. As is the case when using positional lights, the light rays here are not parallel to each other; as a result, we need to calculate each light ray separately. We will do this by using a varying that we will name vLightRay.

In the next section, we will investigate how a positional light interacts with a scene.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.200.143