Previous Blog Next Blog
Prev/Next Blog
by date

Blended Terrain in TGEA from Terragen

Blended Terrain in TGEA from Terragen
Name:Russell Fincher
Date Posted:Mar 15, 2007
Rating:5.0 out of 5
Public:YES
Comments:YES
RSS Feed:GarageGames Blog feedor Subscribe with .
Profile Page:View profile page for Russell Fincher

Blog post
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:

  • 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

And a list of the files that were created through that process:

  • 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)


Take care.

Russell Fincher
Lead Artist | Co-owner
Sickhead Games

Recent Blog Posts
List:01/28/08 - CrazyBump = Better, Faster Art
10/03/07 - Sickhead Games is hiring!
03/15/07 - Blended Terrain in TGEA from Terragen
10/21/06 - Adventure Kit update 1.1
09/08/06 - Adventure Kit post mortem
06/21/06 - Update: Sickhead TGB Tile Pack
04/18/06 - Sickhead TGB Tile Pack #1
06/06/05 - Plan for Russell Fincher

Submit ResourceSubmit your own resources!

Aaron Ellis   (Mar 15, 2007 at 19:55 GMT)
Wow! Beautiful work Russell. Thank you for posting this.

Stephan (viKKing) Bondier   (Mar 15, 2007 at 20:04 GMT)
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-)

Phil Carlisle   (Mar 15, 2007 at 20:37 GMT)
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.

Russell Fincher   (Mar 15, 2007 at 20:40 GMT)
Sounds interesting, Phil... I'll check it out. Thanks!

Dave Young   (Mar 15, 2007 at 20:43 GMT)
Gorgeous! The more reads on doing Atlas terrains, the better! Leave no detail unturned!

Pat Wilson   (Mar 15, 2007 at 21:18 GMT)
Great .plan, Russell! Thanks.

Timothy Aste   (Mar 15, 2007 at 21:45 GMT)
Wonderful .plan!

Russell Fincher   (Mar 15, 2007 at 21:56 GMT)
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. ;)

Stefan Lundmark   (Mar 15, 2007 at 22:25 GMT)   Resource Rating: 5
That is sexy!

Affectworks   (Mar 15, 2007 at 22:41 GMT)
Fantastic plan. The skybox / terragen script comes as a god send. Great stuff!

Fredrik S

Jerane Alleyne   (Mar 15, 2007 at 23:11 GMT)
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!

Anton Bursch   (Mar 15, 2007 at 23:19 GMT)
Awesome!!!

Russell Fincher   (Mar 15, 2007 at 23:43 GMT)
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. :)
Edited on Mar 15, 2007 23:43 GMT

James Laker (BurNinG)   (Mar 16, 2007 at 09:32 GMT)
wow!!

Steve Flowers   (Mar 16, 2007 at 11:18 GMT)
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.

Dave Young   (Mar 16, 2007 at 12:26 GMT)
Well, maybe one of you earthsculptor users can put up something about how to use it :) It does look neat!

James Brad Barnette   (Mar 16, 2007 at 15:28 GMT)
what version of Terragen are you using?

Russell Fincher   (Mar 16, 2007 at 16:01 GMT)
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.
Edited on Mar 16, 2007 17:46 GMT

Florian   (Mar 16, 2007 at 17:38 GMT)
nice, a lot of usefull informastion in this post
now, if i get to know how to use normal maps of detail maps, that would just be terein heaven:D

Sean H.   (Mar 16, 2007 at 17:54 GMT)
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?

Russell Fincher   (Mar 16, 2007 at 18:02 GMT)
Hey Sean: I'm no expert, still pretty new to this... but unique terrain would be one huge diffuse map to color the entire terrain, while blended terrain uses relatively small repeating textures with large opacity maps to mask or reveal them. This terrain, being 6.5 kilometers square, would have required an enormous diffuse map to give any detail, so enormous that it was an unrealistic option.

Also, I'm just not partial to the traditional 'blurry base texture and tight detail texture' look that one unique map would give. I never thought it was that believable, and it requires every surface to have the same detail texture.

As far as I know, you are currently restricted to 4 blended textures, the four channels in the RGBA file. But this could probably be hacked to provide more. It's just not supported by default.
Edited on Mar 16, 2007 18:07 GMT

Jeremiah Fulbright   (Mar 16, 2007 at 18:18 GMT)
I'd be more curious about the Blended Terrain performance versus Unique Terrain in this case. As all of the older results showed the overheard on Blended terrains were still fairly high

Josh Williams   (Mar 16, 2007 at 18:37 GMT)
Hey Russ, great post! Thanks. Could you convert this into a TDN article? That'd ROCK.

James Brad Barnette   (Mar 16, 2007 at 18:42 GMT)
Man terragen is frustrating me is there any other format that can be used to generate altas terrain other than raw? like 16PNG or something?

I'm using Vue 5 Infinite to create my terrain.

or maybe it is something I'm doing between photoshop and terragen but I can't get anything usable into terragen.

every time I try to take something into terragen it looks all interlaced and distorted to hell. any pointers you can give on how you are getting files back and forth?
Edited on Mar 16, 2007 19:08 GMT

Russell Fincher   (Mar 16, 2007 at 18:49 GMT)
Jeremiah: I haven't done any side-by-side testing, but the performance hit from the terrain wasn't that bad. I've seen anywhere from 45 fps - 80 fps during development, depending on machine and what else we were testing at the time (ane we were using a 4k heightmap and 2k opacity and lightmaps). If all goes as planned we'll be doing a lot more of this kind of work this year and I'll post some numbers.

Josh: Will do! :)
Edited on Mar 16, 2007 20:24 GMT

Russell Fincher   (Mar 16, 2007 at 18:55 GMT)
@ James: I think I know what you're talking about. I had the same problem a few times and I believe it's all about how you open and save out your .raw file from Photoshop. Except for the dimensions of your file, you should open and save it with these settings:





Was the problem you had when you imported your heightmap into Terragen that it was just a bunch of noise, so it created like a thousand skinny peaks?
Edited on Mar 16, 2007 20:28 GMT

Erik Madison   (Mar 17, 2007 at 11:09 GMT)
Mind posting what you did with the shader/code to get the broad detail texturing?

Tom Spilman   (Mar 17, 2007 at 15:06 GMT)   Resource Rating: 5
@Erik - Just added this fix and set the repeat to a low number... like 3 times across the entire terrain.

Russell Fincher   (Mar 19, 2007 at 22:06 GMT)
For anyone still watching this plan... as requested, I reformatted it as a TDN article, adding a number of specifics.

It's in the TSEA section of TDN... I'm curious to know if it can be accessed by TGE owners as well...
Edited on Mar 19, 2007 22:08 GMT

Michael Perry   (Mar 20, 2007 at 16:14 GMT)   Resource Rating: 5
I wasn't able to access it as a TGE owner. =(

So, since I can't access it I was wondering if you could answer a question about setting up the opacity maps in Terragen?

I've generated the terrain and tweaked the camera/lighting/atmosphere options to get what I think would be acceptable for rendering the proper image. I was wondering what your Surface Map Pane looked like before you exported


Surface Map
|
--base rock
|
--Grass
|
--Beach
|
--Snow

Is that your basic layout? Also, care to throw a non-artist a few sample values used for the Advanced Distribution pane of the surfaces? How about the bumpiness and terrain mimic feature?

The general usage stuff I've been reading up myself, I'm just wondering about those particular settings and how they would affect the final rendered version in the engine itself.

Russell Fincher   (Mar 20, 2007 at 16:45 GMT)
You could do this a number of ways, but my Surfaces tree was different each time I rendered out an opacity map. I believe I always put the one I was rendering, the black one, on top (at the bottom of the list). But again it would work a few different ways.

As far as the Advanced Distribution pane... I gotta tell you, every time I tried to go through those Terragen tutorials, my eyes would start glazing over. I kinda learned through trial and error. But I usually left the "bumpiness" and "terrain mimic" settings at their defaults and pretty much just used "Coverage", "Altitude Constraints", and "Slope Constraints" to do everything. Someday I'll go back through those tutorials and maybe learn something, heh.

Sent an email to your gmail account.

Russell Fincher   (Mar 20, 2007 at 19:47 GMT)
OK, we don't have a TGE license, so I can't put this tutorial on the TGE section of TDN. They're currently only up on the TSEA side. Looking for someone with a TGE license that I can hand the tutorial assets over to that can post them on TGE-TDN.

Edit: It looks like ONE of us here at Sickhead Games has a TGE license, but apparently it isn't me. So I'll get Tom to post it. But it still looks like it should be currently available to TGE owners. Can I get a second opinion?
Edited on Mar 20, 2007 20:03 GMT

Stephan (viKKing) Bondier   (Mar 20, 2007 at 20:11 GMT)
@Russel: here TGB/TGE/TGEA indie licenses owner. 8-)
Will be happy to do it for you.

Russell Fincher   (Mar 20, 2007 at 21:13 GMT)
Thanks Stephan, I'm just going to do it over here on Tom's machine when I get a minute. I didn't realize he had a license. Thanks, though! :)

Stephan (viKKing) Bondier   (Mar 20, 2007 at 21:35 GMT)
You're welcome Russell 8-)

James Brad Barnette   (Mar 22, 2007 at 03:40 GMT)
I didn't know this applied to TGE? I mean has Atlas been ported or something and I missed it?
Edited on Mar 22, 2007 03:41 GMT

Michael Perry   (Mar 22, 2007 at 12:21 GMT)   Resource Rating: 5
@James - No, you didn't miss anything. Russell and his team are just making this process, Atlas terrain creation using 3rd party tools,available to non-TGEA license holders. I think this is wonderful, because it can be quite useful for artists who are working on a TGEA project.

I'm a TGE user, and I've been working with this process for a few days now. Using these steps, if I can get a nice terrain in the TGEA demo, my company might switch engines.

Russell Fincher   (Mar 22, 2007 at 15:15 GMT)
Hm, I may be showing my ignorance of TGE here... so this tutorial would be irrelevent to TGE owners? I'm not sure it makes sense to congest the TGE-TDN with TGEA information.

Michael Perry   (Mar 22, 2007 at 15:24 GMT)   Resource Rating: 5
@Russell - Not at all, this is a good way for non TGEA owners to test out one of the engine's biggest features before making a purchase. The demo doesn't cover the process of generating and implementing Atlas terrain, so this is a great resource to have to preview TGEA.

Jason Nabors   (Apr 06, 2007 at 03:14 GMT)
There is a tool called Wilbur which I use. It has the ability to open terragen(.ter) files, manipulate them and save the changes. One thing I like is the many file formats it supports. It can do things like open a .ter file, resize it, and save it. Or open a picture file like a bmp and save it as a .ter ect.... I could go on and on about it, but you should just dive in and check it out yourself.

Wilbur

Deception Games   (May 10, 2007 at 16:40 GMT)
Nice tutorial, but for new people its lacking a lot of details

Russell Fincher   (May 10, 2007 at 19:16 GMT)
Thanks for your input, Deception... this plan posting was just intended to be an overview of the methods I've been working with while specifically using Terragen with Atlas, from content-creation perspective. A proper, more detailed description of these techniques can be found on TDN here. Though it does assume you understand the basics of Terragen.

Plus, I'm always glad to answer any questions here, or privately at the email address on my profile page. And if your questions are over the head of a humble artist, my colleague Tom here at Sickhead Games can certainly add his input about implementing this art into Atlas and Torque.
Edited on May 10, 2007 19:27 GMT

Mahmudul Hasan Sohag   (Oct 09, 2007 at 19:19 GMT)
hi,
I am new to tse. I have created some terrain using atlas technology but I can not create a detail map like urs. Its amazing..One question how can I create the 4th channel of a image file?I have tried using ur tutorial but could not make it work.after saving the image file in .png when I reload it photoshop again it seems there is no alpha channel.so I have to use 3 textures only. :( Thanks for any help.

James Brad Barnette   (Oct 10, 2007 at 02:34 GMT)
yeah photoshop handles alphas as transparency. so you don't see the alpha channel but it is there.

Chris D. Walker   (Mar 06, 2008 at 14:06 GMT)
That's reallly cool! Does this technique work in the regular Torque Engine as well, I wonder?

James Brad Barnette   (Mar 06, 2008 at 16:20 GMT)
no this is for Atlas Terrain system and there is not atlas terrain in TGE

You must be a member and be logged in to either append comments or rate this resource.