-
Notifications
You must be signed in to change notification settings - Fork 104
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
Matrix4f.setFrustum with zNear values < 1.0f creates distortions #341
Comments
I don't know what "distortions" you are referring to, but both functions are actually equivalent, as are the implementation of GLM and the derivations of http://www.songho.ca/opengl/gl_projectionmatrix.html and http://learnwebgl.brown37.net/08_projections/projections_perspective.html#building-the-prospective-projection-transform . The OpenXR function just takes different parameters. It does not take the same parameters as the typical OpenGL/JOML In the end, all those function are exactly equivalent. The OpenXR function |
Thank you for pointing me to Matrix4f.setPerspectiveOffCenterPov, somehow I missed that function and only found setFrustum. |
Yeah, what can I say: Naming things and trying to find things by name is hard. :) Actually, if you have the effective tan of the angles, instead of the angles themselves, and you don't need to compute tan(angle) yourself, then you could simply call the setFrustum(tanAngleLeft*zNear, tanAngleRight*zNear, tanAngleDown*zNear, tanAngleUp*zNear, zNear, zFar); given that you already have |
I was computing the tan(angle) values myself because I get the angles from the openxr runtime, unfortunately i only found the setFrustum function to use them. |
I compared JOML's implementation with https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/d6b6d7a10bdcf8d4fe806b4f415fde3dd5726878/src/common/xr_linear.h#L560
and there are only 2 differences
m00 = 2.0f / (right - left) instead of (zNear + zNear) / (right - left)
m11 = 2.0f / (top - bottom) instead of (zNear + zNear) / (top - bottom)
This works without distortions even for very small zNear values like 0.05f
The text was updated successfully, but these errors were encountered: