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

LineMaterial: fix segment clipping with reverse depth #29537

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

CodyJasonBennett
Copy link
Contributor

Description

Fixes software clipping for line segments in LineMaterial which is sensitive to both NDC range and the reversal of near/far values with reverse depth. This needs an example, but I noticed when using Line2 for axis helpers, axes appeared to be inverted.

@CodyJasonBennett CodyJasonBennett marked this pull request as draft October 1, 2024 09:49
@CodyJasonBennett CodyJasonBennett marked this pull request as ready for review October 1, 2024 13:09
@WestLangley
Copy link
Collaborator

Can you please provide a derivation for your conservative estimate of the near plane in the case of USE_REVERSEDEPTHBUF?

For reference, here is the original PR.

@Mugen87 Mugen87 added this to the r170 milestone Oct 2, 2024
@CodyJasonBennett
Copy link
Contributor Author

CodyJasonBennett commented Oct 3, 2024

I'm not sure what you're asking, sorry. Is the method unclear, or do you want me to additionally write how to compose a reversed projection matrix? It's notably using the [0, 1] range but reversed, and I wrote the terms inline to show this if you compare to how we create the non-reversed matrix in https://github.com/mrdoob/three.js/blob/dev/src/math/Matrix4.js#L788.

@WestLangley
Copy link
Collaborator

I was expecting something like the following so I can compare with my notes: 🙏

  1. begin with the formula for the original (perspective) projection matrix
  2. show the formula for the reversed projection matrix
  3. identify a and b.
  4. propose a formula for the z-coordinate of a conservative estimate of the near plane
  5. show that the coordinate lies between 0 and - near.

This parallels what I did in the original PR.

@mrdoob mrdoob modified the milestones: r170, r171 Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants