Git Product home page Git Product logo

Comments (4)

httpdigest avatar httpdigest commented on August 21, 2024

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.

farmboy0 avatar farmboy0 commented on August 21, 2024

Thank you for pointing me to Matrix4f.setPerspectiveOffCenterPov, somehow I missed that function and only found setFrustum.

from joml.

httpdigest avatar httpdigest commented on August 21, 2024

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.

farmboy0 avatar farmboy0 commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.