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 — examining the ray traced scene

  1. Open the file ch10_Raytracing.html in an HTML5 browser. You should see a scene with a simple lit, bobbing sphere like the one shown in the following screenshot:
    Time for action — examining the ray traced scene
  2. First, in order to give us a way of triggering the shader, we need to draw a full screen quad. Luckily for us, we already have a class that helps us do exactly that from the post-processing example earlier in this chapter! Since we don't have a scene to process, we're able to cut a large part of the rendering code out, and the entirety of our JavaScript drawing code becomes:
    function render(){ gl.viewport(0, 0, c_width, c_height); gl.clear(gl.COLOR_BUFFER_BIT ...

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