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

Ground primitive not showing up in 2D #9619

Open
lilleyse opened this issue Jun 16, 2021 · 0 comments
Open

Ground primitive not showing up in 2D #9619

lilleyse opened this issue Jun 16, 2021 · 0 comments

Comments

@lilleyse
Copy link
Contributor

lilleyse commented Jun 16, 2021

In this sandcastle the ground primitive is missing in 2D but visible in 3D.

2D 3D
1 2

The problem is that GroundPrimitive uses ApproximateTerrainHeights to determine the min/max height for the shadow volume even when terrain is off. The approximate min/max height for this location is

-0.000018664832009763883
275.13

In 2D the globe tiles themselves are exactly 0.0 which means the shadow volume should just barely covers the surface, but there's likely precision issues at play that cause the shadow volume to be slightly above the surface so that nothing gets rendered.

To confirm this suspicion I lowered the min height by -10.0 and the shadow volume shows up again. This is definitely not a recommended solution.

function setMinMaxTerrainHeights(primitive, rectangle, ellipsoid) {
  var result = ApproximateTerrainHeights.getMinimumMaximumHeights(
    rectangle,
    ellipsoid
  );
  primitive._minTerrainHeight = result.minimumTerrainHeight - 10.0;
  primitive._maxTerrainHeight = result.maximumTerrainHeight;
}

The only reason it works in 3D is because the globe triangles are not consistently at 0.0 height. If I raise the min height by 0.5 the shadow volume disappears.

The key point is that ApproximateTerrainHeights should not be used for ground primitives in 2D, or used at all (CC #8480)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment