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

Entity incorrectly occluded when no tile is in view #10932

Open
calogeromauceri opened this issue Dec 1, 2022 · 8 comments
Open

Entity incorrectly occluded when no tile is in view #10932

calogeromauceri opened this issue Dec 1, 2022 · 8 comments

Comments

@calogeromauceri
Copy link
Contributor

When the camera is below the ellipsoid minimumHeight and looking at an entity with no tiles in view, then the entity gets incorrectly occluded

Here is an example using moon terrain, where the camera is located in a region that goes below the mean radius.
When the camera is above the mean ellipsoid radius the sphere on the sky (it might be a planet) and the sun are properly rendered. When the camera is below the mean ellipsoid radius the sphere and the sun are not rendered

Sandcastle example

The problem is in the occluder being used for checking if the entity is visible or not.
https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/Scene/Scene.js#L1799-L1823

If no tile is in the current view the scene frame minimumTerrainHeight is set to 0, so the occluder bounding sphere radius is equal to the ellipsoid minimum radius which in this case is above the camera location, causing the camera to be "occluded".
When tiles are visible (in the sandcastle above select "horizon"), then the scene frame minimumTerrainHeight is properly computed.

Browser:
Any

Operating System:
Any

@ggetz
Copy link
Contributor

ggetz commented Dec 6, 2022

Thanks for the report @calogeromauceri! I believe you are correct in explaining why this is happening. This may be tricky to fix without a performance hit since, for a true fix, I think we'd need to iterate through additional tiles each update. @kring would you happen to have additional insight here?

@kring
Copy link
Member

kring commented Dec 6, 2022

When there are no tiles, then perhaps the minimumTerrainHeight should be the planet's actual minimum terrain height, rather than 0?

@calogeromauceri
Copy link
Contributor Author

calogeromauceri commented Dec 20, 2022

I'm happy to help fixing this problem as long as I have some guideline on how to do it. @kring I think the solution you are proposing is a good one, but how do we know the minimum terrain height? should it be a setting parameter for the globe or is it possible to get it somehow querying the terrain provider?

@calogeromauceri
Copy link
Contributor Author

Any updates on this issue? I'm happy to help if needed!

@ggetz
Copy link
Contributor

ggetz commented Sep 10, 2024

Thanks @calogeromauceri.

how do we know the minimum terrain height?

ApproximateTerrainHeights, once loaded, contains minimum and maximum values for earth. This is an approximation, and not suitable for all terrain datasets (see this issue for more info), but it should address the earth.

Other than that, I don't believe it's trivial to get the minimum terrain height at runtime. Perhaps we could allow the user to specify these values themselves.

@calogeromauceri
Copy link
Contributor Author

calogeromauceri commented Sep 11, 2024

Thank you very much for your suggestion, @ggetz. Based on your hint, I’ve come up with a fix. I'll submit a pull request with my changes soon.

Note: I updated the sandcastle example to show the issue with latest Cesium version (currently 1.121)

sandcastle

@calogeromauceri
Copy link
Contributor Author

@ggetz I just submitted a pull request for this issue #12190. The fix is pretty simple, hope it is accepted

@calogeromauceri
Copy link
Contributor Author

I closed the pull request because, as discussed in the pull request conversation, the fix does not solve the issue in all scenarios. Specifically, it works when not tiles are in view, but when the camera is looking at the horizon with a few tiles visible, if their minimum terrain height is higher than the camera height, the entities remain occluded.

Currently, I do not have other ideas on how to fix this problem. The occlusion detection is disabled when the camera is under the terrain or when the globe is translucent, but neither applies to this case. I'd appreciate any suggestions for another solution

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