I am looking to add a material to the terrain that will show a grid for latitude and longitude and I’m looking for a good starting point. Is there anything built in to show a grid or how could I generate it via a material?
Here’s an example from CesiumJS that draws arcs.
Doesn’t use materials (or Unreal) though, unfortunately…
Hi @RoeDan,
We don’t have anything built-in to do that. One is to create a custom material, as you mentioned. This tutorial explains how that’s done:
There’s an example of drawing contour lines in level 9 of the Cesium for Unreal Samples project that could be useful as a starting point.
Another possibility is to use the raster overlay system. For example, if you had a GeoJSON containing the grid lines you want to draw, you could load that up into Geoserver and serve it as a WMS. Then, add the CesiumWebMapServiceRasterOverlay component to your tileset to overlay the rendered map tiles on the globe.
@DigitalDrool Helped me find a solution.
To achieve the latitude and longitude lines on the Cesium globe in Unreal Engine, we followed a structured process:
Dividing the Globe: At its lowest level of detail, the Cesium globe is split into four pieces. As the level of detail increases, more tiles appear, allowing us to use these LOD tiles to create the latitude and longitude lines.
Creating the Grid:
Texture Coordinates: We used texture coordinates to map positions on the globe’s surface. This mapping determines where the lines should appear.
Red and Green Channels: We separated the red and green channels from the texture coordinates. The red channel corresponds to the horizontal (latitude) positions, and the green channel corresponds to the vertical (longitude) positions.
Sharpening the Lines:
Horizontal Lines (Equator): For the red channel, we applied a power node and cheap contrast. This sharpened the gradient into a distinct horizontal line, representing a specific latitude line. We could also adjust the thickness of this line.
Vertical Lines (Prime Meridian): Similarly, we processed the green channel to create sharp vertical lines for longitude. We used a power node and cheap contrast to define the line and control its thickness.
Level of Detail (LOD): As the level of detail (LOD) increases, the grid becomes denser. This means that more latitude and longitude lines are added as you zoom in or as the map’s detail level increases. The process automatically scales to provide more detailed lines, making the grid finer and more accurate at higher LODs.
This method effectively outlines the latitude and longitude lines on the Cesium globe, dynamically adapting to the level of detail to provide a clear and accurate representation.