Regional Customization Part 2: Grayscale Heightmapping

simcitycentral

MY REGION IS TOO FLAT!

Now that you have a nice big region with the cities laid out just right, you’re going to want some interesting terrain on it. Perfectly flat plains may make for easy building, but as you’ve probably noticed, there are no cities built on perfectly flat plains, and they can turn out to be extraordinarily boring. Now, using an option implemented in SimCity since SimCity 3000, you can import a grayscale bitmap image into the game, and the game will turn your image into a dazzling terrain.

WHAT’S A GRAYSCALE HEIGHTMAP?

Many image editors have the capability to make Grayscale bitmaps; that is, a file format that stores the image as a 256 color image, with each color being a different shade of gray. When such an image is drawn to the correct format, the game can generate a region from it; each pixel in the heightmap corresponds to a tile in the region, as if the heightmap had been laid over the flat terrain. Then the game reads the brightness of each pixel in the grayscale and assigns a corresponding height to the tile that pixel represents. It works like this:

The grayscale bitmap is imported into the game. This is done using a special cheat dialogue in the region mode. More on that is found later in this article.

The game reads the image pixel by pixel. For each pixel in the grayscale, the game takes the shade of gray (from 0 to 256) and assigns the corresponding tile in the region to a preset height for that particular shade.

Upon finishing a set of tiles, the terrain in that location is smoothed, creating slopes and gradients instead of 90° cliffs between tiles. This smoothing can have unwanted effects on the terrain in question, but without it the resulting terrain would be totally unusable.

When the game completes a cityfull of tiles, it saves the city in the region’s folder. Once it finishes all the cities, it presents you with your new region terrain!

CAUTION! At this point, the game will overwrite any existing City (.SC4) files in the region. Follow these instructions on a blank region ONLY. A region with a custom Config.bmp is fine, as long as none of the cities in the region have been saved. To ensure you won’t be destroying any cities in the region you want to terraform, check the region’s folder in
My DocumentsSimCity 4Regions[Region Name]. There should be one file there (two if you’ve created a custom city layout with a Config.bmp file). If there are any .sc4 files in that folder, go back into the game and check the region for cities you may have saved in it. If you want to keep any of them, make a new region to terraform. If not, delete them to avoid errors.

HOW IS A HEIGHTMAP FORMATTED?

There are two rules to follow when importing a Greyscale Heightmap:

The Heightmap must be the correct size. To determine how large the Heightmap needs to be, use the following equation:

(Region widthheight in Kilmeters (small maps) X 64) + 1 = Heightmap width/height.

Therefore, a region consisting of one small map (1 kilometer square) would require a Heightmap 65×65 pixels, and a region 4 large maps (16 kilometers) across and 5 medium maps (10 kilometers) tall would need a Heightmap 1025×641 pixels.

The color format must be correct. The game can only generate a region terrain from an 8-bit Grayscale Bitmap. It can also read several other formats (.jpeg, .gif, .tiff) assuming they contain only shades of gray. This tutorial will explain how to generate a terrain form the 8-bit grayscale bitmap, so if you download a terrain Heightmap off the internet it is probably a good idea to convert it to the required format, to avoid any conflicts.

Virtually all problems with Heightmaps are caused because one or both these rules were not followed correctly. If the Heightmap is the wrong size, an error message will appear telling you the correct size when you attempt to import it. Write this down, so you can adjust your image properly. If you attempt to load the Heightmap and nothing happens at all, check the file and color formats and ensure they are correct. Note that while it is possible to import a heightmap into a region with empty city tiles (on the edge or in the middle), it will more then likely result in a broken-up and distorted terrain. To ensure this doesn’t happen, edit your Config.bmp file to fill in any gaps in the region.

GETTING OTHER PLAYERS’ HEIGHTMAPS

Terrain Heightmaps are available for download, preformatted and ready to import, at many SimCity fansites. A good amount of Heightmaps can be downloaded at Rebel 13’s SimCity Site and Simtropolis.

USING TERRAGEN TO CREATE A RANDOM REGION

It is also possible to create a region using a program called Terragen. To create a realistic landscape using Terragen, you will need two programs. First, you’ll need to download and install Terragen from the free download site. Second, you will need an image editor capable of importing and converting .RAW data. Adobe PhotoShop and JASC Paint Shop Pro work nicely.

To make a landscape using Terragen:

Open Terragen. Two windows will open: Rendering Control (in the background) and Landscape, in the foreground. Close Rendering Control, since you won’t be needing it.

In the landscape window, there are 6 buttons you’ll need to know how to use:

Sculpting mode with 128 x 128 brush: Right-click, hold and drag to lower terrain a lot, left-click, hold and drag to raise terrain a lot.

Sculpting mode with 64 x 64 brush: Right-click, hold and drag to lower terrain some, left-click, hold and drag to raise terrain some.

Sculpting mode with 32 x 32 brush: Right-click, hold and drag to lower terrain a little, left-click, hold and drag to raise terrain a little.

Export: Click here to save a terrain as a .RAW image.

Generate Terrain: Click here to create a random terrain based on the settings you choose.

Landscape Dialogue: Click here to adjust the landscape settings.

On the left side of the workspace, there is a vertical toolbar with 7 buttons on it. Click the third button down (Water).

The Water dialogue box will come up:

In the top right corner an input box labeled “Water Level” will be highlighted. Set this to 50.0m. Select “Update Maps” and close the window. On the Landscape window, the “Plan View of Landscape” should now be blue.

Select Button 6, labeled “4000 metres.” The Landscape window will open. Here you can change the size and scale of your terrain. In the top-right corner of the window, there are six buttons; 129, 257, 513, and three grayed-out buttons. Click on “513,” select “Yes” on the next window, and “No” on the one after that. Above “Meters Point Spacing” make this number 16. Hit “OK” to close the window. Now button 6 should be labeled “8192 metres.”

Now you begin making a terrain. Click Button 1 on the image above. This tool allows you to raise and lower terrain over a very large area. Right-click to lower the terrain, and left-click to raise the terrain. The other two tools (2 and 3) in that space work the same way, only on a smaller scale. Take a few minutes to get the hang of raising and lowering parts of the terrain.

While it’s certainly easy to make a terrain using the sculpting tools, if you want something more realistic you’ll want to generate a random terrain. Click on “Generate Terrain” (button 5). The Terrain Genesis window will open:

Here you can adjust the settings for the Terrain Generator. To make your terrain, you’ll want to set the Realism and Smoothing sliders to maximum (100) and the Glaciation and Canyonism sliders close to the minimum. Adjusting these sliders will give you a rougher or smoother terrain; keep adjusting these settings until you get a terrain that you like. Leave the “Size of Features” slider where it is, unless you plan to make a very large region (8 or more Large Maps on a side). If that’s the case, turn it down one notch. Click “Generate Terrain.” The Landscape Window will now look something like this:

If you don’t like the look of the landscape you’ve created, adjust the four top sliders in the Terrain Genesis window and keep clicking “Generate Terrain” until you get one you like.

Using the Height Adjustment tools (buttons 1-3), adjust the image to raise and lower the terrain wherever you want. Be careful sculpting the terrain this way, however, since it is very easy to accidentally raise or lower it more than you wanted to.

When the terrain looks how you want it, Click on “Export” (button 4). Leave the Save settings where they are and click “Select File and Save.” Save your terrain as a .RAW file somewhere you can find it again (the new region’s folder is a good place). Close Terragen.

At this point you will have to convert your region Heightmap into a format the game can read before it can be imported. Start PhotoShop (or whatever image editor you use) and open the .RAW file you created (leave the color settings where they are). Select the entire canvas and copy it to the clipboard. Close the .RAW file, and create a new image. Make sure the image is the same size as the .RAW image you made (513×513 pixels, 72 pixels/inch). Set the color setting to Grayscale. In the new image, color the entire background solid black. Then paste the .RAW image you copied into a new layer. You shouldn’t be able to see any of the black background behind it; if you can see the background around the edges, check the size of the image to ensure it’s correct. Go into the new layer’s Blending Options (in PhotoShop), and find the Blend If box. Move the left tab on the top slider to a value of 85 as shown in the image below:

Your Terragen Heightmap will now look something like this:

On the above image, the solid black areas indicate where the water will be. If your terrain’s water isn’t where you expected it to be (and it probably won’t) you’ll have to adjust the terrain. Open the Brightness/Contrast window, and change the brightness and contrast settings until the water level is close to where it should be. Changing the contrast will make mountains and valleys steeper, and changing the brightness will raise and lower the terrain. Keep adjusting both these settings until the coastlines are correct and the terrain “looks right.” Don’t turn the contrast up too high, as this will result in flat plateaus instead of mountain peaks, and don’t turn the brightness down too low, as this will flood the landscape. When the image is adjusted just the way you want it, close the Brightness/Contrast adjustment window.

Go back into the top (terrain) layer’s Blending Options window, and move the slider you adjusted earlier (the one now set to 85) all the way back down to the Black end of the bar. Close the window, and the background should no longer be visible. Save the image you’ve created, layers and all, so that if the image doesn’t turn out the way you wanted, you can go back and change it. Once the file is saved, flatten the image. If you want the Heightmap to be a different size then the default 513×513 pixels, stretch the image to match your Config.bmp image. Save the resulting Heightmap as an 8-bit Bitmap Image, preferably in the folder your Region is in. You now have a Grayscale Heightmap, ready to import. (If you don’t want to change the image size, create an 8 pixel by 8 pixel Config.bmp to go in the folder of the Region you want to terraform.) The above Terragen image yielded this Heightmap:

DRAWING A REGION FROM SCRATCH

While there are as many ways to draw Grayscale Heightmaps as there are programs in which to make them, only a few good image editors will give you a very good, realistic terrain. For demonstration purposes, this article will show how to draw one using Adobe PhotoShop. Many of the features shown here are also available in other advanced image editors, so don’t feel like you have to have PhotoShop to make good Heightmaps. Just explore your own software, to find out how to perform these techniques. Also, while it is possible to make a Grayscale Heightmap using Windows Paint, it is extremely time-consuming and tedious (you have to set every shade of gray manually) and in the end you will probably have been better off making your region using the ingame terraforming tools. Finally, the most important tip when designing a region Heightmap: Use your imagination and have fun. That’s the whole point of SimCity 4, and once you figure out different ways of making the terrain look the way you want it, you’ll be amazed at the terrains you’ll be able to create. It just takes practice.

GETTING STARTED

The first step in drawing a region is to create a file of the correct size. If you’re unsure about how large your grayscale Heightmap should be, check the Config.bmp in the folder of the region you want to terraform (if you haven’t made one, do so). Then follow the above equation to determine the dimensions of your Heightmap. Note that smaller Heightmaps are easier to draw, so you may want to start off with very small regions, and work your way up to larger ones as you become more comfortable with drawing them.

Once you have the dimensions correct, set image’s Color Mode to 8-Bit Grayscale. Be sure the image resolution is set to 72 pixels/inch, and load the new file. (These demonstrations will all use a Heightmap size of 513×513 pixels, for a square region two large maps across.) You should now have a blank image.

NOTE!

When instructed to select a particular color (such as “85/255″), this means to make sure the Red, Green, and Blue colors are all set to that number. Thus, the color 85/255 would have a Red value of 85, a Blue value of 85, and a Green value of 85. These color settings will result in a dark shade of gray, about 36% White (64% Black), just above water level. To determine the percent-gray amount, divide the first number by the second number, which will always be 255.

On the blank image you’ve created, you’ll want to outline your coastlines first. Create a transparent new layer, which will serve as your “Land” layer. Select color 85/255, and using a solid pencil tool about 5 pixels in diameter, draw an outline of your region’s coastlines on the Land layer. Use squiggly, gently curving lines for Ocean coasts, and use parallel meandering lines for rivers. Draw small rough circles for ponds, and larger ones for lakes. When you have all your coastlines drawn, fill the areas where land is supposed to be with color 88/255. You should now have a dark gray map with white bodies of water outlined on it. This basic drawing will serve as the core of your landscape.

Adding Terrain Variations

Next you’ll want to add the hills, valleys, and plains. Using the soft paintbrush tools, draw slightly lighter gray areas for rolling hills or elevated plains, draw much lighter areas for high mountains, and draw darker areas for valleys. Note that the water level is approximately 84/255; this color and everything darker will be underwater, and everything brighter will be above ground.

SOME GENERAL TIPS FOR DRAWING REGIONS

  • Draw elevation changes in increments, and draw each increment separately. Use large, soft brushes to draw areas of higher terrain in increments of about 10-15 points. For example, first draw all the areas at 90/255, then within these higher areas, draw slightly brighter (95/255) places, and so on until you think the terrain is high enough. 
  • When building up mountains and gouging deep valleys, consider the way Heightmaps of real mountains look. Try downloading a few to examine, and see how real mountain ridges occur, and what they look like. It will probably take a lot of practice with the Paintbrush, Smudge, and Blur tools to make realistic mountains.
  • Keep in mind that the smaller and sharper the brush, the steeper the elevation transition will be.
  • Don’t be afraid to use the other tools the image editor has to offer; don’t limit yourself to the 30 pixel brush and the eraser. Some interesting effects can be created using some of the specialized tools, once you figure out where and how to use them.
  • Use the Blur tools often. Terraced landscapes don’t occur naturally, so unless that’s what you’re going for you’ll have to smooth off the cliffs and sharp elevation variations. Use both the blur brushes and the image-wide blur tools to accomplish this.

About ten minutes of drawing yeilded this image:

Building Underwater Formations

Once your above-ground terrain and water-filled valleys are finished, you’ll need to create the underwater terrain. Since your entire above-ground terrain was drawn on the transparent layer, the background will still be blank white. If you accidentally drew some or all of your terrain on the white background layer, then select the whole thing and cut it out. Paste it into a new layer, and color all the white areas (places where water is supposed to be) black. You’ll have to use a fairly sharp brush to do this, since if you blurred your coastlines there will be light-colored edges on it that you’ll have to remove. Then adjust the Blending Options just like you would if you had a Terragen image, so that all the water-covered parts of your terrain are transparent. On the Background layer, use a Texture Fill tool to make a mottled black-and-white background. Turn the brightness and contrast of this way down so that the terrain is very deep and very uniform in height. Just don’t make it flat, since seabeds and lakebeds are rarely smooth. Then select a very large Paintbrush, and color all the areas near coastlines slightly brighter then the surrounding seabed (78-80/255) to make the shallows near shore. Use darker colors (45-50/255) and very large brushes to make the depths of the oceans.

Another ten minutes of drawing made the image look like this:

PUTTING ON THE FINISHING TOUCHES

Once the mountains have been raised, the canyons have been cut, and the oceans have been filled, it will be time to convert your terrain image into the final Heightmap. To do this:

  1. Save the Terrain image, layers and all, so that you can adjust it if it doesn’t turn out the way you hoped.
  2. Flatten the terrain image; it is now a Heightmap.
  3. Apply a final light blur to the whole image, to break up any remaining sharp outlines.
  4. Check the size of the Config.bmp file you plan to use for the new region. To make sure you got the size of the Heightmap correct, multiply the height and width of the Config.bmp by 64, and add one to both. this will give you the dimensions of the Heightmap. Check to make sure the Heightmap is the proper size for your Config.bmp image. If it’s not, you’ll have to change the size of the Heightmap to fit, either just by changing the Image Size or by stretching it to the correct image size.
  5. Save the Heightmap as an 8-bit Grayscale Bitmap. If you set the color to Grayscale when you first created the image, then it should automatically save as a grayscale image. If you had the color settings set to anything other then Grayscale, (in PhotoShop) go to ImageModeGreyscale. A pop-up window will ask you if you want to discard color information; select Yes. Then save the image in the correct format.

This is the resulting Heightmap from the steps shown above:

IMPORTING YOUR HEIGHTMAP

The time has come; you’ve checked and double-checked your Heightmap’s size and color format, and you’re ready to see what it will look like as a SimCity 4 terrain. To do this, load the region you want to terraform. check to make sure your Config.bmp loaded properly, and there are no holes in your map. Then press, all at once, CTRL-ALT-SHIFT-R. A dialogue window will open, allowing you to browse your hard drive. Locate your Heightmap, and Open it. If all is well, SimCity will act like it’s opening a new city, except it will say “Creating New Region” at the top of the screen. Depending on how fast your computer is and how large your region is, this process could take anywhere from 10 minutes to three hours. You will know the game is working when the messages at the top of the screen keep changing. Eventually it will finish, and you will get to see your brand new terrain in the game. Don’t be disappointed if the terrain doesn’t turn out at all like you expected; just go back to your Heightmap image, and make sure the formats were followed correctly. If you drew your own region, it will most likely be very bumpy from the blurring the Image Editor did and the smoothing the game did on the region. This can repaired by opening each city and smoothing the terrain using the God-Mode Smooth and Erode tools. While you’re polishing up your terrain in-game, you can also adjust the mountains, plains and valleys so that they look just the way you wanted. Once the terrain looks perfect, you can plant trees, release wildlife, and start building!

The Terragen Heightmap shown above generated in this region in SimCity 4:

The drawing created in this article resulted in this SimCity 4 terrain:

ADDITIONAL HEIGHTMAP TIPS

You aren’t limited to using any one of these techniques for making a Grayscale Heightmap; There’s nothing wrong with using your creative wits to make that drab terrain you downloaded into an incredible landscape!

If you get stuck or frustrated while drawing a new terrain or tweaking an old one, save the terrain you have, and import it to see how it looks in the game. That will give you a good idea of where changes need to be made. Enjoy yourself. Have fun.

Once again, Good Luck and Happy Building!

Next Post

Cities XL Screenshots

You might have heard of Cities Unlimited – the new city building game by the creators of City Life; Monte Cristo. The project recently underwent a name change to Cities XL and is currently scheduled for release early 2009. Take a moment and have a look at some promising screenshots in our […]