How to avoid terrain occluding 3D Tiles without breaking other depth testing?

Hi everyone,

I’m working on a scene where terrain data is often not very accurate, so I would like 3D Tiles to be treated as the primary visual surface.

My goal is:

  • 3D Tiles should NOT be occluded by terrain, even if they are below the terrain surface
  • pickPosition should prioritize 3D Tiles instead of terrain
  • At the same time, other primitives (points, polylines, polygons) should still maintain correct depth testing against both terrain and 3D Tiles

I have tried using viewer.scene.globe.depthTestAgainstTerrain = false, but this causes unwanted side effects:

  • Other primitives are no longer correctly occluded by terrain

So this global setting is not acceptable for my use case.

What I’m looking for is a more fine-grained control, for example:

  • Disable terrain occlusion ONLY for 3D Tiles

  • Keep normal depth testing between:

    • primitives ↔ terrain
    • primitives ↔ 3D Tiles

Is there a recommended approach to achieve this?

Any guidance or best practices would be greatly appreciated.

Thanks!

Hey @BlockCnFuture,

Just to confirm my understanding: you have a scene where the globe terrain elevation is inaccurate and your 3D Tiles represent the actual ground surface, so you want tiles to always win visually over terrain without globally disabling depth testing.

It would also be good to know what terrain data you are using? Cesium world terrain, WGS84 ellipsoid, Google Photorealistic Tiles? Your own data?

As far as I’m aware, CesiumJS does not currently support per-tileset depth test control against terrain. Similar issue here with 2 different solutions you could try or look into, I probably wouldn’t recommend my 2 viewer method for performance reasons, although you’re welcome to try to get it more performant).

  1. Height offset your tiles using tileset.modelMatrix to be above/in line with the terrain (if needed) and use a clipping poly to hide the terrain (clipping polygon tutorial)
  2. You could try using an alternate terrain data source.

Let me know how that goes! It could be useful to provide some screenshots as well if neither of the above help you out