Skip to main content

Khronos Blog

WebGL 2.0 Arrives

WebGL 2.0WebGL is a cross-platform, royalty-free standard which provides low-level, GPU-accelerated graphics APIs to the web. To date, WebGL 1.0 has exposed the OpenGL ES 2.0 feature set, offering the power of a shader-based, programmable graphics pipeline to developers.

WebGL 2.0 is a long-awaited feature upgrade which delivers the OpenGL ES 3.0 feature set, bringing the browser’s graphical capabilities closer to the state of the art. WebGL 2.0 is shipping now [1] in the Firefox and Chrome browsers, and all WebGL implementers have declared intent to support it.

So, what shiny new features can we use in WebGL 2.0? Here are just a few: transform feedback, instanced rendering, multiple render targets, uniform buffer objects, and occlusion queries. Key features like integer and bitwise arithmetic, and more powerful texture sampling primitives, are added to the shading language. These features improve performance and enable graphical techniques like deferred shading and physically based rendering.

WebGL 2.0 also offers much wider texture support, including 3D textures, immutable textures, non-power-of-two textures, integer and float textures, depth textures, Red and RG textures, seamless cube maps, and sampler objects. They enable applications like medical data visualization and high-dynamic-range imaging, and may significantly improve video memory consumption efficiency.

WebGL 2.0 Transform Feedback demoWebGL 2.0 Transform Feedback demo (live link, Github repository)WebGL 2.0 Transform Feedback demo (live link, Github repository)

For more awesome demos, information on the new features, and a few extra technical details, see Firefox’s WebGL 2.0 launch announcement. For nice, self-contained examples of many of the new features, check out the WebGL 2.0 Samples Pack.

What are the differences compared to OpenGL ES 3.0? Because WebGL runs on a wide range of web browser architectures, operating systems, and graphics APIs, a few features had to be left out to avoid performance penalties on certain platforms. Compressed texture formats (ETC2/EAC) have moved from the core API into an extension and will only be exposed if hardware support is available. Texture swizzling and CPU-mapped GPU memory (MapBufferRange) have been removed. Importantly, undefined behaviors in the ES 3.0 spec are either defined or rejected from WebGL 2.0. Full details can be found in the WebGL 2.0 specification, Section 5, “Differences between WebGL and OpenGL ES 3.0.”

Why has it taken so long for WebGL 2.0 to arrive? It’s crucial that WebGL have consistent behavior across all of its supported platforms. It took many iterations for WebGL 1.0 to reach its current level of stability, with web developers from across the globe contributing hundreds of tests toward this goal. With WebGL 2.0, tremendous effort was invested up front in a rigorous conformance suite. The test suite is ten times as large (by execution time) as that for WebGL 1.0, and many graphics driver bugs have been found and fixed in the process. Developers can use WebGL 2.0 today with confidence, knowing that their applications will be portable.

What’s next? An extension to WebGL 2.0 providing compute shader support is under development, which will bring many leading-edge graphics algorithms to the web. Khronos is also beginning work on the next generation of WebGL, to bring the enhanced performance of the new generation of explicit 3D APIs to the web. Stay tuned for more news!

We look forward to your next graphical creations on the web using WebGL 2.0!

[1] WebGL 2 requires DirectX 11 on Windows, OpenGL 4.1 on macOS, OpenGL 3.3 with some extensions on Linux, or OpenGL ES 3.0. For users on older graphics hardware, this may be an excuse to upgrade to new machines to enjoy these great new features.