Using L3DT to create Atlas terrain
by Jacob Dankovchik · 08/30/2005 (1:41 am) · 19 comments
With the creation of the Atlas terrain for the Torque Shader Engine, a new difficulty came for developers and that was creating high quality terrains for it without having to spend money. I eventually happened to stumble across a program called L3DT. This is a free program with no restrictions on use, you can use it on free or commercial projects.
The webiste for it can be found here: www.bundysoft.com/L3DT/
With L3DT the two most useful creation methods I found were to either have it randomly generate a terrain based on the values you put in, or to draw your own. The random method is good for something fast and easy that doesn't need a specific design. But the blank method is quite easy to pick up and can pay off very quickly.
One quick note is that sometimes L3DT crashes for me right when it finished calculating water, which is the step after the heightmap. You'll understand where thats at in notime. But a good idea is to save all right before you begin water calculation. Infact, even if you skip it, its a good idea to save all after the heightmap as it would be a shame to lose it after the time it can take to make.
Before you begin it is good to have an idea of what size terrain you want. When you create your new map, you should try to match the resolution with your map size as much as possible as this will make things come up much better looking. For example, if you wanted a terrain 1 kilometer on each side you would go with a 1024X1024 design map. Do not get carried away on the resolution though. As the site explains, L3DT can do heightmaps up to 32,768 pixels, but you will have to export it all out in chunks when you save it and it will be very rough to try to work on. Staying at or below 4,096 would be a good idea.
To figure out your terrain size for a heightmap, multiply your heightmap size by your squareSize. I warn you not to use a squareSize over 2 if possible though because your terrains may end up becomming stretched and if you have sharp mountains and valleys and lots of detail, it will all become dull boring hills. You can of cource help fix this with a bigger height scale but this makes everything much taller too so everything reaches further up into the sky.
If for some reason you need to go over a 2 squareSize and are at a 4,096 heightmap, I recommend making smaller scale features on the heightmap. If you are using the automatic random generation, this is done by a slider bar for scale. If you are hand-drawing things, you will have to draw things in smaller scale by simply putting more variation of features like smaller patches of light and heavy roughness. When you make smaller scale features, stretching your terrain won't be as bad because now the dramatically sharp mountain you made is stretched out to a more resonable slope.
Things can still come out rather odd this way and you can always explore higher resolution maps. Doing that is explained on the site.
One thing to note with your terrains is water. Texturing in L3DT is based on climate files which determine which texture goes where and why. When you move the average altitude slider all the way to land, or when you create a design map with no water and high mountains, you may notice a lot of snow may appear on your texture. There have been times myself in which this snow appeared and I did not want it there, but I still wanted my very large mountains. To do this, don't have any land. Instead, build the design map completely underwater, or if using the generator, set the slider to all sea.
After you make the design map with water over it all, you make the heightmap. Normally after the heightmap comes water calculation, however you want to skip this. Instead you go straight to the attributes map. Since you skipped sea and lake calculations, the attributes map is calculated for all land. But since you made it all below sea level, its low-lying land and so no snow will appear, but you can still have those large mountains.
Next is your lightmap. First you create terrain normals, which comes out as a normal map. Nothing to worry about in this step. In the next step comes the lightmap calculations. This is where every little pixel on the heightmap really starts to count. If you left water in your map, you may want to uncheck the box that says "water effects" in the lightmap window. This makes a very dark blue coloring where water is at, which you may not want for TSE. If you uncheck it the terrain will be lit normally in those spots and it will be textured properly too, as if water was there. I personally always uncheck that because looking at the sandy bottom of an ocean is better then some near-black splotch.
The direction and angle of sunlight, you can make whatever you like. Play with that and see what you perfer.
The slider for sunlight/ambient ratio basically acts as what determines your ambient light power. The further up you slide it, the brighter your shadows will be from the increase in ambient light, and darker if you slide it down.
I normally leave the colors all the same and dont mess with any other settings. I never really tried playing with them, but you can give it a shot. They don't have any huge bearing on TSE itself anyhow.
One important thing to note: You may notice your lightmap looks rather bland. It has the mountains and major details, but the ground itself looks as smooth as a baby's bottom. This is because you don't have any or enough fractal roughness. You'll want to go back to the design map level and add this in. You can add it without having to redo your entire deisgn map. Simply open the diesgn map pencil (as explained on the site) and uncheck everything except "fractal" under the title Roughness. Move that up to wherever you like, may want to check relative, and click apply to all. This will cover the entire map with the chosen roughness. Or instead of clicking apply to all, you can draw it on with the pencil where you like. Or you can just redo it again through the random generator and just set the slider to where you like there. Be careful not to put it too high though or things could turn into a real mess. After you change the roughness you'll have to redo the heightmap, good idea to redo the water if you did it before, and redo the other maps too. On the good side, you'll now notice that your lightmap comes equiped with neat little ground-level details and now looks rough like untamed terrain. This can be a major point in making that beautiful terrain.
Next comes the texture map, where everything comes together. By default the texture comes out at the same resoltuion as the heightmap. You can turn this up however with the TX/HF ratio. At the moment of writing this, the current version of L3DT can only go so large, but with a soon to come update the limits will pretty much be totally lifted. But either way, after a certan resoltuion you'll have to save it as a mosiac.
Assuming that you went with normal-res single image texture, I'll now explain how to get the whole deal into Torque.
First, right click in the window and select heightfield. Then goto file, export, active map. I perfer to select RAW as it is the easiest to work from. After you export the heightmap, right click and select texture. File, export, active map. For the texture I go with jpg because it comes out just fine and bmp takes much longer to export and work with.
After its all exported, open up your RAW heightmap that was exported. Its exported as a single channel 16-bit. For some reason L3DT fliips it horizontally when exporting a RAW, so just flip it back. After that, size it up by 1 pixel from its current size. Save, and thats ready. Next cut (or copy, you choose) the RAW and texture and place them in whichever folder you want for Torque. Next comes the final working of them.
Normally to start I go with a squareSize of 2, heightScale of 0.00390625 (1/256), error metric of 2, and a tree depth of 4.
The squareSize, as explained above, easily works as 1 too. I normally do 2 only because it usually works out good, but of cource sometimes it doesn't. When you make your squareSize smaller, you may need to turn down your heightScale because you could end up with features far too high for as small as they are.
When you get an error saying it exceeded the vertex limit and to try a deeper tree, go deeper when working with a large heightmap as you may need it, but do not go too deep with it. The treeDepth can greatly increase load times and make things a big more unpleasant. I usually use a 6 for 4096 and 4 for smaller ones.
The better route is to increase your error metric. Don't be afraid to really jump it up. After you get that up high enough to work, start to lower it bit by bit until you find the lowest working number. Unless of cource you want the lower detail, then keep it up.
For the texture, nothing hard here. Its just a good idea to get the treeDepth's to match on the texture and terrain.
And thats about it for the basic into to L3DT and TSE. You will find you learn the most by simply expirimenting and messing around. Change some values, see what happens, and read the site. They have a simply excellant tutorial on making a fjord by hand. This was my first time trying something by hand and it came out very well. I suggest you download this tool and try it out.
Also, be sure to check in the site often. Bookmarking it would be a very good idea. The url is scheduled to be changed soon at the time of this writing and there is also set to be some big updates comming, mainly in the texture department. Try this wonderfull and FREE tool out! I did and I now consider it one of my most important peices of software!
The webiste for it can be found here: www.bundysoft.com/L3DT/
With L3DT the two most useful creation methods I found were to either have it randomly generate a terrain based on the values you put in, or to draw your own. The random method is good for something fast and easy that doesn't need a specific design. But the blank method is quite easy to pick up and can pay off very quickly.
One quick note is that sometimes L3DT crashes for me right when it finished calculating water, which is the step after the heightmap. You'll understand where thats at in notime. But a good idea is to save all right before you begin water calculation. Infact, even if you skip it, its a good idea to save all after the heightmap as it would be a shame to lose it after the time it can take to make.
Before you begin it is good to have an idea of what size terrain you want. When you create your new map, you should try to match the resolution with your map size as much as possible as this will make things come up much better looking. For example, if you wanted a terrain 1 kilometer on each side you would go with a 1024X1024 design map. Do not get carried away on the resolution though. As the site explains, L3DT can do heightmaps up to 32,768 pixels, but you will have to export it all out in chunks when you save it and it will be very rough to try to work on. Staying at or below 4,096 would be a good idea.
To figure out your terrain size for a heightmap, multiply your heightmap size by your squareSize. I warn you not to use a squareSize over 2 if possible though because your terrains may end up becomming stretched and if you have sharp mountains and valleys and lots of detail, it will all become dull boring hills. You can of cource help fix this with a bigger height scale but this makes everything much taller too so everything reaches further up into the sky.
If for some reason you need to go over a 2 squareSize and are at a 4,096 heightmap, I recommend making smaller scale features on the heightmap. If you are using the automatic random generation, this is done by a slider bar for scale. If you are hand-drawing things, you will have to draw things in smaller scale by simply putting more variation of features like smaller patches of light and heavy roughness. When you make smaller scale features, stretching your terrain won't be as bad because now the dramatically sharp mountain you made is stretched out to a more resonable slope.
Things can still come out rather odd this way and you can always explore higher resolution maps. Doing that is explained on the site.
One thing to note with your terrains is water. Texturing in L3DT is based on climate files which determine which texture goes where and why. When you move the average altitude slider all the way to land, or when you create a design map with no water and high mountains, you may notice a lot of snow may appear on your texture. There have been times myself in which this snow appeared and I did not want it there, but I still wanted my very large mountains. To do this, don't have any land. Instead, build the design map completely underwater, or if using the generator, set the slider to all sea.
After you make the design map with water over it all, you make the heightmap. Normally after the heightmap comes water calculation, however you want to skip this. Instead you go straight to the attributes map. Since you skipped sea and lake calculations, the attributes map is calculated for all land. But since you made it all below sea level, its low-lying land and so no snow will appear, but you can still have those large mountains.
Next is your lightmap. First you create terrain normals, which comes out as a normal map. Nothing to worry about in this step. In the next step comes the lightmap calculations. This is where every little pixel on the heightmap really starts to count. If you left water in your map, you may want to uncheck the box that says "water effects" in the lightmap window. This makes a very dark blue coloring where water is at, which you may not want for TSE. If you uncheck it the terrain will be lit normally in those spots and it will be textured properly too, as if water was there. I personally always uncheck that because looking at the sandy bottom of an ocean is better then some near-black splotch.
The direction and angle of sunlight, you can make whatever you like. Play with that and see what you perfer.
The slider for sunlight/ambient ratio basically acts as what determines your ambient light power. The further up you slide it, the brighter your shadows will be from the increase in ambient light, and darker if you slide it down.
I normally leave the colors all the same and dont mess with any other settings. I never really tried playing with them, but you can give it a shot. They don't have any huge bearing on TSE itself anyhow.
One important thing to note: You may notice your lightmap looks rather bland. It has the mountains and major details, but the ground itself looks as smooth as a baby's bottom. This is because you don't have any or enough fractal roughness. You'll want to go back to the design map level and add this in. You can add it without having to redo your entire deisgn map. Simply open the diesgn map pencil (as explained on the site) and uncheck everything except "fractal" under the title Roughness. Move that up to wherever you like, may want to check relative, and click apply to all. This will cover the entire map with the chosen roughness. Or instead of clicking apply to all, you can draw it on with the pencil where you like. Or you can just redo it again through the random generator and just set the slider to where you like there. Be careful not to put it too high though or things could turn into a real mess. After you change the roughness you'll have to redo the heightmap, good idea to redo the water if you did it before, and redo the other maps too. On the good side, you'll now notice that your lightmap comes equiped with neat little ground-level details and now looks rough like untamed terrain. This can be a major point in making that beautiful terrain.
Next comes the texture map, where everything comes together. By default the texture comes out at the same resoltuion as the heightmap. You can turn this up however with the TX/HF ratio. At the moment of writing this, the current version of L3DT can only go so large, but with a soon to come update the limits will pretty much be totally lifted. But either way, after a certan resoltuion you'll have to save it as a mosiac.
Assuming that you went with normal-res single image texture, I'll now explain how to get the whole deal into Torque.
First, right click in the window and select heightfield. Then goto file, export, active map. I perfer to select RAW as it is the easiest to work from. After you export the heightmap, right click and select texture. File, export, active map. For the texture I go with jpg because it comes out just fine and bmp takes much longer to export and work with.
After its all exported, open up your RAW heightmap that was exported. Its exported as a single channel 16-bit. For some reason L3DT fliips it horizontally when exporting a RAW, so just flip it back. After that, size it up by 1 pixel from its current size. Save, and thats ready. Next cut (or copy, you choose) the RAW and texture and place them in whichever folder you want for Torque. Next comes the final working of them.
Normally to start I go with a squareSize of 2, heightScale of 0.00390625 (1/256), error metric of 2, and a tree depth of 4.
The squareSize, as explained above, easily works as 1 too. I normally do 2 only because it usually works out good, but of cource sometimes it doesn't. When you make your squareSize smaller, you may need to turn down your heightScale because you could end up with features far too high for as small as they are.
When you get an error saying it exceeded the vertex limit and to try a deeper tree, go deeper when working with a large heightmap as you may need it, but do not go too deep with it. The treeDepth can greatly increase load times and make things a big more unpleasant. I usually use a 6 for 4096 and 4 for smaller ones.
The better route is to increase your error metric. Don't be afraid to really jump it up. After you get that up high enough to work, start to lower it bit by bit until you find the lowest working number. Unless of cource you want the lower detail, then keep it up.
For the texture, nothing hard here. Its just a good idea to get the treeDepth's to match on the texture and terrain.
And thats about it for the basic into to L3DT and TSE. You will find you learn the most by simply expirimenting and messing around. Change some values, see what happens, and read the site. They have a simply excellant tutorial on making a fjord by hand. This was my first time trying something by hand and it came out very well. I suggest you download this tool and try it out.
Also, be sure to check in the site often. Bookmarking it would be a very good idea. The url is scheduled to be changed soon at the time of this writing and there is also set to be some big updates comming, mainly in the texture department. Try this wonderfull and FREE tool out! I did and I now consider it one of my most important peices of software!
#2
You mentioned
"After its all exported, open up your RAW heightmap that was exported."
Use what to open the raw file?
And how to you "flip" the RAW heightmap?
08/28/2005 (11:22 pm)
Hi Jacob,You mentioned
"After its all exported, open up your RAW heightmap that was exported."
Use what to open the raw file?
And how to you "flip" the RAW heightmap?
#3
And to flip it, just find the option to rotate your image and there should be a flip vertical, or mirror vertical, or somethin. If not, just rotate it 180 degrees.
08/29/2005 (3:04 am)
Whatever image program you use that can open RAW's. Myself, I use photoshop, works easily.And to flip it, just find the option to rotate your image and there should be a flip vertical, or mirror vertical, or somethin. If not, just rotate it 180 degrees.
#5
08/30/2005 (4:39 am)
Very good how-to. Like it.
#6
08/31/2005 (9:01 am)
Excellent resource and walkthrough... Much appreciated!
#7
08/31/2005 (10:02 pm)
nice job...it was a bit confusing for me but thats because I am new at using TSE and any terrain editor...nice job it got me through and i got good results...thanks
#8
Does this mean literally take a 1024x1024 and in photoshop for example go to image scale and make it 1025x1025?
If so, whats the purpose of this?
Thanks!
10/25/2005 (11:26 am)
"After that, size it up by 1 pixel from its current size"Does this mean literally take a 1024x1024 and in photoshop for example go to image scale and make it 1025x1025?
If so, whats the purpose of this?
Thanks!
#9
;p
Seriously the atlas chunker assumes that an image has one extra pixel per side. I'm sure that will be removed int
future versions.
~neo
10/25/2005 (11:34 am)
@ian: It's an additional set of pixels that ben uses to do nefarious things. He hides small mouse traps in there.;p
Seriously the atlas chunker assumes that an image has one extra pixel per side. I'm sure that will be removed int
future versions.
~neo
#10
11/13/2005 (7:25 am)
This is nothing short of amazingly helpful. Thanks dude!
#11
Is there a way we can input our own texture to be tiled onto the terrain?
11/16/2005 (5:45 am)
This program is much more useful for TSE terrain building than Terragen in my opinion. Excellent resource!Is there a way we can input our own texture to be tiled onto the terrain?
#12
Go to L3DT\Resources\Textures, and flip through those folders and add what you like. If you add a texture instead of replacing it, you'll have to add its usage in the climate file.
To do that, go back a folder and you'll see a climates folder. Open that and you'll see a bunch of "CLI" files. Open those with notepad and you'll see all the texturing information. You can attempt to figure this out yourself or just go to the L3DT site. Theres plenty of info there.
11/16/2005 (12:28 pm)
Sure is!Go to L3DT\Resources\Textures, and flip through those folders and add what you like. If you add a texture instead of replacing it, you'll have to add its usage in the climate file.
To do that, go back a folder and you'll see a climates folder. Open that and you'll see a bunch of "CLI" files. Open those with notepad and you'll see all the texturing information. You can attempt to figure this out yourself or just go to the L3DT site. Theres plenty of info there.
#13
I've found that mixed with Photoshop, this is a good tool. It is good at previz from photoshop and then making some minor changes and building your terrain file from there.
11/16/2005 (6:07 pm)
Thanks! Wasn't at home when I asked the question there so was kinda dumb, heh.I've found that mixed with Photoshop, this is a good tool. It is good at previz from photoshop and then making some minor changes and building your terrain file from there.
#14
When I tried to reopen the RAW, I noticed Photoshop thought the file was bigger than it should be.
I opened it up in a hex editor, and I discovered that Photoshop had dumped some sort of header.
I opened/saved it in Photoshop CS2.
Not sure if anyone else had this problem, or how to overcome it other than using a hex editor to remove the offending bytes.
(header it dropped in was 20934 bytes)
edit: I guess I assumed a bit too much... deleting the header did not resolve the problem I was having. I guess I'll keep playing with it :P
02/02/2006 (5:09 pm)
I was just trying this today, but I was having some problems converting the RAW to CHU. It would take 10+ minutes, and I'd just kill it. Eventually I let it run for over and hour and when I came back, TSE had crashed.When I tried to reopen the RAW, I noticed Photoshop thought the file was bigger than it should be.
I opened it up in a hex editor, and I discovered that Photoshop had dumped some sort of header.
I opened/saved it in Photoshop CS2.
Not sure if anyone else had this problem, or how to overcome it other than using a hex editor to remove the offending bytes.
(header it dropped in was 20934 bytes)
edit: I guess I assumed a bit too much... deleting the header did not resolve the problem I was having. I guess I'll keep playing with it :P
#15
He needs to know how to figure out the leafe size in the importer for the texture. He didn't see any info in any of the Tutorials on this around and can't seem to import the Terrain without it. he says thanks in advance for the help.
Shon
02/05/2006 (7:35 am)
My artist needs to know sometthing if possible,He needs to know how to figure out the leafe size in the importer for the texture. He didn't see any info in any of the Tutorials on this around and can't seem to import the Terrain without it. he says thanks in advance for the help.
Shon
#16
Thats 2^4-1 * leafSize = 2048.
8*leafSize = 2048
leafSize = 256.
02/05/2006 (8:25 am)
you have to pick a number where 2^treeDepth-1 * leafSize = imageSize. So, for example, a 2048 image with a 4 treeDepth. Thats 2^4-1 * leafSize = 2048.
8*leafSize = 2048
leafSize = 256.
#18
03/22/2006 (12:42 pm)
Has anyone had good experience putting in larger sized textures? For example, I have a 4096x4096 terrain, I created its texture map as 8192x8192, I want it to look very nice. It seemed to work, but I would like better resolution. I didn't do any 'mosaic' files, so I'm not sure how to go about this. Do I have to convert the textures separately?
#19
01/21/2007 (9:00 am)
hmmm, i tried it and it didnt work, well, i got the *.chu and *.tqt but when i try to put it in a level i only see a long white spike and nothing more :s 
Torque Owner Neo Binedell
on the heightmap menu.
Also, an easy way to get your height scale is to divide your required height range by 65535.
e.g. 1200m range / 65535 == 0.01831
~neo