Tile Exclusion is not excluding whole globe

Tile Exclusion does not appear to be excluding large chunks of the globe. Unity 2022.3.6 & URP, Cesium version 1.6.4. In this first image you see our default view of an area on the map, we’re using the CesiumTileExcluder as well as a modified version of the exclusion material(I’ve also tested with the CesiumTileExcluder defaults as well).

In the image below you can see there are other meshes present in the scene.
ss2

Selecting one of theses meshes reveals it’s located extremely far away from the current clipped area of the map (original area is circled).

Removing the clipping material, reveals large chunks of the terrain have not been excluded.

We suspect this is causing some of the performance issues we’re having in AR, given that we have Physics Meshes enabled on the terrain. Please let me know if there is something I could be missing or if more info is needed.

Thanks!

A few possibilities I can think of:

  1. The logic in the tile excluder is wrong, so it’s not excluding what it should. We’d have to see your excluder code to evaluate this possibility.
  2. The bounding volumes for those large tiles actually intersect with your volume, so they’re correctly not being excluded.
  3. The bounding volumes in this tileset are wrong (or just unnecessarily large), so they overlap more than you’d expect. Do you have the same problem with other tilesets?
  4. You’re using “forbid holes” mode, in which case siblings of unexcluded tiles will be loaded even if they are themselves excluded. They shouldn’t be rendered, though.

Do any of those sound like possibilities? Of course it’s also possible that the excluder system simply has a bug. If you think that’s the case, can you help us reproduce it?

1 Like

Hey Kevin,

Thank you for the suggestions. I set up a cesium project from scratch and used the box excluder script suggested here(Add ability to exclude tiles by implementing a C# class. by kring · Pull Request #248 · CesiumGS/cesium-unity · GitHub) along with a small box collider, to rule out #1.

I’m able to reproduce the tiles not being fully excluded on both the Google Photorealistic Tiles and the Cesium World Terrain using these tileset settings:

The issue is much more prevalent on the Google tiles(images in my first post), but still happens with a quarter of the globe on the Cesium World Terrain. Also it should be noted that turning on both Frustum Culling and Fog Culling will “resolve” the issue, but I would assume basic tile exclusion should work without those being turned on.

Let me know if there’s any other information I can provide to help you reproduce.

Thanks!

Can you walk me through the steps in detail? I can’t reproduce this. Here’s what I did:

  1. Create a new, empty scene.
  2. Use the Cesium panel to add Google Photorealistic 3D Tiles.
  3. Set the options on the tileset as you have in your screenshot.
  4. Add the box excluder script from the PR you linked above to my project.
  5. Drag the script onto the Google Photorealistic 3D Tiles game object.
  6. Set the editor camera parameters as follows and zoom way out:
    image

With the “Cesium Box Excluder” disabled, I see this:

With it enabled, I see this:

Which looks correct to me.

Hey Kevin,

Did you happen play the scene? apart from that my setup is the exact same as yours, but the clipping issue only happens in play mode.

Here is a gif of me reproducing the issue from scene creation:
screenrecording

The Project was created using the 3D(URP) blank template on Unity 2022.3.6, added the cesium registry and installed Cesium for Unity 1.6.4. Everything is default except for the scene camera, which matches exactly what you sent.

Let me know if there’s anything else I can provide, also just wanted to say I really appreciate you taking the time to look into this.

Ah ok, in play mode, I do see problems if I use a Dynamic Camera with the CesiumOriginShift component enabled. That’s expected, though, because the example CesiumBoxExcluder doesn’t account for the origin shifting, so the excluder effectively moves with the camera. This is mentioned in the issue, and Janine suggested a solution:

Hey Kevin I’m just using the default scene camera, no dynamic camera or origin shifting. Also this happens from scene start and doesn’t change regardless for camera or georef location.

I did implement the suggested solution of updating the _boxCollider.center in Update() with the following:

  var ecef = _geoRef.TransformEarthCenteredEarthFixedPositionToUnity(new double3(_geoRef.ecefX, _geoRef.ecefY, _geoRef.ecefZ));
  _boxCollider.center = new Vector3((float)ecef.x,(float)ecef.y,(float)ecef.z);
  this._bounds.center = this._boxCollider.center;
  this._bounds.size = this._boxCollider.size;

Is this in line with the intended solution? It doesn’t seem to make any difference in my case unfortunately.

I don’t think I’m successfully reproducing it, then. Any chance you can start with the Cesium for Unity Samples project, modify it to clearly demonstrate, the problem, and send it to me?

Hey Kevin, the issue wasn’t immediately reproducible in the sample project. I had to decrease the georeference scale to .01 to see it happen.

I’ve uploaded the zipped project here:

Open Scene 07_CesiumGoogleMapsTiles, play, and check out the scene view. Let me know if you need any more information from me, hope this helps!

Well I downloaded your project and opened it in Unity 2022.3.6f1 (because that’s the version the project was set to use). Then I open 07_CesiumGoogleMapsTiles, hit Play, and… I can’t move. The default view looks fine I guess:

If I enable the “Cesium Camera Controller” on the “Dynamic Camera”, then I can rotate around, but still can’t move. There’s a message in the log:

Step Offset must be less or equal to <scaled Height> + <scaled Radius> * 2
UnityEngine.GameObject:AddComponent<UnityEngine.CharacterController> ()
CesiumForUnity.CesiumCameraController:InitializeController () (at ./Library/PackageCache/com.cesium.unity@1.6.4/Runtime/CesiumCameraController.cs:256)
CesiumForUnity.CesiumCameraController:Awake () (at ./Library/PackageCache/com.cesium.unity@1.6.4/Runtime/CesiumCameraController.cs:311)

Other levels in this project work fine, so I’m not sure what’s going on with this one. What am I missing?

Hey Kevin, you’re not meant to move around. Just switch to the scene view to see that entire parts of the globe and their colliders are still loading in well outside the bounds of the box excluder.

Oh, I see, thanks Matt. Ok, so I can see the extra tile you’re talking about. I spent a lot of time digging into it, and wrote some bounding volume debug visualizations (I might try to get this into the product proper). My conclusion is that it’s working as expected, even though that may be surprising. Take a look at this screenshot from your level, with the added bounding volume visualization:

The large tile is the unexpected one that appears to be well outside the the CesiumBoxExcluder. The excluder itself is centered near the red/green/blue coordinate axes on the left side of the image, and is too small to see. So why are we rendering this tile that appears to be nowhere near the excluder? Shouldn’t it be excluded? Unfortunately, no, it should not. Let me explain.

The red wireframe box in the screenshot is the oriented bounding box that is actually expressed in the tileset.json for this particular tile. It’s a bit bigger than it needs to be, but it actually looks worse in this screenshot than it really is (a trick of perspective). The Google tileset has a reasonable - if not ideal - bounding volume for this tile.

The CesiumTileExcluder, however, doesn’t work with oriented bounding boxes. It uses a bounding box aligned with the Unity world axes. That aligned bounding box is shown with the green wireframe. It’s quite a bit bigger than the red one, but necessarily so. It’s the tightest-fitting axis-aligned bounding box that fully contains this tile’s oriented bounding box.

The CesiumBoxExcluder tests this axis-aligned box against the exclusion volume, and correctly determines (as we can see in the screenshot) that the excluder volume and the AABB overlap. So that is why this tile is not excluded. And, having not been excluded, it’s also rendered because you’ve turned off frustum culling.

You can actually improve the situation by turning on “Enforce Culled Screen Space Error”. With that option OFF, tiles outside the view frustum are not refined at all. So we tend to select very large, low detail tiles like the one in the screenshot. These large tiles have large bounding volumes (especially once they’re axis-aligned), so the CesiumTileExcluder tends to deem them not excluded.

With the option ON, however, these large tiles will be refined, so their smaller, higher-detail children will be selected instead. These child tiles have much smaller bounding volumes, and so they can be more readily excluded by the CesiumTileExcluder. The downside is that more tiles will need to be downloaded.

1 Like

I’ve committed the bounding box visualization code to this branch:

Enable “Show Tiles in Hierarchy” on the tileset. Then select a tile in the Outliner and add the “CesiumDebugTileBoundingVolume” component to it.

1 Like