Now we are ready to take a look at the first example of 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.
Also for simplicity, we have assumed here that the ambient color is the same for the three light sources. For the sake of simplicity, we have removed the specular property. Open the file
ch6_Wall_Initial.html
using your HTML5 web browser.You will see a scene such as the one displayed in the following screenshot where there are two lights (red and green) illuminating a black wall:
Open the file
ch6_Wall_Initial.html
using your preferred text editor. We will update the vertex shader, the fragment shader, the JavaScript code, and the HTML code to add the blue light.Updating the vertex shader: Go to the vertex shader. You can see these two uniforms:
uniform vec3 uPositionRedLight; uniform vec3 uPositionGreenLight...