Webgpu worldViewProjection equivalent

glsl repro: Babylon.js Playground
webgpu repro: https://playground.babylonjs.com/?webgpu#6GFJNR#316

Using example from the docs, I’m trying to get the same result for worldViewProjection in webgpu. But the output seems to be very different, beyond differences in precision, am I missing smthg fundamental?

Z coords in clip space is [0..w] in WebGPU and [-w..w] in WebGL.

You can generate the same NDC Z value in WebGL/WebGPU this way:

woah, this is impt. Do we need a doc to explain diffs in spec for shader developers? Or is this the only diff? other coordinate systems are not impacted?

The most important difference is that Z in NDC coordinate system is [0..1], because it’s something you have to deal with yourself in your shader. There are other differences (like Y is top down in framebuffer/viewport coordinates), but we take care of it for you and you can assume it’s the same than in OpenGL (so you can use fragmentInputs.position.xy in the same way as gl_FragCoord.xy).

See WebGPU for more information about the coordinate systems in WebGPU.

Awesome! I will update the doc with this. Thanks, marking as solved.