Code Monkey home page Code Monkey logo

Comments (4)

walbourn avatar walbourn commented on June 2, 2024

Thanks for the feedback. It turns out you can trivially use the existing functions for reverse-z: swap the far/near values:

m_proj = XMMatrixPerspectiveFovLH(XM_PIDIV4, aspect, c_farZ, c_nearZ);

Be sure to clear the depth-buffer with 0.0 instead of 1.1, and use the reverse depth comparison operator for the Depth/Stencil state (i.e. D3Dxx_COMPARISON_GREATER_EQUAL instead of D3Dxx_COMPARISON_LESS_EQUAL).

I have support for reverse-z in the DirectX Tool Kit CommonStates.

from directxmath.

TheRealMJP avatar TheRealMJP commented on June 2, 2024

Hey @walbourn, thank you for replying! To be clear I was specifically referring to the "infinite" variant of a reversed-z projection, which cannot be done with the existing perspective matrix functions (finite reversed projections can be done as you suggested). The infinite reversed matrix has this form for the LH variant:

xScale     0          0             0
0        yScale       0             0
0          0          0             1
0          0          znear         0

from directxmath.

walbourn avatar walbourn commented on June 2, 2024

Thanks for the clarification.

from directxmath.

walbourn avatar walbourn commented on June 2, 2024

Thank you for the suggestion. I definitely see the value in this, but I'll need a bit more time to do the full validation/verification this warrants. In the meantime, you can of course easily create your own projection matrix with existing constructors and functions.

from directxmath.

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.