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

Fixed ground primitives in orthographic mode #8854

Merged
merged 4 commits into from
May 19, 2020
Merged

Conversation

IanLilleyT
Copy link
Contributor

@IanLilleyT IanLilleyT commented May 15, 2020

Fixes #5110

There were two problems going on:

  1. czm_geometricToleranceOverMeter was NaN because it assumed the frustum had an fov property, which is not the case for orthographic. This made shadow volumes extend REALLY far which caused some strange behavior, likely floating point precision related.
  2. The shadow volume geometry behind the near plane was being clipped, confusing the shadow volume algorithm into thinking the mesh was not watertight, which caused it to be shaded in weird ways. So now it clamps to the far AND the near plane. Not sure why this problem doesn't show up for perspective + multi-frustum. It's possible I haven't found the perfect camera angle to trigger it.

Before:

Screen Shot 2020-05-14 at 11 22 33 PM

After:

Screen Shot 2020-05-14 at 11 22 45 PM

Before:

Screen Shot 2020-05-14 at 11 26 43 PM

After:

Screen Shot 2020-05-14 at 11 27 14 PM

@IanLilleyT IanLilleyT requested a review from lilleyse May 15, 2020 04:38
@cesium-concierge
Copy link

Thanks for the pull request @IanLilleyT!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

  • Cesium Viewer works.
  • Works in 2D/CV.
  • Works (or fails gracefully) in IE11.

@IanLilleyT IanLilleyT changed the title Ortho ground primitive fix Fixed ground primitives in orthographic mode May 15, 2020
@lilleyse
Copy link
Contributor

The shadow volume geometry behind the near plane was being clipped, confusing the shadow volume algorithm into thinking the mesh was not watertight, which caused it to be shaded in weird ways. So now it clamps to the far AND the near plane. Not sure why this problem doesn't show up for perspective + multi-frustum. It's possible I haven't found the perfect camera angle to trigger it.

I thought this was what the stencil preload pass was for. Is the stencil preload pass even needed anymore?

@lilleyse
Copy link
Contributor

I thought this was what the stencil preload pass was for. Is the stencil preload pass even needed anymore?

Actually we should just scrap the three-pass shadow volume technique. I have the two-pass approach working on a branch and will open a PR after this is merged. The near/far clamping here is still important.

@@ -1136,13 +1136,9 @@ function depthClampVS(vertexShaderSource) {
// It is not to workaround an issue with Edge:
// https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12120362/
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, removed.

@lilleyse lilleyse merged commit d85033e into master May 19, 2020
@lilleyse lilleyse deleted the orthoGroundPrimitiveFix branch May 19, 2020 20:44
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.

GroundPrimitives are broken in orthographic projection
3 participants