Skip to content
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

Missing frustumZO method #441

Open
AshleyScirra opened this issue Nov 8, 2021 · 1 comment
Open

Missing frustumZO method #441

AshleyScirra opened this issue Nov 8, 2021 · 1 comment

Comments

@AshleyScirra
Copy link

When using perspective with an off-axis projection, mat4.frustum is used instead of mat4.perspective. In v3.4.1 there's a mat4.perspectiveZO method for WebGPU, but no mat4.frustum. So web apps using an off-axis projection are missing a way to use the right matrix for WebGPU in glMatrix.

@AshleyScirra
Copy link
Author

Figured out a workaround from the code referenced in #369:

const matWebGLtoWebGPU = mat4.fromValues(
    1, 0,   0, 0,
    0, 1,   0, 0,
    0, 0, 0.5, 0,
    0, 0, 0.5, 1,
);

// Calculate WebGL matrix (Z range [-1, 1])
mat4.frustum(outMat, /* ... */);

// Convert to WebGPU matrix (Z range [0, 1])
if (isWebGPU)
    mat4.mul(outMat, matWebGLtoWebGPU, outMat);

Hopefully an easy add for a glMatrix frustumZO method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant