Blended Terrain in TGEA from Terragen
by Russell Fincher · 03/15/2007 (7:25 pm) · 52 comments
My Experience Building Blended Terrains in TGEA Using Terragen
Edit: this plan has now been reformatted as a TDN tutorial for TGEA users.







In-game shots from the GDC demo, sans foliage.
We're just back from GDC '07, where we had a great time. We saw some old friends, made some new ones, learned a lot, and slept little.
Some of you who strolled by the Garage Games booth may have noticed the Forest Technology preview that Tom has been working on over here. I was tasked with building the terrain for that demo and learned a ton in the process, so I figured I'd put some of it down in a plan so others could learn from my experience.
The demo consisted of a 6.5 km island built from a 4k x 4k heightmap, using blended terrain (as opposed to unique terrain) in Atlas. Obviously this is way bigger than most people will ever need for terrain, so keep that in mind. First, a quick overview of my process:

Step 1 - Creating the Terrain

Over the course of a couple of weeks I tried every tool I could find. We started with Freeworld but realized that, though it is a simple, inexpensive, and somewhat full-featured solution for creating terrain lightmaps, heightmaps, and diffuse maps, the level of quality of the resulting terrain and maps were just not that great. Also, in our case we needed a 4K height map, which Freeworld simply doesn't support.
. So I decided to do the opacity map creation, initial heightmap creation, and lightmap creation all in Terragen. This was a good move, since we all know how unbelievably good Terragen is at creating stunning, realistic terrain and terrain mapping. I just had to figure out a pipeline for exporting opacity maps and lightmaps from Terragen and use them with blended terrain in Atlas. More on that later on.
. Oh yeah... and it was about this time that we decided to use blended terrain instead of unique terrain. This was kind of a logical choice since our world needed to be 6+ km, and using one single diffuse map for a world that big would look pretty terrible, even with a detail texture, so after tooling around in Terragen and realizing I could use its awesome terrain mapping for opacity maps in Atlas, that was the way to go.
By exporting hi-res opacity maps and lightmaps from Terragen, you can imply a lot of detail that really isn't in the in-game terrain. I started by creating a base terrain in Terragen using it's random terrain generator... just something close enough to what I needed.

I needed to do some custom editing of the terrain, and since Terragen's editing tools are a little slim, I knew I'd need an external editor to tweak a few things. Now there are a ton of apps out there for modifying heightmaps, and most of them are simply awful (edit: see Phil's recommendation of EarthSculptor in the comments below...). However, I found a rather excellent tool for modifying Terragen terrains called Leveller. I love this app. It's solid, versatile, can handle huge files, and has a fantastic toolset (which, btw, is very Photoshop-esque... as an artist, I appreciate that). I know most indies will frown at the price point ($150 USD), but imo Leveller is worth every penny. It imports Terragen .ter terrains, but unfortunately doesn't export them in a file that Terragen can directly use (or at least I never figured it out). Currently the only way is to export a heightmap and import it back into Terragen. But that's a simple enough process.
Step 2 - Exporting Maps for Atlas
Terragen was used to create the opacity maps, lightmap, and original heightmap for the demo. I'll break these down individually.

*Now if anyone more versed at Terragen than myself knows of a simpler way to export opacity maps or lightmaps than this, please post a comment below. Or if you know how to create a Terragen script that would do this automatically, then you'll forever be my hero.

Using blended terrain with opacity maps allows you to get a fairly detailed texture in the ground (see example at right), so we decided to use the detail texture as a broad noise to break up any repetition from the ground textures from a distance. This worked great. Quite the opposite of what it is intended for... to create a tight pattern that adds detail. Below you can see the grass from a distance with and without the broad detail texture:

Step 3 - Preparing Files for Atlas

The 16-bit .raw heightmap was pretty much game-ready. It may have needed to be flipped/rotated in Photoshop. The lightmap was opened in Photoshop, color-adjusted as stated above, and saved out as a .jpg.
For blended terrain, the opacity maps for each surface all need to be pasted into separate channels of an RGBA (standard RGB file with one alpha channel) .png file. I also had to invert the colors. The channels act as masks for the repeating terrain textures which exist as separate .jpgs. This is standard blended terrain stuff.
At this point everything was ready to go!
Step 4 - Skybox Exporting
Just a little note that there is a very easy-to-run Terragen script out there that exports Torque-ready skyboxes without the hassle of manually pointing cameras in the right direction and dealing with lighting and rendering preferences. It batch-exports all 6 sides of your skybox cube all by itself. After attempting to export them manually once or twice, I was elated to find this simple script. Go grab it here
OK then...
I didn't intend that to be so long, but if I can give someone else a better starting point than I had, then it was all worth it. Believe it or not, I skipped over a bunch of little details there. Please post a comment or email if you'd like clarification on anything. A few side notes...
Russell Fincher
Lead Artist | Co-owner
Sickhead Games
Edit: this plan has now been reformatted as a TDN tutorial for TGEA users.
We're just back from GDC '07, where we had a great time. We saw some old friends, made some new ones, learned a lot, and slept little.
Some of you who strolled by the Garage Games booth may have noticed the Forest Technology preview that Tom has been working on over here. I was tasked with building the terrain for that demo and learned a ton in the process, so I figured I'd put some of it down in a plan so others could learn from my experience.
The demo consisted of a 6.5 km island built from a 4k x 4k heightmap, using blended terrain (as opposed to unique terrain) in Atlas. Obviously this is way bigger than most people will ever need for terrain, so keep that in mind. First, a quick overview of my process:
- 1) Initial terrain generation in Terragen
- 2) Tweaking terrain in Leveller, exporting heightmap
- 3) Back in Terragen, exporting opacity maps and lightmap
- 4) Prepping of maps in Photoshop
- Ground textures - .jpgs of rock, grass, sand, and snow, most created in Genetica 256x256 - 512x512
- Detail texture - noise texture originally created in Genetica. 512x512
- Heightmap - 16 bit .raw file, 4097x4097. This is the file containing height information.
- Opacity maps - Large grayscale maps that mask or reveal a texture on the terrain. 2048x2048, all placed as channels in one RGBA file.
- Lightmap - Large texture that adds ground shadows to the Atlas terrain. 2048x2048

Step 1 - Creating the Terrain
Over the course of a couple of weeks I tried every tool I could find. We started with Freeworld but realized that, though it is a simple, inexpensive, and somewhat full-featured solution for creating terrain lightmaps, heightmaps, and diffuse maps, the level of quality of the resulting terrain and maps were just not that great. Also, in our case we needed a 4K height map, which Freeworld simply doesn't support.
. So I decided to do the opacity map creation, initial heightmap creation, and lightmap creation all in Terragen. This was a good move, since we all know how unbelievably good Terragen is at creating stunning, realistic terrain and terrain mapping. I just had to figure out a pipeline for exporting opacity maps and lightmaps from Terragen and use them with blended terrain in Atlas. More on that later on.
. Oh yeah... and it was about this time that we decided to use blended terrain instead of unique terrain. This was kind of a logical choice since our world needed to be 6+ km, and using one single diffuse map for a world that big would look pretty terrible, even with a detail texture, so after tooling around in Terragen and realizing I could use its awesome terrain mapping for opacity maps in Atlas, that was the way to go.
By exporting hi-res opacity maps and lightmaps from Terragen, you can imply a lot of detail that really isn't in the in-game terrain. I started by creating a base terrain in Terragen using it's random terrain generator... just something close enough to what I needed.
I needed to do some custom editing of the terrain, and since Terragen's editing tools are a little slim, I knew I'd need an external editor to tweak a few things. Now there are a ton of apps out there for modifying heightmaps, and most of them are simply awful (edit: see Phil's recommendation of EarthSculptor in the comments below...). However, I found a rather excellent tool for modifying Terragen terrains called Leveller. I love this app. It's solid, versatile, can handle huge files, and has a fantastic toolset (which, btw, is very Photoshop-esque... as an artist, I appreciate that). I know most indies will frown at the price point ($150 USD), but imo Leveller is worth every penny. It imports Terragen .ter terrains, but unfortunately doesn't export them in a file that Terragen can directly use (or at least I never figured it out). Currently the only way is to export a heightmap and import it back into Terragen. But that's a simple enough process.
Step 2 - Exporting Maps for Atlas
Terragen was used to create the opacity maps, lightmap, and original heightmap for the demo. I'll break these down individually.
- Heightmap - Exporting a 16-bit .raw file as your game-ready heightmap is just a simple export from the surfaces pane in Terragen or, if more terrain tweaking is done in Leveller, then the heightmap can be exported from there.
- Opacity maps - I had 4 different surfaces in my scene: 1) A base rock texture, 2) A spotty grass texture on flat areas, 3) A beach area next to water, and 4) Some snow caps on the mountains. This is where Terragen shines, in my opinion in comparison to Freeworld. The controls you have over the distribution of surfaces (or even default surface settings) are fantastic. So after setting these up to my liking, I would export them by setting all surfaces to white except for the one I'm exporting, which would be set to black. Turning off some lighting parameters and setting up the camera properly would allow me to export a top-down view of the scene that I could use as an opacity map for that specific terrain map in Atlas. I did this for all three non-base maps. (The base map was the dark rock, everything else was distributed on top of that)
- Lightmap - I exported a lightmap using a technique similar to the opacity maps, except I set all surfaces to white, and let the terrain cast shadows, so I'm left with only shadow information. Later, in Photoshop I decided to warm up the light areas by adding yellow and cool down the shadows by adding blue. It gives the shadows in the snow that realistic purple-ish tint.

*Now if anyone more versed at Terragen than myself knows of a simpler way to export opacity maps or lightmaps than this, please post a comment below. Or if you know how to create a Terragen script that would do this automatically, then you'll forever be my hero.

Using blended terrain with opacity maps allows you to get a fairly detailed texture in the ground (see example at right), so we decided to use the detail texture as a broad noise to break up any repetition from the ground textures from a distance. This worked great. Quite the opposite of what it is intended for... to create a tight pattern that adds detail. Below you can see the grass from a distance with and without the broad detail texture:

Step 3 - Preparing Files for Atlas

The 16-bit .raw heightmap was pretty much game-ready. It may have needed to be flipped/rotated in Photoshop. The lightmap was opened in Photoshop, color-adjusted as stated above, and saved out as a .jpg.
For blended terrain, the opacity maps for each surface all need to be pasted into separate channels of an RGBA (standard RGB file with one alpha channel) .png file. I also had to invert the colors. The channels act as masks for the repeating terrain textures which exist as separate .jpgs. This is standard blended terrain stuff.
At this point everything was ready to go!
Step 4 - Skybox Exporting
Just a little note that there is a very easy-to-run Terragen script out there that exports Torque-ready skyboxes without the hassle of manually pointing cameras in the right direction and dealing with lighting and rendering preferences. It batch-exports all 6 sides of your skybox cube all by itself. After attempting to export them manually once or twice, I was elated to find this simple script. Go grab it here
OK then...
I didn't intend that to be so long, but if I can give someone else a better starting point than I had, then it was all worth it. Believe it or not, I skipped over a bunch of little details there. Please post a comment or email if you'd like clarification on anything. A few side notes...
- Sickhead Games is still looking for a programmer familiar with Torque with a knack for physics for a full-time gig. Wanna get in on the indie developer lifestyle, have a say in the products created, and bake in the perilous heat of Dallas summers? Give us a shout. We're considering the intern thing as well. If you even think you might be interested, please send us an email and let's chat.
- I just put up some free 2D art good for casual games on the TGB forums this week. Hope someone finds it useful. (edit: sorry, access to that forum is TGB-owners only... here's a preview for anyone else interested)
Russell Fincher
Lead Artist | Co-owner
Sickhead Games
About the author
Art Lead at Sickhead Games focused on dev tools and prototyping, instructor/advisor at several Dallas colleges and universities, Associate Developer with GarageGames, moderator at gameproducer.net, champion of avant-garde game art at uncommonassembly.com.
#2
We are far from Geo-Terrain (TGE legacy terrain format).
The result is as good as the process to get it in game is complex...
Thanks for the reading. 8-)
03/15/2007 (8:04 pm)
Woot. 8-/We are far from Geo-Terrain (TGE legacy terrain format).
The result is as good as the process to get it in game is complex...
Thanks for the reading. 8-)
#3
03/15/2007 (8:37 pm)
Russell, check out www.earthsculptor.com for an alternative that I've been playing with. Does 4k x 4k fine and actually works pretty well as terrain painter, lightmapper and blender etc.
#4
03/15/2007 (8:40 pm)
Sounds interesting, Phil... I'll check it out. Thanks!
#5
03/15/2007 (8:43 pm)
Gorgeous! The more reads on doing Atlas terrains, the better! Leave no detail unturned!
#6
03/15/2007 (9:18 pm)
Great .plan, Russell! Thanks.
#7
03/15/2007 (9:45 pm)
Wonderful .plan!
#8
03/15/2007 (9:56 pm)
You know, I have to admit... part of the reason I posted this is so I'd have a place to look the next time I tried to do this a realized I'd forgotten it all. ;)
#9
03/15/2007 (10:25 pm)
That is sexy!
#10
Fredrik S
03/15/2007 (10:41 pm)
Fantastic plan. The skybox / terragen script comes as a god send. Great stuff!Fredrik S
#11
03/15/2007 (11:11 pm)
Its good to see someone else using Genetica. Its such a great tool for creating original textures, particularly organic/natural ones. Ah, and great work!
#12
03/15/2007 (11:19 pm)
Awesome!!!
#13
03/15/2007 (11:43 pm)
Hey Jerane, I used Genetica for almost all the art in the Adventure Kit also. It works for realistic and more subjective textures. I love having Genetica around. :)
#14
03/16/2007 (9:32 am)
wow!!
#15
03/16/2007 (11:18 am)
I second the earthsculptor suggestion. Actually could be a tweaking intermediary tool for stuff like path's, leveling, etc.. Or just used on its own. Very cool toolset.
#16
03/16/2007 (12:26 pm)
Well, maybe one of you earthsculptor users can put up something about how to use it :) It does look neat!
#17
03/16/2007 (3:28 pm)
what version of Terragen are you using?
#18
03/16/2007 (4:01 pm)
I'm using the current version of v.09x... just picked it up a month or two ago. I haven't tried any of the 2.0 stuff, and probably won't unless it will offer better terrain sculpting and painting. I'd love to have one less link in the chain and forego the Leveller step.
#19
now, if i get to know how to use normal maps of detail maps, that would just be terein heaven:D
03/16/2007 (5:38 pm)
nice, a lot of usefull informastion in this postnow, if i get to know how to use normal maps of detail maps, that would just be terein heaven:D
#20
also, can a blended terrain support multiple opacity maps files allowing more than 4 blended textures?
03/16/2007 (5:54 pm)
what do you mean by blended terrain as opposed to unique terrain?also, can a blended terrain support multiple opacity maps files allowing more than 4 blended textures?
Torque 3D Owner Aaron E