New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projection matrices differ between WebGL and WebGPU #894
Comments
Thanks for the heads up on this issue! Given that we don't support WebGPU-based layers (yet) resolving how the projections matrices will work with them isn't of immediate concern. We should definitely strive to be more precise about how the projection matrices are derived, though. (Due to hardware compat issue we can't give a precise algorithm for constructing them, but we can at least indicate the Z range.) When we do get to the point of integrating with WebGPU either of the options you mention sound reasonable. My preference would be to make the Z range configurable (maybe via |
Also, FWIW, we do talk about the Z range indirectly in the description of the
We'd obviously want something much more clearly linked to the projection matrix computation in the spec, though. |
That quote appears to be talking about what's configured by glDepthRange, which is talking about the output range in viewport space. Viewport space is the same for both WebGL and WebGPU. What's different is the transform from clip space to viewport space, or, in other words, the definition of clip space. This article has some of the details of what changed between the two specs. It's confusing given that there are so many options and spaces, though. |
Ah, you are correct.
Here at the Immersive Web Working Group, juggling confusing spaces is our specialty. 😜 |
See gpuweb/gpuweb#416 for context.
Currently, the spec does not define much about how the projection matrix is created, nor which clip space it is mapping to. Note that two different clip spaces are in common use: OpenGL (and thus WebGL) specify a clip space with a Z range of -1...1. Most other graphics APIs, like Direct3D, Metal, and Vulkan (and WebGPU) specify a clip space with a Z range of 0...1.
As such, projection matrices are dependent on the clip space they need to map to. This means that we cannot simply use a single projection matrix between WebGL and WebGPU.
Two solutions:
Regardless, the specification should mention which clip space the current projection matrices are currently mapping to.
The text was updated successfully, but these errors were encountered: