Time for Action: Adding a Blue Light to a Scene

We’re ready to take a look at the first example in this chapter. We will work on a scene with per-fragment lighting that has three light sources.

Each light has a position and a diffuse color property. This means we have two uniforms per light. Perform the following steps:

  1. To keep things simple, we have assumed that the ambient color is the same for all three light sources. We have also removed the specular property. Open the ch06_02_wall_initial.html file in your browser.
  1. You will see a scene such as the one displayed in the following screenshot where two lights (red and green) illuminate a black wall:
  1. Open the ch06_02_wall-initial.html file using your code editor. We will update the ...

Get Real-Time 3D Graphics with WebGL 2 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.