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

Help with perspective projection #315

Closed
TypeSafeSchwalbe opened this issue Aug 1, 2022 · 1 comment
Closed

Help with perspective projection #315

TypeSafeSchwalbe opened this issue Aug 1, 2022 · 1 comment
Labels

Comments

@TypeSafeSchwalbe
Copy link

TypeSafeSchwalbe commented Aug 1, 2022

I need help with creating the projection-view matrix for a perspective camera.
I have this piece of code already...

viewMatrix.setLookAt(position, cameraLookAt, cameraUp);
projectionMatrix.setPerspective(fov, aspectRatio, nearPlane, farPlane);
Matrix4f projectionViewMatrix = new Matrix4f().set(projectionMatrix).mul(viewMatrix);
// projectionViewMatrix holds the result!

...that generates a Matrix4f that I can pass to my vertexshader to convert world coordinates to NDC.
This currently works... kinda. Everything that gets rendered is inverted on the Y-axis (upside down).
I've looked for solutions online, tried the various invert-methods of the Matrix4f-class,
but everything I tried just does not render anything (the matrix is probably modified in a weird way)...

@TypeSafeSchwalbe
Copy link
Author

Oh wow. The issue actually does not have anything to do with JOML. I rendered my frame buffers upside down...
JOML works perfectly fine, and no further method calls were needed.
Thank you for making JOML (I would have to write A LOT of code otherwise...)!

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

No branches or pull requests

2 participants