How to create square terrain tiles all over earth?

Hello, was wondering if there is an easy way to place square tiles on terrain all over earth at the size of ~ 10m x 10m .

ive seen this Cesium Sandcastle
but i need for square tiles all over earth transparent.!

Example:
3d tiles2|690x430

Hi @maxtorgr, welcome to the community.

The Sandcastle example you provided is using vector data, which are not currently supported in Cesium for Unreal. However, if it’s just the visual effect of the grid that you need, you can create that with materials.

I created an example just so I could see how it’s done. You don’t have to follow this procedure, but I figured I’d post it in case it helps anyone else out too.

I drew the procedural grid function from here - https://www.techarthub.com/making-a-procedural-grid-material-in-unreal-engine-4/

You can start by duplicating one of the existing Cesium materials found in the CesiumForUnreal Content/Materials/Instances folder. I picked MI_CesiumThreeOverlaysAndClippingAndWater. You’ll also need a Material Layer (CesiumForUnreal Content/Materials/Blends) and a Material Blend(CesiumForUnrealContent/Materials/Blends). Duplicate all of these, rename them something and move them to your project folder.

Open up your new Material Instance. Replace the Layer Asset and Blend Asset of Overlay2 with your new Material Layer and Material Blend.

Right-click in the Content Browser and create a new Material Function. Name this something like MF_GridLines. This function will generate a procedural grid in world space, which is necessary since regular UV operations won’t work properly with 3D tilesets.
This material function is a simplified version of the one from the above tutorial. Check it out if you want a more in-depth overview of these nodes.
We don’t need to project the grid onto the sides of the object, only the top, so that makes it easier.

Open your new Material Layer. If there’s a bunch of existing logic to create inputs for BaseColor or other attributes, you can remove that and replace it so it looks like this:


GridSize and GridLineWidth are Scalar Parameters, which means you’ll be able to edit them in the material instance for quicker shader updates. By default, set GridSize to 1000 and GridLineWidth to 10 for a 10m x 10m grid.
Also, make sure you’re plugging the result of MF_GridLines into both the Base Color and the Opacity Mask.

To make sure the material blends properly, open up your new Material Layer Blend. You’ll want to make it look like this:

The Input Bottom Layer is the tileset raster overlay with texture information for the terrain. You’ll blend the base color with the base color of the grid material, with the blend determined by the opacity mask of the base color.

Now, just double check to make sure the material instance is set up as shown in the first screenshot. Then, in the main Unreal Editor, click on Cesium World Terrain. In the details panel, you can set the Material and the Water Material for the tileset. Make sure they’re both set to your new material instance, and when the tileset reloads you should see the grid lines covering the terrain.


(The cube in this photo is 10x10 meters, for reference.)

The number you enter for GridSize should determine the size of each grid cell, in centimeters. A very small grid (even 10x10 meters) will look stranger when zoomed out, so you should make sure to adjust the grid size/line width for the desired visual effect.

Also, one thing to note is that this will not necessarily break the whole earth cleanly into squares. It’s projected on the Z axis, which is basically the “up-into-space” direction from your georeference origin. This means that if you move very far around the earth from the origin, it will no longer be grid shaped.

The easiest solution for this is to use sublevels to automatically change the origin to be near the camera at locations of interest. That will essentially re-set the grid, so the distortion hopefully won’t be noticeable. Or, there’s probably some sort of math that you could put in the material to make it properly map to the whole globe, but that’s definitely beyond my experience.

The grid also doesn’t have to just be white. You can play around with the material to adjust the style, color, transparency, and more.

If the material route works for your use case, let me know how it goes! And, if you have any questions or want more clarity on any step in this process, feel free to ask.

-Alex

1 Like