Time for action — directional point lights

In Chapter 3, Lights!, we compared point and directional lights:

Time for action — directional point 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.

  1. Open ch6_Wall_Directional.html ...

Get WebGL Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.