Masking out Cesium map with polygon that is not anchored to the map/globe

I am working on AR application that will have 3D map displayed on virtual round table:

I was able to mask it out with CartographicPolygon but it has GlobeAnchor script that cannot be removed or disabled. So the mask moves with map when long/lat is changed. Is there a different method to mask the map?
I would like to add interactions with the map using hand tracking gestures or controller.

I couldn’t find any option in CartographicPolygon to generate fade out on the edges, I believe that kind of vignetting should be available by default.

UE5.3, Cesium v2.4

Hi @Moulderca, welcome to the community!

By design, CesiumCartographicPolygon is fixed to the globe. While you can reposition it at runtime, you’d have to refresh the CesiumPolygonRasterOverlay for the changes to take place, which would not provide the smooth experience that you’re describing.

However, you can try a different method that involves two steps:

1. Implement a CesiumTileExcluder

CesiumTIleExcluder is an interface that allows you to prevent tiles from loading depending on your own specified logic. For example, you can exclude tiles whose bounds fall completely outside of a box positioned at an Unreal world position (as opposed to a long / lat). And this box can move around the world at runtime.

We unfortunately do not have documentation at this time, but our Cesium for Unreal Samples project contains an example excluder that implements the behavior I described above.

However, the exclusion alone does not perfectly clip tiles. Because it works with the bounds of tiles, it can load tiles that are both in and outside of the box, in ways where your excluder will give you this:

So to get that perfect crisp clipping, the next step is…

2. Modifying the material

You’ll have to create a copy of the default tileset material instance (MI_CesiumThreeOverlaysAndClipping). Then, create a new material layer. You’ll use this new material layer to replace the existing “raster overlay” one.

The clipping behavior works by looking for a red value in the material layer. If it’s red, then that area should be clipped (hidden). Otherwise, the original pixels will be left visible.

So, to create a circular clipped area in your custom material layer, you’ll want to output a red value if the distance from the circle’s center is greater than your desired radius. This should result in similar clipping to what you already did with CesiumCartographicPolygon.

This should be enough to get you started, but let us know if you have any followup questions. :slight_smile: