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 — using multitexturing

  1. Open the file ch7_Multitexture.html with your choice of HTML editor.
  2. At the top of the script block, add another texture variable:
    var texture2 = null;
    
  3. At the bottom of the configure function, add the code to load the second texture. As mentioned earlier, we're using a class to make this process easier, so the new code is as follows:
    texture2 = new Texture();
    texture2.setImage('textures/light.png');
    
  4. The texture we're using is a white radial gradient that simulates a spot light:
    Time for action — using multitexturing
  5. In the draw function, directly below the code that binds the first texture, add the following to expose the new texture to the shader: ...

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