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

Fix intermittent z-fighting issue in DepthPlaneVS #12385

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

jjhembd
Copy link
Contributor

@jjhembd jjhembd commented Dec 20, 2024

Description

#12188 included a change to DepthPlaneVS, to use a pre-composed modelViewProjection matrix for the vertex position. This was a misguided attempt to improve precision.

When multiplying by a vector by two matrices, we will usually get better precision (and performance) if we pre-multiply the matrices on the CPU. However, the projection matrix is a notable exception to this rule, as noted in #4250 (comment) based on a paper by Upchurch and Desbrun. For the view and projection matrices, sequential multiplication on the GPU side actually cancels some of the precision errors.

This PR reverts the change, to again use sequential multiplication of the modelView and projection matrices.

Issue number and link

Fixes #12337

Testing plan

Testing is somewhat challenging due to the intermittent nature of the bug.

  1. Load this local Sandcastle in the current main branch, and allow the animation to play for a few seconds until paths that should be behind the globe momentarily flash into view.
  2. Repeat the test in this branch, verify the z-fighting is fixed.
  3. Load the Sandcastle from Polyline and Globe Rendering Flicker #12371 and verify no z-fighting. (I was not able to reproduce that issue on Windows.)

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

Copy link

Thank you for the pull request, @jjhembd!

✅ We can confirm we have a CLA on file for you.

Copy link
Contributor

@lukemckinstry lukemckinstry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, the flicker is fixed in both linked sandcastle examples 👍

@lukemckinstry lukemckinstry added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit 6d02388 Dec 20, 2024
10 checks passed
@lukemckinstry lukemckinstry deleted the depth-plane-precision branch December 20, 2024 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depth Test Failure / Z-fighting
2 participants