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 — adding a white light to a scene

  1. Open the file ch6_Wall_LightArrays.html in your HTML5 browser. This scene looks exactly as ch6_Wall_Final.html, however the code required to write this scene is much less as we are using uniform arrays. Let's see how the use of uniform arrays change our code.
  2. Let's update the vertex shader first. Open the file ch6_Wall_LightArrays.html using your favorite source code editor. Let's take a look at the vertex shader. Note the use of the constant integer expression const int NUM_LIGHTS = 3; to declare the number of lights that the shader will handle.
  3. Also, you can see there 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 ...

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