CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.43k stars 3.39k forks source link

Depth plane causing clipping artifact #7879

Open OmarShehata opened 5 years ago

OmarShehata commented 5 years ago

I've run into this with various 3D Tilesets, but this is a good minimal example produced by Adam Twite in this forum thread:

Sandcastle. Just try tilting the camera up a bit.

depth_plane_czm_man

Here, the 3D model is actually underneath terrain, but depth testing is turned off, so it should show through. It clips because the depth plane (which is used to write depth on the ellipsoid when the globe tiles don't, so that things on the opposite side of the globe don't show through). You can verify this by commenting out the depthPlane.execute line here in Scene.js:

https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Scene.js#L2307

lilleyse commented 5 years ago

A simple short-term fix would be to move the depth plane execution after the 3D Tiles pass. The drawback to this is 3D Tiles may show through the globe when depthTestAgainstTerrain=false, but this would only happen for tilesets with a huge geometric error. It wouldn't fix that Sandcastle either. It's probably a worthwhile tradeoff to make.

The better fix is to compute the depth plane differently. I don't know what that would look like yet.

lilleyse commented 5 years ago

https://github.com/AnalyticalGraphicsInc/cesium/issues/7859 looks like the same issue

pjcozzi commented 5 years ago

That short-term fix sounds reasonable enough.

The other option is to replace the depth plane with a depth cone - so instead of having a plane, use a cone with the vertex on the other side of the globe so it is like an ice cream cone with the ice cream being the front half of the globe facing the user and the cone inscribed in the back half of globe.

If this can be done fast, maybe just do this right away instead of the short-term fix.

lilleyse commented 4 years ago

https://github.com/AnalyticalGraphicsInc/cesium/pull/8398 had a workaround that pushed the depth plane ellipsoid inward based on the the Mariana Trench's depth. A better approach will involving finding the min/max heights based on the loaded terrain tiles / 3D Tiles kind of like https://github.com/AnalyticalGraphicsInc/cesium/pull/8398. Or try out the depth cone.

TJPovey commented 3 years ago

Hi, is this being actively worked on? Is there any reason #9200 hasn't been merged? This is causing us quite a few issues for clients with assets located in the middle east region. Thanks, Tom

grantis commented 3 years ago

Hi, also curious if this clipping issue being worked on. I'v posted a similar issue on the Cesium forum https://community.cesium.com/t/czml-data-source-gtlf-model-disappears-a-certain-camera-angles/11214/5

mDeligalabov commented 10 months ago

Hi, is there a fix for this bug? I have checked all around the net on this but still nothing that works.

lilleyse commented 10 months ago

@mDeligalabov You should be able to use the depthPlaneEllipsoidOffset option added in https://github.com/CesiumGS/cesium/pull/9200

mDeligalabov commented 10 months ago

Thank you @lilleyse this information leaded me to more information. One thing that I still find strange is that with camera movements the ellipsoid value is also moving up and down. Shouldn't this be considered as a bug since the for example the Cartographic instance height is relying on this?

ggetz commented 7 months ago

Also reported in https://github.com/CesiumGS/cesium/issues/11658.

zachsussman commented 7 months ago

depthPlaneEllipsoidOffset doesn't appear to work correctly with clustering. With clustering on, the clipping still happens, while with clustering off, depthPlaneEllipsoidOffset fixes the issue.