Game Development Community

Making a Terrain in T3D From Start to Finish

by Jacob Dankovchik · 05/19/2009 (9:11 pm) · 31 comments

In this tutorial, I'll be working with L3DT. It is a very useful program for terrains and can do very simple terrain very quickly, or if you take the time to really unlock it's features, has many powerful tools for advanced work. You can buy it here on GG, as the L3DT For Torque, however with Torque 3D that version isn't really any more helpful anymore. Or you can get it from www.bundysoft.com/L3DT/. If you purchase from the main site, you'll have access to pre-release development builds. Your choice.

In this guide, I'll cover the basic randomized generation in L3DT. I won't take the time to get into more advanced concepts as that would take too long to write about in depth. This will thoroughly cover how to do a basic terrain and if you really wish to learn how to do higher-end work, this will be a good stepping stone.


So to start, we open L3DT. Go to file, New Project. In the window that comes up, Designable Map (recommended) should already be highlighted. If not, select it and click next. This will set us up to create a generated terrain but that will also be able to be edited by hand, if need be.

In the next menu that comes up that says Heightfield size, change the width and height (default value of 1024) to 2048. This is a fairly large terrain we'll be making for this example, only to demonstrate something with quite a bit of meat in it right off the bat. If you really want, you can go smaller though.

Below the dimensions is something that says "Horiz. scale (m)". This is how many meters you want each pixel to represent. When you import your heightmap into T3D, you'll want to set the squareSize variable to the same value as this. Since the default 10 is excessively large for Torque, change it to 1. This will create a terrain scaled to 2048x2048 meters, plenty large enough.
img193.imageshack.us/img193/1418/mapsize.jpg
Click next. In the next menu, Design map size, you won't need to change anything. This is if you want to change the resolution of the first stage of the process, the Design Map. That's nothing we need to worry about here.

The next menu, Design Map Parameters, is where you really put it together. For this demonstration, I'll go ahead and make a set of sharp mountains. To do this, move the Average altitude slider all the way to the right for land. Move the Altitude range up a few notches as well, for my own I'm setting it to the mark before last. For Scale of features, I'll move my slider up a couple tick marks. The very name of those variables should be quite self-explanatory.


The next 4 variables are what really do the shaping that will make your terrain what it is. Since I want to go with some sharp, jagged mountains I'll give my terrain a high Noise strength. This will make the map very bumpy and detailed. I'm setting mine to the tick mark before last.

Noise shape is what will determine what form you want it to take. To the left towards rolling you'll get smooth curves and bumps. To the right towards fractal, you'll get more of sharp lines and edges. Since we're going for sharp mountains, we'll want our noise to have a fractal shape. My marker is put in between the next to last marker and the marker before that.

Cliffs and terraces can add quite a bit of detail however a little bit goes a long way. If you get carried away with this variable you can easily get a terrain that is not at all what you wanted. You will have little platform and sharp drops all over the terrain. Sometimes this is desirable depending on what you are making, but for this we'll set it to something low. I'll go with the third tick mark.

Erosion adds great detail to a scene but at the cost of great generation times. Nevertheless, I feel our mountains should have some strong erosion so I'm going for the center tick.

Since we won't want anything to do with Lakes, leave that slider at few. That variable will make certain parts prone to form lakes.

Climate is one of the very great features of L3DT. Your climate is a detailed file that says which textures go where. It can be very simple, or very very detailed. For this we'll keep it simple and go with the default climate of Temperate.
img193.imageshack.us/img193/221/designsettings.jpg
In the next menu, Calculation Queue, only leave Design map selected since we're going to do this step by step. Click OK and it should go to work spitting out some stuff that flips by so fast you can't even really read it. After that, you are presented with a very low-resolution map with varying shades of greens and browns. This is your design map. Each pixel of it contains detailed information on the terrain, the level of all formation variables. This is passed off to the heightmap generator and a heightmap is formed by calculating and interpolating between the design map pixels. Up at the toolbar is a pencil looking tool, this is the design map pencil. With this you can manually edit your design map. Since L3DT's website contains detailed information on this, I won't go into it here.
img41.imageshack.us/img41/7314/designmap.jpg
Also on that bar, the 5th button over, is a series of green arrows with the word Calc above it. Click that and you are again greeted with the Calculation Queue. Heightfield should be checked. Again, one step at a time, so, click OK. You'll be greeted with a small window with some colors zipping by and probably mostly talking about erosion. This is where the heightmap is being formed and this map take a while, so feel free to go grab a drink or take a restroom break at this point in time.
img195.imageshack.us/img195/3629/heightprogress.jpg

Once all that is done, you should presented with something that hopefully looks like this:
img38.imageshack.us/img38/9946/heightmap.jpg
This is our terrain! Since that's the first image we need and it's already done, we might as well just go ahead and export it now. Right click on the picture, go to export, and click Export Active Map.
img190.imageshack.us/img190/4211/exporting.jpg
For file format, select PNG and stick it wherever you like. There will be no need to re-size the heightmap.
img199.imageshack.us/img199/7968/exportmenu.jpg
Once it's done exporting we're ready to move on. Return to the calc button and click it. Water map should already be checked, if not, check it and click Next. The next menu titled Water flooding is mostly just details we need not worry about here. If you want, you can make it turn anything below a certain elevation as sea, or you can make it freshwater, auto-flood sea will turn and sea blocks in your design map to water and flood outward to everything else, same with auto-flood lakes, only with freshwater. Anyhow, click next. The next menu with a bunch of variables we in no way need to mess with, so click OK.
img199.imageshack.us/img199/1754/wmprogress.jpg
And you should get something sort of like this:
img41.imageshack.us/img41/7599/waterr.jpg
This is our water table, a model of our groundwater. This helps in placement of grasses and other textures. Unlikely it will significantly affect our mountain set, but it's still a good idea to calculate it out anyhow for accuracy's sake.

Back to the calculation queue and this time, we're doing Attributes map. In Attributes map calc. you can make it higher resolution than your map itself, or split it. We don't need to do any of that, so click OK. After some calculations you should get something like this:
img195.imageshack.us/img195/7353/21940226.jpg

Now we have all of our terrain's data constructed, we're ready to export our alpha maps. Right click, select operations, Alpha maps, Generate maps.
img193.imageshack.us/img193/4593/alphagen.jpg
The next menu, Combine alpha layers, tells us what textures are used by our map and how much coverage the make up of the map. It will probably look something like this:
img196.imageshack.us/img196/8202/coverage.jpg
It appears we got lucky and the map only called for 4 different textures. This means we can get away with just one alpha mask and thus less headache. Look over anything you feel you need to. Also, remember what channel is what texture, as you'll need to know this later. I'll remind you in case you forget later, but nothing stops you from writing it down. Click next.

In this menu, we export our mask layer. As you can see, you can select Layers per image, file formap, high-res, split, and export now. The only thing we'll want to select here is Export alpha maps now. It will ask you to save an xml file. Stick this wherever you like, usually along with the heightmap is a good idea, and click OK.
img190.imageshack.us/img190/7761/alphaexport.jpg
You are then greeted with a colorful display that should be something like this:
img190.imageshack.us/img190/6766/alpha.jpg
We are now done with L3DT! But, before we exit, we need to get a readout on our altitude range if we want this to be correct. Navigate to the heightmap by clicking on the small button that says "Heightfield". Your heightmap image will then reload onto the display. Move your mouse to the highest point you can locate. In the bottom right corner of L3DT is says what the altitude is at your mouse position. You don't have to worry about being exact with this by the way, a few meters off won't make a noticeable difference. Now navigate to the lowest point and subtract this from your highest point. My lowest is 94m, my highest is 614. So, my height range is about 520 meters.

Save your project if you like, and we can get ready to see how our hard work has paid off.


We are now ready to open T3D. Do so and setup to create a new mission. When you get there, delete the terrain that's already there, we won't be needing it. (Don't forget to free your camera from the player, if it's attached)

Go to file, import terrain heightmap. Since our horizontal scale in L3DT was 1, make your Meters Per Pixel 1 in the menu. For Height Scale, we enter our altitude range of 520. In the heightmap image box, browse your way to your way to your heightmap and select it.

In the small box below click the plus sign, and navigate to your texture mask layer. A small note of a possible bug: Sometimes T3D won't like the name L3DT gives your mask, it will cause it to say that your mask size doesn't equal the heightmap size. For this reason, just rename it from the browse window and import it. Something simple like "mask" should give you no trouble.
img196.imageshack.us/img196/9974/import.jpg
Now here is the part where you should've written down your textures for your channels, if you didn't remember them. If you can't remember and were lazy (shame on you), go to where you saved that XML file and open it. Where you see it listing off the filenames of the textures, those are the textures each channel of the PNG represents in the order of RGBA. If that doesn't work, you'll have to reopen your L3DT project and go through the alpha map process to get a readout on your textures. I'll leave that to you as punishment if you are in this group. Live and learn.

Now, select the first of the channels, the red, and click Edit and pick the material that goes with it. This is the part where your process will most likely vary from mine since I may not have the same material files you do. You can use the default demo T3D materials, or your own if you've made your own. Since material creation is a whole other issue, I won't go into it here.

Once you have your materials assigned, go ahead and click OK. Since we're using a 2048x2048 map, which is rather large, this may take a minute or two. I've had a couple instances where T3D will crash at this step for no apparent reason. If this happens, don't panic, just try it again.

Once that's done, you should have something like this:
img193.imageshack.us/img193/4822/firstpass.jpg
Now, all may appear to be great, but it very well may not be. While our terrain is in, and working, it may not be quite perfect. If you drop your player on it and run around, you'll probably notice very quickly that the shadows look very poor and glitchy. This is not a big issue, just a small number that needs changed from it's default value. Go to the object editor, select the sun, and find the splitFadeDistances variable. I've done some playing around with this and found that usually just throwing it to "13 13 13 13" gives the best results in general. Sometimes with even larger work it needs a but further adjustment, but that shouldn't be needed here. Set that and your shadows should look vastly improved.

The next issue you may or may not notice is performance. Now, obviously you can improve this by cutting the visible distance down. But honestly, with a mountain range like this, do you want your view cut off so short when peering from the top of a mountain? Probably not. So for this, in the object editor select the terrain and find the screenError variable. The higher you make this, the quicker the terrain will lose detail over distance. Improves speed, but decreases quality, obviously. This is totally up to you to find that happy point inbetween.

Lastly, I've been hearing of some people having issues with terrains not at "0 0 0" and that are rotated. So for that reason, I just leave mine at "0 0 0" and don't rotate it to keep from having any issues I don't need.

And now of course, you can spice up the scene a bit if you like, make it a bit more flashy for screenshots. Some decent fogging, better sunlight, etc. Also, while a low screenError doesn't work for moving around, for a screenshot it certainly doesn't hurt. ;)

img190.imageshack.us/img190/982/finalb.jpg

Hopefully this tutorial has been helpful to some of you. I may write another in the future touching on the more advanced areas that I skimmed over this time around. Feel free to throw any suggestions my way. And remember, the only way to really learn how to do this yourself is to experiment. A LOT!
Page «Previous 1 2
#1
05/19/2009 (9:33 pm)
Wow, wonderful timing, I just downloaded L3DT Standard version and was about to do figure out terrains in T3D. This should make that go a bit smoother. Thanks!
#2
05/19/2009 (9:41 pm)
Awesome! Thanks for this tutorial.
#3
05/20/2009 (3:00 am)
Very Awesome. :) Nice job ... will definitely be giving this a bash this evening.
#4
05/20/2009 (1:28 pm)
Thanks. I look forward to any advanced topics you may decide to do.

For example, what we might have to do if we didn't get lucky:
Quote:It appears we got lucky and the map only called for 4 different textures. This means we can get away with just one alpha mask and thus less headache.
#5
05/20/2009 (2:04 pm)
Great Tutorial, I have been playing with this myself, but you have some suggestions that will help me improve mine. Thank you for taking the time.
#6
05/20/2009 (4:52 pm)
Great tutorial however....for those of us not using L3DT anymore and are using a combination of GeoControl, World Machine, and Grome this isn't working. I've put the information required in for my terrain to show up with the masking to be able to texture procedurally and this time instead of getting the usual error that others have been getting it's now crashing....so I'm still going to experiment however if someone has a solution to this before I do please share it with us :o) It's not like I have a slow machine, I've built a full on CAD specialised machine and it's 64 bit so I know it's not that crashing it.....anyway back to the drawing board!
#7
05/20/2009 (5:35 pm)
I have had a chance to try it out and ran into a problem.
What do I do if there are 6 channels? It gives me 2 alpha maps, how do I incorporate that into T3D?
#8
05/20/2009 (5:41 pm)
Quote:What do I do if there are 6 channels? It gives me 2 alpha maps, how do I incorporate that into T3D?

Basically just repeat the process with the second image, just click the plus and import the other map and assign the textures to it's channels. If for some reason you still have trouble, you can export the maps as greyscales and do them all 1 at a time.
#9
05/21/2009 (3:46 am)
Just tried this in the hope that it doesnt error like the other methods and it still gives the error "opacity does not match the heightmap size"
This has been logged as a bug,
http://www.garagegames.com/community/forums/viewthread/90511

so how are you getting around this............. really bugging us.
can anybody shed some light.
#10
05/21/2009 (5:51 am)
Thank you, Jacob. Eagerly awaiting any and all advanced tutorials (or stuff on how to make materials).
#11
05/21/2009 (8:34 pm)
@Richard and Shez
Have you tried this work around by Bloodknight?
http://www.garagegames.com/community/forums/viewthread/91065
#12
05/21/2009 (9:24 pm)
Tried it once before with our own stuff , and it didnt work for us , but will try again
I was kinda hoping that this would have been fixed in Beta 2,hope it has been as its a pretty major thing as well as the reversed input on the GUI

Thanks
#13
05/22/2009 (12:53 am)
Thanks it worked this time
#14
05/22/2009 (4:54 am)
This worked for me in Beta 2 ... had to move my T3D folder to a subdirectory just under C (used to be My Documents ... My Development ... Gobbo Games ... etc ... but the new location solved the Heightmap Size bug. :)

www.novogeek.org/files/twilightwars/tests/T3D_Test-0001a.png
#15
05/22/2009 (3:32 pm)
We moved the maps back one step at a time, and found that it started working when you put your opacity masks and hightmap straight in the art directory
#16
05/22/2009 (5:10 pm)
hmmm, mine just crashes whenever I try to use the alpha maps. Plain hightmap is fine, put program crashes with alpha maps. Tried moving alpha maps to the art Directory as Richard and Shez suggested, but no affect.. Any one else have this problem? It is a really big map 4096 by 4096.
#17
05/23/2009 (12:35 am)
What error do you get David?

Can you send me a screenshot: quinton[at]novogeek[dot]org

Also send me the path where you have your game directory ... let me see if I can help.

I have now done this several times and it has worked everytime. :)
#18
05/24/2009 (12:59 pm)
Using the standard version, it gives me 4 black and white alpha layers. When I try to import anything, it says "Opacity map does not match the height map size" or something to that effect.

What am I doing wrong?
#19
05/24/2009 (6:07 pm)
@Nick see comment #11
#20
05/24/2009 (7:36 pm)
I Tried that, and now it's trying to get a "Mask_A1" file, which doesn't exist. I copied Mask_Alpha1 and renamed it, and torque crashed.

Here's the contents of my folder. I exported using standard, so I'm trying to find a way to set this up correctly without the professional exporting features.
i12.photobucket.com/albums/a246/Rkynick/Contents.png
Page «Previous 1 2