I’ve been patching ThreeJS to work with WebGL2 over the last couple days. Expect a bunch of PRs in the next couple weeks.
I’ve started with the easy ones:
WebGL2 is pretty backwards-compatible, so most things should work, but extensions presents a big problem. To fix this, I’m monkey-patching some
gl methods to make it more backward-compatible, and passing that context to the WebGLRenderer. Ideally, we could come up with a solve so users don’t need to do this.
In WebGL2, a lot of extensions have been promoted to core (see here for a list). When you call
gl.getExtension on one of these, it will return null, meaning a lot of ThreeJS code will break or not work as expected.
Another problem is with extensions in v100 GLSL shaders, like standard derivatives. In a WebGL2 context, you can only get standard derivatives by re-writing the shader in 300es syntax. Fixing this correctly would involve a lot of overhead for ThreeJS, and also a second code path for fallback shaders (WebGL1).
Next week I will put up a repo with a basic WebGL2 test-bed, monkey-patching the
gl context to fix the extension problems. Until then, you can check out these for details: