O'Reilly logo

WebGL Beginner's Guide by Brandon Jones, Diego Cantor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required