|Design 1, Design 3 (Computer and Video Games)|
|Unit 5 (cont.): November 5th, 7th 2002|
Mathias Fuchs, email@example.com
H ow to Build Terrains in UT2003
If you use UnrealEd 3.0 or later, forget everything you read in the tutorial unit 5. The process of generating terrain has changed in every respect since Unreal Tournament 2003 was introduced. That's why this unit is UT2003 only !Lode Vandevenne (member of the Unreal Developer Network) compiled the information you find underneath. If you want to download the Word Document of this tutorial please right-click on this link: Unit5a.doc (1.54 MB, 48 pages)
If you want to have a terrain in your map, you need a very large area to add the terrain. Substract a very large cube, for example 65536*65536*65536. UnrealEd now supports sizes up to 524288*524288*524288, but I can't advice you to make such a big space.
To enable terrain in this cube, it needs to be a TerrainZone. You need a ZoneInfo for this. Open the Actor Class Browser, expand Info and then select ZoneInfo.
Place the ZoneInfo close to the center of the cube. If you right click in the center of the 2D overhead view and choose "Add ZoneInfo Here", it should be in the center of the cube automaticly.
Right click on the ZoneInfo and choose ZoneInfo Properties. In the properties window, expand ZoneInfo and there set bTerrainZone to True. Now the editor knows that this zone will contain terrain. Expand ZoneLight and set AmbientBrightness to 128, this way you will be able to see the terrain later when you haven't made sunlight yet. Never set the LevelInfo to bTerrainZone, or the editor will crash after you rebuild.
The terrain itself is generated by another actor: the TerrainInfo. Go back to the Actor Class Browser, and select TerrainInfo. Place a TerrainInfo in the center of the large cube.
The TerrainMap of your terrain is a heightmap that determinates where the terrain is high, where it is low or anything between this. It determinates the hills, mountains, canyons, valleys,etc... of your terrain. The TerrainMap is a 16-bit texture, but you can also import 8-bit textures in the editor. When you edit the terrain, the TerrainMap will become 16-bit. In the texture you use for the TerrainMap, the black color or the first color in the palette represents the lowest parts of the terrain, and the white color or the last color in the palette the highest parts. Most of the times you will want to import 16-bit or 8-bit greyscale textures for the TerrainMap, but it is possible to use any colored 8-bit palettized texture. Theoreticly you can use textures up to 2048*2048, but a enabling a texture of this size as TerrainMap takes much longer than rebuilding the lighting of a very large map. Most of the times textures with dimensions 256*256 will do fine.
Examples: This texture, fading lineary from black to white, will create a mountain with a peak. The texture is created with a brush with hardness 0 in PSP.
This texture, created with a brush with hardness 50, makes a more flat mountain:
If there is no fading in your texture, the faces of the mountain will be vertical:
Textures like this create very thin peaks, so it looks like grass:
The last two examples, both having very steep faces, create BSP holes quite easily. What you really want are complicated heightmap textures, like this one:
There exist some good programs to create heightmaps, for example in Terragen, that you can download for free at http://www.planetside.co.uk/terragen/
There are some good heightmap textures in the texture package Terrain.utx. Open this package with the Texture Browser, and select one of the greyscale textures, for example Mountains2. Then open the properties for the TerrainInfo and expand TerrainInfo. Click on TerrainMap and press the "Use" button. The name of the selected texture should appear in the TerrainMap textfield.
Once you have chosen a texture, the editor forgets about the texture from the texture browser and store it in the map file itself as a 16-bit TerrainMap, so you can edit it with the Terrain Editor later. This does not happen to the alphamaps for the layers. The terrain is still not visible in the editor, because you need to choose a texture for the terrain.
In the Terrain Properties again, expand Layers and there expand . Apply the following properties:
You will get an explanation for these properties later in the Layers section of this tutorial. Basicly, you now have chosen a tiled texture for your terrain.
If you did all of the above and rebuild , you should see the terrain. You might have to move your camera above the terrain, because it is invisible if you look at it from below.
If you press the "Always Show Terrain?" button next the the command input on the bottom of the editor, you will be able to see the terrain in the 2D Top View as well, if your camera is inside the TerrainZone.
You now have a working terrain, but it is still very ugly. However you can already test your map in the game now. First place a PlayerStart (in the Actor Class Browser under NavigationPoint), make sure it is above the terrain.
If you save your map, do not give it the name terrain.unr or terrain2.unr. There are already some texture packages called terrain.utx and terrain2.utx, and the engine will confuse the map and the texture packages.
Whenever you are walking around in the terrain in the game, and you want to be able to walk quickly from one side to another, type "slomo 8" in the console to walk 8 times faster than normally. Use "slomo 1" to get back the normal speed.
To change the size of the terrain, expand TerrainScale in the properties. The X and Y values determinate the width of the terrain, and the Z value the height of it. The size of one TerrainScale unit depends on the TerrainMap you used: if your TerrainMap is a 256*256 texture, the 1 X or Y TerrainScale unit equals 256 units of the grid in the editor. The Z value always equals 256 units of the grid, but also depends on the TerrainMap itself.
The TerrainInfo actor is always in the center of the terrain, at the same height as color 128 of a 8-bit TerrainMap would be. So if your terrain is 16384 units high (this means a Z value of 64), the lowest part of the terrain will be 8192 units below the TerrainInfo actor and the highest parts will be 8192 units above the TerrainInfo actor. You need to keep this in mind if you don't want to place the TerrainInfo too low or too high in your map, otherwise the terrain will partially disappear in the floor or ceiling.
If you used a 65536*65536 box and a 256*256 TerrainMap, set both the X and Y values to 256, so the terrain will be exactly as wide as the box.
Especially if you want Sunlight in your terrain, a SkyBox is very important. To create a SkyBox, substract a small cube somewhere outside the large cube you made. Add a SkyZoneInfo in it (in the Actor Class Browser under Info), add some lights and some textures.
Then go back to the large box, select all the walls of it, open the Surface Properties and enable Fake Backdrop.
If you rebuild, you should see the SkyBox paralax in the large box.
If your terrain is much larger than the 65536*65536*65536 box, and some walls are set to Fake Backdrop, you will be able to see the terrain behind these walls, but you will still not be able to walk through them. In the game, it looks like an invisible barrier.
P.S. the skybox texture is made by Adam W. Stiles - firstname.lastname@example.org
To make the terrain look nicer, you have to add one of more Sunlights. A sunlight is a light that comes from infinitly far away, and it is also calculated that way by the editor. This means that all the rays are parallel. In the calculations of the editor, the rays of a light are stopped by every wall, so also by the sides of the large box, except if they are set to Fake Backdrop. That's why you made this SkyBox.
Select the Sunlight class in the Actor Class Browser in Actor --> Light --> Sunlight. It doesn't matter where you place the light, only make sure it's inside the large box. After you added it, rebuild the lighting of the map and now the terrain will look very nice: the screenshot of the left has no sunlight, the one on the right has it.
You probably have to decrease the AmbienBrightness of the ZoneInfo and increase the Brightness of the Sunlight to see the effect better. You can change the color of the Sunlight the same way you would change the color of a normal light. However, LightTypes such as LT_Pulse or LT_Flicker will be ignored by the SunLight.
To change the direction of the light, use the rotation tool and rotate in any of the 2D views. The arrow shows the direction of the light. Rotating it up or down in one of the side views will simulate the sun being higher or lower. Rotating it in the top view will change the the direction of the sun (North, East, or whatever).
Note that the arrow points to the direction the sunlight comes from, and not the direction it is going to:
You can have multiple and colored lights in your terrain:
The Sunlight is actually a normal light with special settings enabled, if you want to create a Sunlight using a normal light, or if the Sunlight class is not in your editor, add a normal light and set LightEffect to LE_Sunlight in Lighting, and set bDirectional to True in Advanced.
If you have multiple zones in your map, the Sunlights will only enlight the zones in which you placed them, so each zone can have his own lighting.
The Sunlights will not only enlight the terrain, but also every other polygon that is in the map. Also, normal lights will enlight the terrain as well, as you can see on this screenshot:
The terrain you now created has only one layer: Layer with the grass. You can give the terrain up to 32 different layers. Every layer has a Texture and an AlphaMap. The Texture is a repetitive pattern for the layer, for example grass, and the AlphaMap is a large alphachannel that determinates on what places of the terrain the texture will be present, not present or anything between this. The Texture can be any texture that is not animated, the AlphaMap can be a 8-bit paletized or greyscale texture, or a RGBA texture. For now, use a greyscale texture. For layer, you should always use a 100% white texture, unless you want your terrain to be invisible at certain areas. For the other layers, use AlphaMaps with variating values of black, grey and white to create variation in your terrain. For example to create snowtops, use a snowy Texture, and use an AlphaMap that is black everywhere, except at the places where there are high peaks in your TerrainMap.
It's best to place the AlphaMaps in the MyLevel package. This is a package that is stored in the *.unr file of level itself and not in an *.utx file you have to save. To place a texture in the MyLevel package, type MyLevel as Package when importing a texture. The reason for this is, when you are going to edit the AlphaMaps later, you are actually changing the texture you used as AlphaMap. If you don't place it in the MyLevel package, you have to save the texture package every time you edited the terrain. Also, use a different AlphaMap for every layer, because if two layers use the same texture and you edit one of them, the other one will be edited too.
To add an extra layer to your terrain, expand Layers again in the TerrainInfo properties, and expand . Set Texture to for example SDirt2, and AlphaMap to a greyscale texture. If you want to use one of the AlphaMaps from the Terrain.utx file, and you want to place it in the MyLevel package, export it and then import it back. After you rebuild, you'll see the new terrain. Note on the screenshot the SDirt2 texture only being visible on the terrain at the places where the Alphamap1 texture is grey or white.
To add more layers, use , , etc... The more layers you use, the less repetitive your terrain will be.
For every layer, you can also set other properties:
When you are going to Terrain Edit later, you will be able to change these properties in an easier way.
Instead of using greyscale or other P8 (8-bit paletized) textures for the AlphaMaps of the layers, you can also use RGBA8 textures. This are textures with 4 8-bit channels: Red, Green, Blue and an extra AlphaChannel. You can easily create such a texture with PhotoShop, if you add a 4th channel and save it as a *.tga file with 32-bit per pixel. If you use such a texture, the AlphaChannel does the same as the P8 textures did: determinate how visible the texture of the layer is on certain parts of the terrain. The R, G and B channel add a color to it. This way, you can add more variation to the terrain, even when using only one layer.
You can of course also use this in more subtle ways than on the screenshot above.
Or to give your terrain and the skybox the same theme: it's hardly possible to see the difference between the mountains in the skybox and the 3D ones.
The layers use a hierarchy: layer is above layer, layer is above layer, etc... So if layer and layer both use a 100% white alphamap, only layer will be visible. On the screenshot, you can see how layer with the brown texture overlaps layer with the green texture, and layer with the grey texture overlaps both layer and layer, because layer is the highest layer in the hierarchy.
Also, if you haven't got a layer (so you don't have a Texture and AlphaMap set), but you have a layer, layer will not be visible. So you have to create the layers in the correct order, and not leave any holes between them. Before you create layer, you must already have created layer, layer and layer.
For the texture of any layer, you can also determinate the axis is used to align the texture. To do this, open the properties of the TerrainInfo, expand TerrainInfo --> Layers and there choose the layer you want. There you can choose your TextureMapAxis for this layer.
TEXMAPAXIS_XY will align the texture to the floor, this means if you place your camera above the terrain and look, the texture will look straight. TEXMAPAXIS_XZ and TEXMAPAXIS_YZ will align it to the XZ or YZ wall. If it's YZ, it'll look straight when you look to the East or the West direction. If it's XZ, it'll look straight when you look to the North or South direction.
Examples: In the first series of screenshots the camera is looking down and the TextureMapAxis is respectively XY, XZ and YZ:
In the second series of screenshots, the camera is looking to the West, and again the extureMapAxis is respectively XY, XZ and YZ:
Everything you did now was changing the properties of the TerrainInfo to get textures, a TerrainMap, etc... However, you can also edit all of this in real time in the editor, when you are in Terrain Editing Mode. To enable the Terrain Editing Mode, press the mountain button in the left toolbar.
You will see the terrain in the 2D Top view, and your mouse cursor will change into two yellow circles with a red dot in the center. Also a new window will appear, the Terrain Editing Window.
There is an Undo button, but you can only undo the last terrain editing action with it, and it has some bugs, so don't trust the undo button! The main undo function of the editor can't undo terrain editing actions.
The window has several parts:
You will get a more detailed explanation for these options soon.
In the part of the window that shows the layers, make sure the HeightMap is selected, so you will be editing the TerrainMap and not the AlphaChannels of the layers. Here's an explanation about what every brush does with your terrain:
If you select this brush, your mouse cursor becomes two yellow circles with a red dot in the center. The yellow circles represent the brush. In the Terrain Editing Window, you can set 2 radii for it: the Inner Radius and the Outer Radius. The inner part of the brush is the strongest part of it, the outer part is softer. The Strength (%) value determinates how strong the brush is, the inner part of the brush will exactly as strong as this value, the outer part will be less strong: the further away from the center, the less strong it is.
If you click with any mouse button on the terrain in the Top view or the 3D view, you will select some vertices of the terrain. You can select the vertices with variating strengths, depending on your brush. White vertices are selected the strongest, black vertices are the softest. All the vertices that were inside the inner yellow circle of the brush are white, the ones in the outer circle are the further away from the center, the softer. This will only work when Soft Selection is set to Automatic, so make sure that option is enabled.
You can change the radius of the inner and outer yellow circles in the Options part of the Terrain Editing window. For example, if you set inner radius to 512 and outer radius to 2048, your brush will look like this:
In the Options part, you can also set the Strength of the brush, for example if you set it to 50, your selection will become much softer:
When holding the CTRL key, you can select more places at the same time, however because of the automatic soft selection every circle you selected before will become larger:
If you disable Automatic Soft Selection in the Soft Selection part of the Terrain Editing Window, you will be selecting only one vertex at the same time, no matter what size your brush has. When holding the CTRL key, you can select multiple vertices, or deselect previously selectet ones. The strength of the vertex now depends on the Strength (%) value only:
If you now press the Select button in the Soft Selection part, you will get this:
The radius and strength of the parts that are selected by the Select button are determinated by the same sliders you use to change the radii of the brush. The target of Soft Selection is to create much smoother hills instead of sharp peaks.
The reason why you are selecting the vertices is because you can raise or lower them to create hills or pits on your terrain. After you selected some vertices, hold CTRL and both mouse buttons, and drag the mouse. The white vertices will move up or down much faster than the black or grey vertices.
When you want to raise or lower the terrain, first press both mouse buttons at the same time and press CTRL only after it. Otherwise the editor thinks you want to extend your selection.
This brush allows you to make a rectangular seletion on the terrain. Hold CTRL and left mouse button, and drag the mouse to select.
If you drag the box with the right mouse button, one corner of it will automaticly be placed in the center of the terrain. You will need a selection like this later, for the Terrain Generator.
With the Painting Brush, you can paint on your terrain ro raise or lower it. Hold CTRL and left mouse button, and move the mouse over the terrain to raise the terrain on these parts:
If you hold CTRL and the right mouse button, you will lower the terrain:
With the Adjust and the Strength (%) options in the Terrain Editing Window, you can make your brush stronger or softer, for example if Adjust is 5 you will have to paint much longer to get the effect you would get if Adjust was 50. The size of the peaks depends on the size of your brush, that you can determinate with the inner and outer radius values.
When you use the Painting Brush on your terrain, BSP holes will be created quite easily, especially if there are very sharp peaks. You can reduce this with the Smoothing Brush.
If you hold CTRL and a mouse button, and you move the brush over sharp peaks, you will make them much smoother.
Again, the Adjust and Strenght (%) option determinate how much the effect is present, the following screenshots show the effect with a Strength of 24:
This brush creates random noise on the terrain, if you drag the brush over it with CTRL and any mouse button pressed. The higher the Adjust value, the more differences in height there will be.
When you press CTRL and a mouse button and start painting, all places you touch with the mouse will get the same height as the place where you started, so you get flat terrain. You can create plateaus if you start at a high point, or canyons if you start at a low point.
With this tool you can edit the visibility layer of the terrain, to make all layers visible and solid, or invisible and non-solid. More details about this later.
Use CTRL+Right mouse button to make the terrain invisible, and CTRL+left mouse button to make the invisible parts visible again.
The sides of the invisible part get blocky, so you'll have to hide them with normal or hardware brushes (for example the sides of a cavern).
These brushes don't do anything on the TerrainMap, you will use them later when you will be editing the AlphaMaps.
When you are editing the terrain, you might encounter something similar to BSP holes, especially when you have very sharp peaks. Most of the times you will only see them when you test your terrain in the game. The screenshots show the same peak, with the camera rotating up. At some angles, the peak suddenly disappears partially.
Also very steep faces can and will create holes:
The best way to avoid holes, is to use the Smoothing Brush: it allows you to remove the sharp edges of peaks, and to make faces that are too steep softer. There should be no holes anymore after you did this.
The Terrain Generator can crate random terrain for you, it can do this for the entire terrain or just with a part you selected. First select a part of the terrain with the Select Brush. Then open the Misc Tab.
If you press the Build button, random terrain will be generated inside the selection only if Use Entire Heightmap is disabled, or for the whole terrain if this is enabled.
There are two values: Height Seed determinates the average height differences that will be created: the screenshot on the left shows a Height Seed of 10000, the one on the right shows a Height Seed of 75000. Both screenshots are taken with a Scaling of 0.3
The Scaling Value determinates the size of the tops: the screenshot on the left shows a Scaling of 0.1, the one on the right shows a scaling of 10, so the hills in the second screenshot are 100 times wider than the hills in the first screenshog. Both screenshots are taken with a Height Seed of 75000.
There are still some bugs in the Terrain Generator: if you want to do this for the entire heightmap, it still asks you for a selection, and if you undo this action, the action will only be undone inside the selection, even if you changed the whole heightmap. Also, the Move Actors with Terrain option doens't seem to work. After you generated a terrain for the entire heightmap, all terrains in any map you open might look as if they're full of BSP holes. If you close and reopen the editor, this problem is solved.
Until now you used the brushes to edit the TerrainMap, so you changed the height of the terrain. You can also use them to edit the AlphaMaps for any layer, so you can manually paint dirt paths in the grass, snow, swamps, etc...
To do this, select a layer in the Terrain/Layers part of the Terrain Editing Window. Don't select the first layer in the list, because you probably want to keep the 100% white alphamap for it.
When editing the AlphaMaps, make sure they are in the MyLevel package, or if they are in another package you save that package every time you finished editing the AlphaMaps. You can use the different brushes again for different operations:
These tools will edit the height of the terrain, even if you have selected a layer in the list. So they do exactly the same as explained higher in this tutorial.
This tool allows you to litteraly paint on the alphamaps: if you hold CTRL and the left mouse button, and drag over the terrain, you will make the AlphaMap brigher on the spots you touch, so the texture of the selected layer will become more visible. For example you can paint a mudpath by editing the layer with the SMud1 texture:
As you can see, sometimes there appear artefacts on the terrain when you paint on it. You will be able to remove them with the Smoothing Brush. If you paint with the Painting Brush using the right mouse button, you will make the alphamap darker, so the texture of the selected layer will become less visible on the touched parts:
The Inner Radius, Outer Radius, Strength and Adjust values again determinate the way you will be painting: with a larger or smaller brush, a smoother or sharper brush, and a softer or harder brush.
If you paint with the right mouse button on the first layer, layer, the terrain will become transparant or invisible on the location of your brush, if there's no other layer above it.
If you hold CTRL and click with any mouse button at the alphamap, everything in the radius of the brush will become smoother.
If you lower the Strength value, the smoothing effect will be reduced:
With this you can create random patches of the texture inside your brush:
This brush doesn't do anything on AlphaMaps, it only works with the TerrainMap. An explanation for this is higher in this tutorial.
Because this tool makes all the layers and the terrain itself invisible/non-solid at the same time, this tool does exactly the same if you use it on any of the layers or on the TerrainMap. More about this tool later.
These brushes don't edit the alphamap, but the alignment of the tiled texture your selected layer uses. The Tex Pan Brush will pan it from left to right if you use CTRL + left mouse, and from up to down if you use CTRL + right mouse button.
The Tex Rotate Brush will rotate it.
The Tex Scale Brush will scale it from left to right with the left mouse button, and up or down with the right mouse button. You can also mirror the texture with it, if you make it very thin and then still keep dragging.
The buttons on top of the Terrain/Layers part of the Terrain Editing Window allow you to delete, add or modify the order of the layers.
The visibility layer is an extra 1-bit layer: visible or invisible. To make parts of the terrain invisible, use the Visibility Tool. The invisible parts make ALL the layers invisible on that part, and are also non-solid (walkthrougable). The most important use of this feature is if you want the player to be able to go under the terrain, for example a inside building with floors under the ground or a cavern.
For example if you want to make a cavern in a mountain, you'll have to make a hole in the side of the mountain first, so players are able to walk to the inside of the mountain.
Then the player can go under the TerrainMap. You'll need normal brushes, hardware brushes or another terrain for the player to stand on. Also, if you're under the terrain and you look up, you can't see the terrain: the surface of it is one sided, so you need to make walls and a ceiling as well. On this screenshot, a lot of static meshes were added to make a long cave that brings the player to another part of the map, where there's another invisible, non-solid hole in the terrain. The second screenshot shows the view inside the cave to the outside.
DistanceFog creates realistic fog on the whole terrain or inside any other zone, and it can make your map faster because the fog hides the polygons that are inside the fog. To enable the DistanceFog, open the properties of the ZoneInfo actor, expand ZoneInfo and set bFogZone to True. Then expand ZoneLight and use the following properties
You can have as many TerrainInfo Actors as you want in a zone, if you place the TerrainInfos are close to each other, the terrains will stick through each other, as you can see on the screenshot:
If your map has multiple zones, and you are outside the zone with the terrain in it, you are unable to see the terrain, even if it's set to bTerrainZone as well. So when you have a building with windows in it on your terrain, make sure the rooms with windows are in the same zone as the terrain itself.
The terrain is made to be used for outdoor terrains: mountains, deserts, canyons, etc..., but it can also be used to get the effect of DisplacementMaps on a floor. You can for example make a floor with with 3-dimensional tiles. On the screens, the effect is a little bit exaggerated to make it clear.
If you compare it to a flat floor, a floor with DisplacementMaps looks much better.
To make the effect, a rastered texture was used for the TerrainMap, every square is one tile. Because every tile has it's own place on the texture, you can give individual tiles a seperate height, for example to make a broken tile somewhere.
In TerrainScale, the Z should be a very low value, for example 0.05, if you leave the value at 1 the tiles will be 256 units high. Use a floor texture on the terrain, and pan and scale it until it's what you want.
The performance of this really isn't bad. However you can only use it for floors, so you can't make brick walls with 3D grooves between the stones. In one of the later builds, there might be added support for real DisplacementMaps or BumpMaps, so it's up to you what to choose.
If you enter "stat terrain" in the console (in the game or in the editor), you get some stats about the terrain.