What version of WebGL does three use?

What version of webgl do three use?
I want to use texelfetch and understand it does only work in webgl2

This is a dead link:
https://threejs.org/docs/#manual/en/introduction/How-to-use-WebGL2

It can use either WebGL 2 or WebGL 1, depending on the device’s capabilities. You can check renderer.isWebGL2 to see what it is currently using.

It’s actually renderer.capabilities.isWebGL2 :innocent:.

3 Likes

Ok i understand. So there are no garanties that glsl functions that only is supported in webgl2 will run? it depends on the hardware specs in the current device that runs the application?

But how does it work. Will my application try to run with webgl2 in first place and if not possible on the current device fallback on webgl1 ?

I guess webgl2 is widely supported? Otherwise it seems a bit unstable to implement anything from webgl2

Yes.

It also depends on the browser (e.g. iOS browser and Safari in general do not yet support WebGL2).

This is the default of three.js. The engine ensures that all built-in materials work with both WebGL versions. However, using WebGL 2 exclusive features (like WebGLMultisampleRenderTarget) do not work with WebGL 1 and there is no fallback. If you write custom shader code in GLSL 3, you have to ensure to provide an alternative material with GLSL 1 code so it can run with WebGL 1.

Like mentioned above, all browsers on iOS devices do not yet support WebGL 2 (since they all rely on WebKit). Same for Safari desktop.

Correct. If you don’t know the devices of your users, you should only use WebGL 2 features with respective WebGL 1 fallbacks.

1 Like

Somewhere around 79%.

IMO, this is still a quite low value. I hope it won’t take too long until WebGL 2 finally lands in WebKit.

Most of all relevant devices support WebGL2, with relevant i mean the relevant target group (this is a bit vague, but you probably know what i mean), there still is a huge amount of desktops with XP running, there is just a large amount of people barely using computer despite smartphones which by default got a GPU chip and are more up-to-date than any other devices.

A year or 2 ago a friend from south africa who bought a 15$ phone had WebGL2 support - while your lost with apple devices.

A lot features of WebGL2 can be polyfilled, like most common issue being float textures, even 3D or array textures or multi render targets can be polyfilled, but it’s less about being possible rather than being reasonable and some issues from polyfills, such as using multiple render passes for multi render targets will cost much more performance, or using atlases for array textures will bring back the classical atlas issues/cost again.

In your case texelFetch could be polyfilled with something like:

vec4 texelFetch( sampler2D tex, vec2 pos, vec2 res ) {
	return texture2D( tex, ( pos + .5 ) / res );
}

There are only few major features you’ll only get with WebGL2, such as queries.

1 Like

All Apple mobile devices do not support WebGL 2 yet which is still a considerable amount of users.

Yes i wanted to add this in the first sentence ^^ if they’d support it that percentage probably would be around 90-95.

It depends on the project but you can at least wrap your app or game in a container that will support WebGL2, but i honestly just skip out this yet since i don’t want to pay 99€ yearly to apple just for putting it into the store, for playstore i paid 30€ once.

Since IE is basically gone Safari kinda took it’s place for popularity, i hope they keep up with other browsers or do it like Edgeium.

It seems the latest Safari Technology Preview has WebGL 2 now enabled. However, I don’t know when this lands in production. Hopefully soon^^.

2 Likes