3D terrain in Unity

Mapbox
maps for developers
2 min readFeb 8, 2017

--

By Baran Kahyaoglu

The Mapbox Unity SDK has full support for global digital elevation data in Unity. Our SDK ships with elevation encoded raster tiles from our global tiled digital elevation model that, together with mesh generation factories, can be used to generate hillshades and elevation contour lines for any location in the world.

The SDK includes many geospatial convenience functions to help translate between the real world and Unity space. One of these functions helps to decode the elevation tiles from RGB pixel values to height in meters.

Once decoded, you can generate a 3D mesh model that can be used as a canvas for different types of visual experiences. Here’s an example of where I used contour lines of the Mapbox terrain layer to create a Tron-like atmosphere:

The contour lines are fully customizable in Unity, so you can change them to have any look and feel you want.

Here, I used Mapbox Satellite as a texture overlaid on top of our elevation mesh model. Then, on top, I extruded road networks and buildings from our Mapbox Streets layer to create a realistic 3D flyover of San Francisco Bay, Golden Gate Park, the Grand Canyon, and Monument Valley. This is what you would see if you were flying at a height of 500 feet over these areas:

There are so many possibilities of what you could build with our new tools for 3D terrain. Peter posted yesterday about how we’re pushing the boundaries of 3D with WebGL and Three.js, and we’re excited to push forward with similar work for Unity developers.

Need inspiration to start building something of your own? Explore the world in 3D, and hit us up on Twitter to show us what you’ve made!

--

--

mapping tools for developers + precise location data to change the way we explore the world