Using WebGL 2 by default


CesiumJS has been powered by WebGL 1 since the very beginning, and while support for WebGL 2 was added in 2015, as of version 1.99, CesiumJS defaults to running in a WebGL 1 context to ensure compatibility on as wide a range of devices as possible. However, given WebGL 2’s maturity and near universal support, we’re planning on switching to WebGL 2 by default. On platforms where WebGL 2 is not available, we will fallback to WebGL 1 with extensions.

Scope of Changes

On an API level, WebGL 2 is very similar to WebGL 1, however, there are a few major differences:

  • Shaders must be written in GLSL ES 300 instead of GLSL ES 100. This will require a rewrite of all CesiumJS shaders. If your application uses custom shaders or materials, they will have to be updated too.
  • Several extensions, such as ANGLE_instanced_arrays and OES_texture_float are part of the standard, so they’ll only need to be checked for when running in WebGL 1 compatibility mode.

We don’t plan on doing a complete overhaul and adopting features like uniform buffer objects immediately. The current effort is primarily targeting compliance with the WebGL 2 spec and providing an efficient fallback method to WebGL 1 where needed. In time, we see a lot of potential in using all that WebGL 2 has to offer for delivering new features and a better user experience, such as:

  • Enabling MSAA by default, resulting in improved visual quality
  • Optimizing picking
  • 3D textures for voxels and clouds

If your application already uses WebGL 2 with CesiumJS, then this change should result in better performance since we will no longer have to manually upgrade shaders from GLSL ES 100 to GLSL ES 300 at runtime.

We would like to hear any thoughts or concerns you may have regarding this change.