Terrain Building

Contents:

Basics / Getting Started

We're going to have a look at creating some basic terrain today, discuss a couple different ways to make terrain, how to texture it properly, edit it properly, and go over the tool set provided via UEd. Expect this to be a fairly HEFTY tutorial!

First things first - you'll need to subtract a big cube to place your terrain in. It should be rather large. So if you right click on the Cube button on the left toolbar you'll be presented with a dialog showing you some options you can apply to the cube brush you are about to create.

You'll notice that I've put in some simple multiplication formulas for the cube dimensions. UEd will allow you to input something like 1024*16 and it will do the math for you - so you need not be able to cite numbers that are multiples of 16 quite so high :) You may also want to set your grid size to about 1024 or so. Something higher than 16 obviously. Now go ahead and subtract it with the subtract button or just hit CTRL-S. You'll need to apply a different texture to the sides of the cube otherwise UEd is likely to give you a null material warning when you rebuild.

Next up - place a ZoneInfo actor (located in the actor browser under Info->ZoneInfo) into this cube. In order for the Unreal Engine to render terrain in a place, that place has to be a "terrainzone". There is no TerrainZone actor in the actor browser, so you place a ZoneInfo actor in, and set it's ZoneInfo->bTerrainZone property to "true". You might also set it's ZoneLight->AmbientBrightness to a mid range value like 192 or higher so you can see the terrain later without adding lights. You can rebuild now to let the zone settings take effect.


Creating a TerrainInfo

Now that the place the terrain is going has been prepped, it's time to create the actor that will actually be the terrain. This is a TerrainInfo actor. It uses a greyscaled bitmap, called a "heightmap" to generate terrain with. The lighter/more white the pixel on the map/image and the higher the terrain will be generated in that corresponding spot on the terrain. TerrainInfos can actually be made a couple of ways depending on how much control you want over things. If you're an absolute control freak and want to directly use your OWN heightmap, premade for the occasion, you can import one manually. We'll cover that a bit later, but for now we're going to use the tools in UEd to generate a quick and dirty, and relatively easy, terrain.

Click the Terrain Editing button on your left toolbar. You'll get a dialog with lots of options on it, and several tabs as well. We're first going to cover getting the terrain in place and generated. Then we'll cover the tools to shape the terrain a bit later. But for now lets take a look at the dialog and see what we need to be looking at:

Things to particularly note have been circled in the picture. Those are the Tools, Misc, Terrains, and Layers tabs. Also circled is the Tools list on the left side of the dialog. Make sure that you have the Terrain tab clicked like the picture. The last thing circled in the picture is the New Terrain button - the little file icon in the lower left of the dialog. Click this button and you'll get another dialog like this one:

This dialog is a lot like the other "new something" dialogs in UEd. You provide it a package name in which to store this new thing you are creating (in this case terrain related stuff) a name to call it, and we also have some dimension values. We're going to leave those at the defaults for now though. Enter the values as I have them in the picture. You'll note I've entered "myLevel" for the package name. This is a reserved package name in UEd that tells the editor to store the new stuff into the map file itself. You could very well use a different name if you wanted the package to reside outside of the map - so you could access the terrain height map from another map you make.

Enter the values and click "OK". Now your Terrain Editing dialog should look like this:

Notice it's created a terrain map info section for you and it's highlighted/selected. It has the name you gave it and is placed in the Terrain Infos list as "TerrainInfo0". You might also notice that you've got two yellow circles with a red "pin" in the middle of them for a mouse cursor in the 3D view window. We'll explain that in a few. But for now turn your attention back to the Terrain Editing dialog.

The terrain object has been created, but it still doesn't know all the info it needs to know to draw it out. So that's what we're going to give it now. Every terrain uses "layers" to give the engine information about what texture to put on it and where and how that texture should be drawn on the terrain. Since there are no layers yet, there's literally no terrain being drawn. So lets fix that by clicking the "layers" tab.


Layers

More options - and a list of "undefined" layers. Highlight/select the first one in the list by clicking on it. It should be outlined by a slightly grey box like the pic below:

This is going to be our "base" layer for our terrain. A terrain needs a proper texture, so locate one in the texture browser, which ever you like, and select it. You'll notice in the pic above I have a button circled. Now back in your Tool Editing dialog, press the "New" button circled in the pic above. You're presented with yet another "new something" dialog (in this case new layer) and more options. There are a fews things that need to be set here for the terrain to render correctly. But first an explanation of layers.

A layer, as mentioned before, tells the engine "render this texture in this manner, on these spots". It's the "these spots" part I need to explain right now. A layer renders its texture on a terrain according to an "alpha channel". All an alpha channel is, is a greyscaled image - the texture will be drawn where ever it is white, not where it is black, and will fade accordingly in the grey areas. Since this is our base layer and we want the texture drawn EVERYWHERE for the terrain to show up everywhere, we need this alpha channel to be completely white for this layer. Now - back to that dialog. Enter the info as provided in the picture below:

We've given it the package of "myLevel" which you already know about. We've given it a name. Now you need to note the "AlphaFill" setting. The alpha channel will basically be filled with this color, so set it to pure white by highlighting it and clicking the "…" button that shows up to its right. Then you can choose white for your color. Also note the UScale and VScale options. These MUST be set higher than 1. This basically tells the engine to render the texture onto the terrain at this scaling. Keeping it at 1 will cause it to scale the texture to fit onto 1 pixel of your height map. The result would be your terrain will be one constant color. We've set both to 25 here, but you can play with values later to tweak it.

Once values have been set click "OK". You're returned to the Terrain Editing dialog. A couple of things should have happened now. One, a new layer has been created in the layers listing and the "undefined" layer underneath is now highlighted/selected. And two, you should see a flat plane in your 3D window with the texture you selected for your terrain on it. This is your terrain. You should also notice a TerrainInfo actor icon in your cube now. This can be moved around to place the center of the terrain in the map just where you like. You can see that those yellow circles and red pin that your mouse cursor turns into in the 3D view - follows along the terrain. This is your terrain tool (think of it as a "paintbrush" of sorts) and will follow the contours of the terrain. The red pin snaps to a vertex on the terrain, the circles are the "soft select" or ring of influence for the tool. But this terrain is flat and pretty darn boring right now. Terrain is supposed to be hilly and interesting looking. So lets make it such.


The Misc Tab and Random Terrains

UEd provides a way to randomly generate some hills on your new terrain, the method to do this is on the "Misc" tab, but there are a couple things that need to be done first for this to work. So lets take care of those now.

First off click the Terrains tab and select the terrain in the list by clicking on it like below:

Now the random generator only works when you have the "Select" tool chosen. So lets look at your "tools" listing now.

Lots of tools, but right now we're going to need the Select tool - so choose it by clicking on it. Now you can click the Misc tab to get to working on some hill generation. Pretty simple setup here - only four things to look at. Two values, a button and a checkbox. Lets see what each one does.

First up the values. Steps basically tells the editor "when generating hills use a grid that is STEPS in length and STEPS in width" It will then randomly push or pull vertices on that grid to generate hills on the terrain. In short if you want a few large hills the lower number the better. Want a lot of hills, higher number the better. Next value is the Strength value. This tells the editor how strongly to push or pull the vertices on the grid defined by the Steps setting. A higher value will create generally higher hills, and a lower value - eh you get the picture. Next is the "Use Entire Heightmap" check box. This is a deceivingly powerful little option. You'll notice in the 3D view, your cursor has changed to a red dot and a dashed box icon. This is the select tool in action. It basically lets you select a "section" of the terrain to work with. The tools for the terrain are engaged by CTRL-LeftClicking on the terrain where you want the tool to be engaged at. In the case of the select tool, you can CTRL-LeftClick to drag a selection box about a section of the terrain. If you leave the "Use Entire Heightmap" box unchecked then the terrain will be generated in that selection box ONLY. That's not what we want, however, in this case. So check the box to make the hills be generated all over the terrain. And last but not least is the magic button "Build" this commits the settings you've made and generates your terrain accordingly. So feel free to play with the settings as you like and click Build. This is an interactive type process in that once you click build if you don't like what you see, you can simply insert some new values and build it again until you like it. So go ahead and play with the values a bit to see what kind of terrain you can make. When you are done and want to get rid of the Terrain Editing window, simply choose another tool (like the camera tool ha ha) from the Toolbar on the left of UEd.


Manual Entry and Tweaking Your Terrain

Ok so now you know how to use the built in tools to generate a random terrain. But what if you don't like the tools provided and want to create your own custom heightmap in say Photoshop. Or perhaps you want to create a second layer for your terrain that paints a textured path onto your grassy hills, but want to be very very specific about where that path goes? You could go into Photoshop, paint it out how you like, then import the results into UEd manually. So lets try that.

First off we're going to follow the same base instructions. Starting from scratch, we need a cube room, we need a ZoneInfo with bTerrainZone set to true and its AmbientBrightness set up a bit. Then rebuild to let the changes take effect. Now we start the manual process.

You'll need a TerrainInfo actor in there - this will store all the pertinent data for your terrain. The actor can be found in the actor browser under Info->TerrainInfo. Once you've placed one in the cube room, you will want it roughly centered. Now open up it's properties and have a look around. Under TerrainInfo you'll notice lots of stuff. The two main things we want to focus on here is the "Layers" slot(s) and "TerrainMap" slot.

So open up Photoshop and create a new RGB image. Make it 256x256 and paint, in grey scale, what ever sort of height map you like. Remember the whiter the areas, the higher it will be on your terrain. Save it as a 16-bit bitmap someplace. Now import this as a texture into UEd. You can import it into "myLevel" as explained above and give it a name. When you import it, it should import it as a "G16" texture (explanation of that later) Now select that texture in the texture browser. In the TerrainInfo properties, highlight TerrainInfo->TerrainMap and click the "use" button to assign that texture you just imported to it (see image below):

So now your heightmap is assigned, but you still need a base layer. Back to Photoshop. If you'll recall from above, layers use alpha channels to define where and where not to draw the texture on the terrain. For our base layer we want a completely white alpha channel. So go back into Photoshop and create a 256x256 image and fill it totally with white. Save it as a 24-bit (that's 24 NOT 16!) bitmap. Import this texture now into UEd into the "myLevel" package. Select/highlight it in the texture browser. Now back to the TerrainInfo properties.

We need to expand TerrainInfo->Layers. You'll see a list of numbers. These are the possible layers for your terrain. The base layer is going to be number 0. So expand TerrainInfo->Layers->0.

Now you should see a value called "AlphaMap". Select it and click the "use" button to assign that pure white texture to it. Now it needs a texture for the terrain! In your texture browser, find yourself a nice terrain texture to use and select it. Back in the TerrainInfo properties, highlight TerrainInfo->Layers->0->Texture and click the "use" button to assign the chosen texture to it. Now you need to set VScale and UScale to something other than 1 - above we chose 25 for both values and that will work here as well.

At this point if you rebuild, you should see your terrain in the 3D view. You can now use the Terrain Editing dialog to make changes to your terrain if you like using the tools that will be described below. Note that whether you create your terrain using the Terrain Editing dialog OR via the manual way just outlined, you can still open up the properties for the TerrainInfo and tweak the scale settings, sizes, etc. So it's good for tweaking afterwards if you need to.


Caveats of Manual HeightMaps

While manually creating a heighmap gives a bit more flexibility there are some things to be warned of. Mainly restrictions that MUST be adhered to when doing things the manual method.

First and foremost. You're heightmap and layer alpha map dimensions MUST be the same. Ie, if you make a height map that is 256x256 and and a base layer, then the texture you use for the AlphaMap must also be 256x256. Not doing this will cause the editor to act wonky on you when you attempt to use the various terrain editing tools.

Next. You're heightmaps have to be G16 textures and your alphamaps have to be RGBA8. Now what the heck does this mean? These are just UEd nomenclature for texture formats. A G16 texture is a 16-bit texture with no alpha associated with it. So if you save out of Photoshop as a 16-bit bitmap, and import into UEd, you'll get a G16 texture. RGBA8 is UEd's term for a 24-bit texture basically. So if you save out of Photoshop as a 24-bit bitmap, you should get a RGBA8 texture in UEd when you import it.


The Sunlight Actor

Now you're probably going to want some better lighting than the default ambient brightness at this point. A sunlight actor is good for this. You can locate the sunlight actor under Lights->Sunlight. Place one of these in your level and rotate the arrow on it to point in whatever direction you want the sunlight to shine towards. Now if you rebuild at this point you'll notice that there's no sunlight there. That's because a sunlight actor requires that there be walls in that zone set to "fakebackdrop" in order to emanate light. So you'll need to make a SkyBox and set some of the walls and ceiling of your cube room to "fakebackdrop" in it's surface properties. I'm not going to outline how to make a skybox - there are tutorials out there to handle that. Create a skybox, flag some of those walls to fakebackdrop and rebuild. You should now have some light in there.


The Tools

Now we're going to do a quick run down of some of the tools available in the Terrain Editing dialog. You'll see the tools listed on the left side of the dialog and you select one by simply clicking on one. It should be noted that if you have the Terrain Tab chosen, then the tools will generally affect the terrain heightmap information of the currently selected terrain. If you have the layers tab selected, then the tools will affect, generally, the alpha channel of the layer you currently have selected. Also, in general, you engage the tool by CTRL-Clicking on the terrain surface in the 3D window. Some tools will use both mouse buttons. So that being the case, lets have a look at a few of the important tools here.

  • Vertex Editing - just as it implies, if you are on the terrain tab and select this tool it will allow you to LeftClick on a vertex of the terrain and raise or lower it by CTRL-BothMouseButtons and dragging the vertex up and down. If you have softselection checked you'll be able to raise and lower other vertices around the chosen one on a scaled strength. This way you can raise up "hills" instead of raising up mesas ;)
  • Select - you got a taste of this one with random terrain generating. This allows you to select a portion of the terrain by CTRL-LeftClick and dragging a selection box.
  • Painting - this one's a biggie. In the terrain tab, it allows you to CTRL-Left OR CTRL-Right click and drag to paint the height of the terrain in the 3D window. If you're on the layers tab, create a new layer, set it's AlphaFill to total black. Now using the paint tool, you can paint that texture onto the terrain wherever you'd like it to go by using CTRL-LeftClick and CTRL-RightClick and dragging around.
  • Smoothing - in the terrain tab, this will smooth out rough edges, or hills on the terrain by CTRL-Clicking on it. Under the layers tab, this will allow you to smooth or blur the edges of your painted on textures for the layer you have selected.
  • Noise - in the terrain tab, this tool will add some random "noise" or bumps to your terrain by CTRL-Clicking and dragging a bit. In the layers tab, it will add random white/black noise to your texture by CTRL-Clicking and dragging a bit - giving your texture a somewhat speckled appearance.
  • Flatten - in terrain tab, CTRL-Clicking and dragging will literally flatten any terrain surface to whatever height the first vertex you started dragging on was.
  • Visibility - in the terrain OR layer tab, CTRL-RightClicking will effectively "erase" polygons from the terrain, marking them invisible. CTRL-LeftClicking will paint them back in. Invisible polys on terrain can be walked or fallen through by the player. So you can use this to carve out a spot to say put a cave in the side of a mountain for instance.
  • Edge Turn - using this tool will allow you to turn the edges of the polys on the terrain. Hard to explain, but the effect is that it can allow you to better shape sharp edges on your terrain. Say you had a ledge overlooking a canyon - this tool could help shape the edge of the ledge a bit better.
  • TexPan - in the layers tab, CTRL-Click and dragging will let you slide the texture for that layer around.
  • TexRotate - the layers tab, CTRL-Click and dragging will let you rotate the texture for that layer.
  • TexScale - in the layers tab CTRL-RightClick dragging will let you scale the texture for that layer along one axis. CTRL-LeftClick dragging will let you scale along the other axis.

You'll also notice that you can set the brush sizes for the inner and outer radii as well as the brush strength in the middle of the dialog. Checking the "Per Tool" check box will allow you to edit the settings for that tool only. Keeping it unchecked will apply your brush size and settings to every tool in the list that uses it.

In another tutorial we'll cover deco layers, texture mapping coordinates for terrain, and other neato stuff, but for right now this should get you going pretty good with the terrain options in UT2003.