From VRML to WebGL: Part III

vcard's picture

From VRML to WebGL

Continued from Part I and Part II

3 - WebGL, the road ahead for 3D on the Web

At this point we rationalize about WebGL and the available reasons and evidence pointing it as the road ahead.

What is WebGL?
In mid 2000s the non-profit khronos group deploys OpenGL ES, a 3D rendering API for mobile and "embedded systems" (ES), based on the desktop long-established 3D rendering standard OpenGL but optimized for mobile/handheld devices. As an industry standard and royalty free, OpenGL ES became universally adopted on small computing devices, most notably phones and tablets to deliver a hardware-accelerated 3D experience. WebGL is a Web version of OpenGL ES 2.0. The designers felt that, by basing the API on OpenGL ES’s small footprint, it would be more achievable to deliver a consistent, cross-platform, cross-browser 3D API for the web.

WebGL is implemented as low-level API JavaScript. It uses the HTML5 canvas element and is accessed using DOM (Document Object Model) interfaces. Automatic memory management is provided as part of the JavaScript language. As such WebGL runs directly in browsers (desktops or mobiles) without the need for a specific plugin to harness the full power of the computer’s 3D rendering hardware. It is today supported by all the major browsers (IE, firefox, Chrome and Safari) on desktops and mobile platforms.

Why WebGL?
Some relevant aspects:

  1. Technically sound and proved standard. WebGL is based on long experienced, widely adopted, open and free standards and is already supported by all major browsers (IE, Firefox, Chrome and Safari) on desktops and mobile platforms. It is the long waited 3D on the web without plugins!
  2. It's light and fast. Based on standards with a small footprint, it is more capable to deliver a consistent, cross-platform, cross-browser 3D API for the web and capable to deliver a hardware-accelerated 3D experience using the device GPU directly. We should say here that we where amazed by the incredible speed this scene runs on a three year old galaxy note II mobile phone.
  3. Perfectly integrated in HTML 5 canvas. WebGL wires the GPU to the browser with a Javascript-based OpenGL ES API, thanks to the HTML5 canvas tag. This means WebGL content is a DOM element (this was never true with VRML, because it operated as a plug-in) and can be manipulated with the same procedural or formatting techniques as any other element. Its finally at reach a seamless 2D/3D web content integration.

WebGL risks, performance and compatibility
There are some concerns with WebGL security risks coming with direct access to the GPU. Due to these risks, initially Microsoft and Apple refused to support WebGL but that changed in time partially because the browsers war is back again and no one wants to be left behind and also because the upcoming WebGL versions addressed the security concerns. According to WebGL Security white paper, by the Khronos Group, WebGL conforms to all the security principles of the web platform and was designed with security in mind from day one.
WebGL performance is in general not as good as native execution, It is limited by the dynamic nature of JavaScript. Even so, performance has increased over time and the current browser implementations do a great job of optimizing it. In situations mostly GPU-bound, we can now expect WebGL to perform very similar to native code.
Universal WebGL availability and compatibility is growing but, in the meantime, here and there problems may occur. We have experienced problems with android running in virtual machines, which was to be expected, but problems may also occur, as we also have experienced, on systems with older graphics cards (GPU) and/or outdated drivers. In some cases certain features or all of WebGL isn't available. The Khronos WebGL wiki has a list of supported configurations.

How are going the alternatives to WebGL?
Comparing to VRML/X3D, WebGL is an obvious advance. On the other side comparing to Flash is not. Flash has been an incredible platform, done a lot for the web as an interactivity and entertainment platform. The reasons to change from flash to WebGL in the foreseen future are more "political" than technical.
The exact timing is not entirely known right now but there is a declared intention (started by apple in 2010) to end, sooner or later, the support for plugins in major browsers. Specially plugins that run proprietary compiled code. It affects Java, Silverlight, bs contact (VRML/X3D), Unity 3D Web plugin, Flash and many others. This is one of the reasons why Unity dropped flash to switch all development efforts in the creation of a WebGL deployer.

WebGL is already supported on more devices than Flash
"The times they are a-changin". The declared intentions to end the support for third party plugins in major browsers and the mobile market growth are changing the landscape dramatically and Flash isn't anymore the largest platform on the planet for interactive browser graphics. Flash is not supported on mobile browsers out of the box; it primarily reaches Mac and PC desktop browsers. On the contrary, WebGL reaches all platforms, desktop and mobile, via the browsers but can also be packaged into native apps and run independent of a browser on both desktop and mobile. It is now supported on more devices than Flash (according to Wired magazine estimates).
With such a wide support for WebGL, the demand for content is growing rapidly and the software industry is already committing. Tool producers are working on WebGL exporters or already have the solutions to offer. Unity 3D stopped flash export development (the feature was removed in recent versions) and is now committed to WebGL. The next version (version 5, already available in beta and the final coming soon) replaces the former Web plugin by a WebGL export format . Even Adobe itself has adapted its professional tools to produce content in HTML5 and WebGL alongside with Flash. Adobes position is incredibly pragmatic and, obviously, endorses WebGL as the road ahead for 3D graphics on the Web.

In the next part IV we list some fundamental tools for programmers (and designers with some programming skills) to create WebGL content for the on going virtual Web.

Vitor Cardoso