Comments (4)
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 frustum
function, but instead solely the tangens of the angle from the viewpoint to the left, right, top and bottom plane edges of the near plane (so regardless of the distance to the near plane along the Z axis). The standard OpenGL/JOML frustum
function expects the actual distances of the vector along the Z view direction to the left, right, top and bottom edges of the near plane.
In the end, all those function are exactly equivalent.
The OpenXR function XrMatrix4x4f_CreateProjection
is more comparable to JOML's perspectiveOffCenterFov
: https://javadoc.io/doc/org.joml/joml/latest/org/joml/Matrix4f.html#perspectiveOffCenterFov(float,float,float,float,float,float) in that this JOML function also takes just angular arguments to the left, right, top and bottom near plane edges (the actual angles in this case, not the tangens, but that's irrelevant here).
To then compute those angles to actual distances, the near
value (distance along z-axis to the near plane) is multiplied in.
from joml.
Thank you for pointing me to Matrix4f.setPerspectiveOffCenterPov, somehow I missed that function and only found setFrustum.
from joml.
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
method like setPerspectiveOffCenterPov
does: https://github.com/JOML-CI/JOML/blob/main/src/main/java/org/joml/Matrix4f.java#L10307
setFrustum(tanAngleLeft*zNear, tanAngleRight*zNear, tanAngleDown*zNear, tanAngleUp*zNear, zNear, zFar);
given that you already have tanAngleLeft
, tanAngleRight
, tanAngleDown
and tanAngleUp
(without requiring you to compute the tan(angle) function yourself from actual angles, of course). So, it's just about multiplying all the tan(angle) arguments with zNear
and you have effectively the arguments that setFrustum
needs.
from joml.
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.
from joml.
Related Issues (20)
- Kotlin extensions are not involved in the final artifact HOT 5
- Matrix3f class missing set(float m[], int off) method HOT 1
- Make Matrix4f element-fields "mxy" public like in Matrix3f HOT 1
- Matrix4f.getEulerAnglesYXZ HOT 1
- The function getTransposedToAddress() does not exist HOT 2
- AABB Intersections HOT 1
- [PR Reminder] You can instatiate instances of the Math utility class
- Can't figure out interesting behavior by Matrix4f.transpose() HOT 1
- A simpler way to create a Vector2d from a Vector3d HOT 6
- Optimize Vector Multiplication? HOT 20
- rotation matrix scaling HOT 1
- Vector3d.div() incorrectly takes in Vector3d instead of Vector3dc HOT 1
- Long counterpart to integer components HOT 2
- Quaternionf fromAxisAngleDeg angle parameter description discrepancy HOT 1
- Bug in MemUtilUnsafe.put3x4 HOT 1
- Consistent Array Constructors/Accessors
- Scala Operators
- [Suggestion/Discussion] Matrix Consumer Actions
- Using JOML without Kotlin HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from joml.