Let's cover an example of how we'd add a new light to our scene:
- Open the ch06_04_wall-light-arrays.html file in your browser. This scene looks exactly like ch06_03_wall-final.html; however, the code is far less complex since we are now using uniform arrays. Let's see how using uniform arrays changes our code.
- Open the ch06_04_wall-light-arrays.html file in your code editor. Let's take a look at the vertex shader. Note the use of the constant integer expression const int, numLights = 3;, to declare the number of lights that the shader will handle.
- There, you can also see that a uniform array is being used to operate on light positions. Note that we are using a varying array to pass the light rays (for each light) to the fragment shader:
for(int i = 0; i < numLights; i++) {
vec4 lightPosition = uModelViewMatrix...