What is WebGL?

You may have heard that 3D on the web is driven by WebGL. But what hides behind this cryptic acronym? That’s what this article will shed some light on. If you are eager to know how Sketchfab manages to pop a 3rd dimension from your 2D web browser this read is for you.

So, what is WebGL?

WebGL stands for Web Graphic Library. It’s the Web counterpart of OpenGL which is a cross platform Graphic Library, specified by the Khronos Group and implemented by most graphic card vendors drivers. This library is quite low level and is used by some games or graphic applications on desktop computers, laptops and mobiles (called Native applications).

Unfortunately, in a web context, you can’t access this kind of low level library, for security reasons. That’s the reason why WebGL was born: It’s a graphic library, designed for the web browsers. One can use it from a JavaScript web application to draw in 3 dimensions, in a similar way you would do on a desktop application with OpenGL. However, WebGL is a subset of OpenGL, so it comes with some limitations.

Most browsers now support WebGL 1, and that’s how Sketchfab is compatible with most of them.

Sketchfab and WebGL

Cedric, our CTO, was one of the very first 3D programmers to work on WebGL, back in 2011. WebGL was initiated by Mozilla in 2011, and Cedric worked with Mozilla to make the first demo of WebGL for the launch of Firefox 4. Our initial name before Sketchfab was actually ShowWebGL.

How do we use WebGL?

WebGL comes with what is called an API which is the acronym for Application Program Interface. It’s a fancy phrase that describes a list of functions an application can call to draw things on a web page. For example, each time Sketchfab draws something on the screen, there is a call to this API.

Why is it good?

WebGL is cross-platform. This means one can use the same API on all browsers that support it, and by extension on all platform/devices where those browsers can run.

This makes Sketchfab available on desktops, laptops, mobiles.

According to https://webglstats.com/ WebGL1 is supported by 98% of browsers.

A screenshot from WebGL Stats

What are some of its limitations?

As said in the introduction, WebGL is a subset of OpenGL, and it comes with limitations, that prevents Sketchfab from having even better rendering. WebGL 2 removes quite a lot of these limitations, but is not yet widely enough supported yet for us to use it.

Screenshot 2019-10-22 at 12.25.52
A screenshot from WebGL Stats

How does WebGL impact me when I make a configurator?

It doesn’t!

The Sketchfab Viewer API, which is used by Configurators, is a higher level API where you only manipulate objects in the scene, materials, lights, camera. The drawing part with WebGL is handled behind the scenes by Sketchfab.

What’s next?

WebGPU is a new specification and is likely to be the future of graphic libraries on the Web. It’s bringing the 3D on the Web closer to what you can have in a native application. It’s not yet implemented in browsers, but be sure that we are watching this closely and that we already have plans to use it.