In Chapter 3, Lights!, we compared point and directional lights:
In this section, we will combine directional and positional lights. We are going to create a third type of light: a directional point light. This light has both position and direction properties. We are ready to do this as our shaders can easily handle lights with multiple properties.
The trick to create these lights consist into subtract the light direction vector from the normal for each vertex. The resulting vector will originate a different Lambert coefficient that will reflect into the cone generated by the light source.
Open
ch6_Wall_Directional.html
in your HTML5 Internet web browser. As you can see there, the three light sources have now a direction. Let's take a look at the code.Open
ch6_Wall_Directional.html
in your source code editor.To create a light cone we need to obtain a Lambert coefficient per fragment. Just like in previous exercises, we obtain these coefficients in...