Monday, September 3, 2012

Making height maps with Unity3D

Hi everyone! Today, a tutorial! :)

For our course of Graphics Programming, we needed to make a custom terrain. This is done with a gray scale file, where black is the lowest point, and white the highest. Normally, we just had to do this in Photoshop, but for our retake exam, Sven came up with a good idea. Why not make it in Unity, and then export it? First, I was afraid that Unity had its own format or that it would not have an export option, but it worked! A quick overview:

In a new Unity project, click Terrain -> Create Terrain


Select the terrain, then click Terrain -> Set Resolution. Type in the desired width, height and length.


Now let's start "modeling" the terrain. Use the first 3 buttons: with the first one, you can raise/lower the terrain. (Hold shift to lower the terrain) I don't use the second one a lot, but it can be handy to create plateaus, since you can specify the desired height. With the third one, you can smooth out the terrain. Use the brushes, play around with their size and opacity a bit.



Just continue until you're pleased with the result! :)



Now, with the terrain selected, click Terrain -> Export Heightmap - Raw... And then select the right settings. So if you're on Windows, select Windows, and select the Bit Depth as needed.

Now open the RAW file in Photoshop with the right settings, and there you can resize it. Save again with the right settings.

For the textures:

Keep some tileable textures at hand, and import them in Unity, or use some textures that are included in Unity. (Import them by clicking Assets -> Import Package -> Terrain Assets)


Click "Edit Textures -> Add texture", then choose the texture and be sure to select a nice Tile Size X & Y.



Paint! Again, play with brushes, sizes, opacity and target strength until you're pleased with the result.



To export it: there is no way to export the texture as a whole, because Unity uses a blendmap, but this is a nice trick: go into orthographic top view, zoom in as much as you can, do a print screen and tweak it in Photoshop.


Another terrain made with the same method in the Graphics Programming Engine of DAE:


Good luck to use it in your applications!

Greetz,
x Marcia

No comments:

Post a Comment