Sponsored By

A tutorial on in-game mountain creation using the data from NASA satellite images, a system we're using for the Afghanistan '11 game.

Megan Hughes, Blogger

December 14, 2015

9 Min Read

RetroEpic Software and Every.Single.Soldier have teamed up to develop the sequel to Vietnam '65: Afghanistan '11. This blog post tutorial was originally posted on the RetroEpic Blog, written by Neal Liddle, and reposted here with permission.

An important aspect of the Afghanistan '11 game, particularly in how it differs from Vietnam '65, is the terrain. The Afghanistan landscape is not only desert, but also mountainous. We needed to figure out the best way to implement the varied terrain and considered creating our own mountains from scratch (modelling/sculpting) or using existing software that creates the mountainous terrains for us. In the end, we realised the best process would be to pull the data captured on relief maps by NASA and use this to generate the mountains in the game. This turned out to be a quick and easy process and gave us the option of having terrain that was an exact match of the environments we were recreating. I've written this post to show the process of retrieving the data, making it usable, using it in a 3D package to create the asset and optimise it and, then, pushing it into Unity. I won’t be covering the shader/texturing of the terrain in this post though I hope to cover it in future. What you need:

  • 3D package: Blender

  • Conversion software: MicroDEM and Awesome Bump(or CrazyBump)

  • Game package: Unity3D

This was written for use on a PC. Mountain Tutorial | Afghanistan '11 | RetroEpic  

Retrieving the data: After looking through a couple of sites, I realised that they all pull the same data. This meant that I could choose the website that was the most user friendly for my purposes:http://gdex.cr.usgs.gov/gdex/. The data on this site seems to be originally from NASA. It’s not extremely high, but it’s the highest I could find and did the job since we are converting it to a lower resolution version for gaming. You have to be signed in to be able to download files.

  • Find the area where you want to download from on the map.

  • Use the polygon tool to define the area you want to download. The bigger the area you select, the lower resolution the final maps will be, so try be specific to which area you want.

  • Once you are happy with the selection, click the download button.

  • In the download menu, select a research area otherwise it won’t download. Then press submit.

  • It will give you a data preview and if you are happy with it (no white artefacts) press download.

You will now have a *.tiff file containing the information for your maps. Converting the data: Now that you have your tiff file, you will notice that the file is just a black image. That is because it’s not so much an image, but rather information. In order the to get the individual images we want from the tiff, you need ‘Microdem’. It will give some errors when it starts up, but you can just ignore those. The main images we want is the slope data and the height map. Mountain Tutorial | Afghanistan '11 | RetroEpic  

  • File - Open - Open DEM - (Select the *.tiff file)

  • You should now have a multicoloured image of the mountain displaying. Right click - Display parameter

    • Elevation

      • Gray Scale

    • Slope

      • Gray Scale

      • Pixel size: 1

  • For each image right click - save image (make sure to make it .png rather than .bmp)

Those are now your height map and slope mask. Converting additional data: Mountain Tutorial | Afghanistan '11 | RetroEpic I wanted some additional data, so for that ‘AwesomeBump’ came in quite handy. It’s an open source conversion software, similar to ‘CrazyBump’. From the height map we created earlier we can create the Ambient Occlusion map and the Normal map.

  • Open AwesomeBump

  • In the Height tab - open image(CTRL + O)

  • In the Normal tab - Input image - Height(Input)

  • In the Output tab

    • - Save settings - Untick the diffuse pass.

    • Click on the first save icon next to the passes. Place those in the same folder as the already exported textures.

Now you have all your textures, but they are not optimized to be using the the texture space properly. In Photoshop, load all your textures into one image with different layers. Select all the layers and rotate the image so that it uses as little space as possible. You can crop it in areas where the texture of the mountain is blank. Once you are finished, export the images at 1024x1024.

  • If the image is not square, use the existing images largest size (width or height), then adjust the canvas to make it square, without stretching the image.

That’s it for saving out the textures. Now on to the actual model of the mountain. 3D model creation: The 3D package we currently use in studio is Blender. We start by creating our mountain as a model in our scene.

  • Create a plane

  • Add subdiv modifier with 6 subdivs. Set it to simple. Apply modifier.

  • Add a subsurf modifier and set it to Simple. Set your subdivisions to something like 2(for render and view since it exports using the render settings).

  • Add a displacement modifier.

    • For the displacement we use the height map.

    • Texture coordinates: Global

    • Midlevel: 0

  • Add Smooth shading.

Mountain Tutorial | Afghanistan '11 | RetroEpic Setting up the weight map for the displacement map:

  • Delete the faces that are not using the height map. Now you should have a more organic shaped plane as opposed to the square plane.

  • Go into weight paint mode (maybe push down the subdiv so it’s not too slow). Paint the area where you want the mountain, and leave the area where you want it to be completely flat blue.

  • Go into edit mode - Press SpaceBar - type in “Select Non Manifold”. This will select all the verts on the outside. Press CTRL + I to select the inverse.

  • Go back into weight paint mode. At the bottom select the “Vertex selection masking”.

  • Tools panel - Weight Tools - Smooth.

  • Under the displacement modifier - vertex groups. Plug the current vertex group in there. Now your mountain should taper off at the edges and be completely flat at the edges.

Mountain Tutorial | Afghanistan '11 | RetroEpic Optimising the mesh:

Mountain Tutorial | Afghanistan '11 | RetroEpic Mountain Tutorial | Afghanistan '11 | RetroEpicMountain Tutorial | Afghanistan '11 | RetroEpicMountain Tutorial | Afghanistan '11 | RetroEpic

Top Left: High resolution mountain with deleted faces Top Right: First decimate modifier added Bottom Left: Smooth modifier added to get rid of jagged faces. Bottom Right: Extra decimate modifier added to bring down face count.

  • Add a Decimate modifier to the mesh. Use a value of 0.1.

  • Add a smooth modifier. This will get rid of the sharp edges that cause strange shadows in Unity.

  • Add another Decimate modifier. This time set the value to 0.2.

  • Add an empty and move it one unit above the mountain mesh.

  • Go into edit mode - Press SpaceBar - type in “Select Non Manifold”. This will select all the verts on the outside. Create a new group called “normalsFix” with full weight on those verts.

  • Add a Normal Edit modifier to the mesh.

    • Set to directional.

    • Under Directional, set the empty as the object to use for direction.

    • Plug the “normalsFix” group into the vertex group slot.

    • Tick Parallel Normals on.

  • Go to the Data tab(tab on the right of the modifier tab)

    • Tick Auto Smooth.

This is your final mountain that will be exported. Try play with the decimate values to get something that is still sharp, but not jagged. Before exporting, make a duplicate and apply all the modifiers except for the Set Split Normals modifier. Do a final check on the mesh to see that there are no strange faces overlapping verts. Select the Non Manifold verts again, press Shift-C and make your pivot point the 3D cursor (press fullstop on keyboard) and then scale the verts to zero in the Z axis. Make sure you have no transforms on the object and export the mountain to Unity. Mountain Tutorial | Afghanistan '11 | RetroEpic Left: Mountain with edges who’s normals have not been changed by the “Normal Edit” modifier. Right: Normals have been fixed to match the ground normals therefore creating a seamless transition. This way you get rid of the seem and don’t see where the model of the mountain stops and the ground starts.

Read more about:


About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like