Hi, is there away to cut out or hide parts of the terrain in Unity. like using the Cartographic Polygons in Unreal.
Thanks
1 Like
We plan to add it eventually, but don’t have a definite timeline for it currently. In the meantime you can create a custom material that masks out part of a model. The main downside is that tiles entirely within the masked-out area will still be loaded.
1 Like
Hi, could you elaborate a bit more on how to make this mask material that works for the cesium world terrain?
I describe how to create such a material in the second post in this PR:
CesiumGS:main
← CesiumGS:tile-excluder
opened 06:03AM - 16 Mar 23 UTC
Depends on CesiumGS/cesium-native#608
Added `CesiumTileExcluder`, which is a … C# version of cesium-native's `ITileExcluder`.
The idea is that we can add a C# class like this to our project:
```csharp
using CesiumForUnity;
using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class CesiumBoxExcluder : CesiumTileExcluder
{
private Bounds _bounds;
protected override void OnEnable()
{
base.OnEnable();
BoxCollider box = GetComponent<BoxCollider>();
this._bounds = new Bounds(box.center, box.size);
}
public override bool ShouldExclude(Cesium3DTile tile)
{
return !this._bounds.Intersects(tile.bounds);
}
}
```
And then add an instance of this class as a component on the `Cesium3DTileset` or any of its parents, up to and including the `CesiumGeoreference`.
With that in place, cesium-native will call the `ShouldExclude` method for each tile that it is considering loading or rendering. This will happen a _lot_, so this method needs to be fast. Return true to skip loading and rendering that tile. Return false to load it and render it as normal.
In the implementation above, a user-defined BoxCollider is also attached to the same GameObject as the CesiumBoxExcluder. Any tiles that intersect this BoxCollider are loaded and rendered, others are not. So tiles that are entirely outside of the box are ignored. The given tile's `bounds` property is an axis-aligned bounding box in the same coordinate system as the `CesiumBoxExcluder`, so it's easy to do tests like this.
In this screenshot, the BoxCollider is the green box in the middle of Melbourne. All of the visible tiles are at least partially inside the box:
![image](https://user-images.githubusercontent.com/924374/225528568-647a9bb8-58c1-4635-b0dc-c24713b7ff95.png)
If we disable the CesiumBoxExcluder, all the tiles load as normal:
![image](https://user-images.githubusercontent.com/924374/225528858-5986386f-7413-434f-8050-37d5ff1bc61c.png)
Also in this PR: Extended Reinterop to allow constructors of blittable value types to be called from C++. On the C++ side, these are exposed as `Constrct` methods rather than C++ constructors so that brace initialization can continue to be used to initialize fields without calling into C#.
The PR itself actually adds the ability to exclude tiles completely, so that may be useful to you as well. Hopefully it will be included in our early April release.
1 Like
I second this request.
Thank you for your hard work!
Hi Cesium team.
Do you have any updates on Cartographic Polygons for Unity? . Thanks
We still have an open issue tracking this need,
opened 07:07AM - 29 Aug 23 UTC
enhancement
Add UE “Cesium Cartographic Polygon” to unity
1 Like