Switch to the store?

WebGL Beginner's Guide

More Information
  • Understand the structure of a WebGL application
  • Build and render 3D objects with WebGL
  • Load complex models using JSON and AJAX
  • Set up a lighting model using shaders, physics of light reflection, and lighting strategies
  • Create a camera and use it to move around a 3D scene
  • Use texturing, lighting and shading techniques to add greater realism to 3D scenes
  • Implement selection of objects in a 3D scene with the mouse
  • Advanced techniques to create more visually complex and compelling scenes

WebGL is a new web technology that brings hardware-accelerated 3D graphics to the browser without installing additional software. As WebGL is based on OpenGL and brings in a new concept of 3D graphics programming to web development, it may seem unfamiliar to even experienced Web developers.

Packed with many examples, this book shows how WebGL can be easy to learn despite its unfriendly appearance. Each chapter addresses one of the important aspects of 3D graphics programming and presents different alternatives for its implementation. The topics are always associated with exercises that will allow the reader to put the concepts to the test in an immediate manner.

WebGL Beginner's Guide presents a clear road map to learning WebGL. Each chapter starts with a summary of the learning goals for the chapter, followed by a detailed description of each topic. The book offers example-rich, up-to-date introductions to a wide range of essential WebGL topics, including drawing, color, texture, transformations, framebuffers, light, surfaces, geometry, and more. With each chapter, you will “level up” your 3D graphics programming skills. This book will become your trustworthy companion filled with the information required to develop cool-looking 3D web applications with WebGL and JavaScript.

  • Dive headfirst into 3D web application development using WebGL and JavaScript.
  • Each chapter is loaded with code examples and exercises that allow the reader to quickly learn the various concepts associated with 3D web development
  • The only software that the reader needs to run the examples is an HTML5 enabled modern web browser. No additional tools needed.
  • A practical beginner's guide with a fast paced but friendly and engaging approach towards 3D web development
Page Count 376
Course Length 11 hours 16 minutes
Date Of Publication 14 Jun 2012
System requirements
What kind of rendering does WebGL offer?
Structure of a WebGL application
Creating an HTML5 canvas
Time for action – creating an HTML5 canvas
Accessing a WebGL context
Time for action – accessing the WebGL context
WebGL is a state machine
Time for action – setting up WebGL context attributes
Loading a 3D scene
Time for action – visualizing a finished scene
Vertices and Indices
Overview of WebGL's rendering pipeline
Rendering geometry in WebGL
Putting everything together
Time for action – rendering a square
Rendering modes
Time for action – rendering modes
WebGL as a state machine: buffer manipulation
Time for action – enquiring on the state of buffers
Advanced geometry loading techniques: JavaScript Object Notation (JSON) and AJAX
Time for action – JSON encoding and decoding
Time for action – loading a cone with AJAX + JSON
Lights, normals, and materials
Using lights, normals, and materials in the pipeline
Shading methods and light reflection models
ESSL—OpenGL ES Shading Language
Writing ESSL programs
Time for action – updating uniforms in real time
Time for action – Goraud shading
Time for action – Phong shading with Phong lighting
Back to WebGL
Bridging the gap between WebGL and ESSL
Time for action – working on the wall
More on lights: positional lights
Time for action – positional lights in action
WebGL does not have cameras
Vertex transformations
Normal transformations
WebGL implementation
The Model-View matrix
The Camera matrix
Time for action – exploring translations: world space versus camera space
Time for action – exploring rotations: world space versus camera space
Basic camera types
Time for action – exploring the Nissan GTX
The Perspective matrix
Time for action – orthographic and perspective projections
Structure of the WebGL examples
Using colors in WebGL
Use of color in objects
Time for action – coloring the cube
Use of color in lights
Architectural updates
Time for action – adding a blue light to a scene
Time for action – adding a white light to a scene
Time for action – directional point lights
Use of color in the scene
Depth testing
Alpha blending
Time for action – blending workbench
Creating transparent objects
Time for action – culling
Time for action – creating a transparent wall
What is texture mapping?
Creating and uploading a texture
Using texture coordinates
Using textures in a shader
Time for action – texturing the cube
Texture filter modes
Time for action – trying different filter modes
Texture wrapping
Time for action – trying different wrap modes
Using multiple textures
Time for action – using multitexturing
Cube maps
Time for action – trying out cube maps
Architectural updates
Time for action – testing some post-process effects
Point sprites
Time for action – using point sprites to create a fountain of sparks
Normal mapping
Time for action – normal mapping in action
Ray tracing in fragment shaders
Time for action – examining the ray traced scene


Diego Cantor

Diego Cantor is a software engineer with experience in government, education, finance, enterprise resource planning (ERP) and data warehouse (DWH) projects. He has also been appointed as instructor at the Faculty of Engineering at the Universidad de los Andes (Colombia) in the department of Systems Engineering. He did an internship at the CREATIS lab in Lyon, France. During that internship he implemented a component model based on the OSGi standards for medical imaging applications. After that, he did an internship at the Australian e-Health Research Centre in Brisbane, Australia, working on imaging analysis techniques and applying them to the study of Alzheimer's disease. During his graduate studies, Diego worked on the processing of medical images (MRI) in 3D. This work led him to work with VTK and ITK and later on to research on technologies to improve state of the art medical imaging visualization and medical simulation systems. Currently he is a PhD student at the University of Western Ontario in Canada. There, he works on computational methods to correlate MRI to digital histology imaging. Diego speaks English, Spanish, and French.

Brandon Jones

Brandon Jones has been developing WebGL demos since the technology first began appearing in browsers in early 2010. He finds that it’s the perfect combination of two aspects of programming that he loves, allowing him to combine eight years of web development experience and a life-long passion for real-time graphics. Brandon currently works with cutting-edge HTML5 development at Motorola Mobility.