Game Development Community

Finally got some good looking Atlas2 terrain...

by Marek Gorecki · in Torque Game Engine Advanced · 02/22/2007 (6:56 pm) · 39 replies

After spending many days trying to get TGEA and atlas2 terrains looking good close-up (i.e. for FPS/3rd person RPG solutions), and reading everything I can find on TDN/forums on getting em to look good, I finally managed to get stuff looking to my satisfaction. I personally don't like detail textures, especially on top of blurry terrain textures.

Used L3DT to make the terrain/images, Photoshop for the opacity map, Atlas2 Blended terrain, some minor code and script tweaks here and there.

Anyway, here's a sample image of what I'm talking about:
www.saladstudios.com/mp-sample.jpg
If anyone is interested in the specific details, I can make a blog post or just reply here with exact info on what I did, otherwise I'll keep hammering away at my stuff (next step for me is adding support for 16-blended textures... 4 just ain't enough!).

Cheers,

Marek

About the author

Recent Threads

Page «Previous 1 2
#1
02/22/2007 (7:11 pm)
I for one would be extremely happy to hear how you accomplished this :)

Looks excellent:))) Congrats

Regards

Graham Evans
#2
02/22/2007 (7:15 pm)
Hey that's looking real good. You know... I used to think that a Blended terrain couldn't be edited afterward, but now I'm starting to think about it. Couldn't it be edited by selected one your import textures as a "brush" and then "painting" with it on the blendmap? You would be limited by the textures available... but it should work, shouldn't it?

Ben, I could use an answer on this one. We've been working with Unique terrains under the assumption that was the only kind that could be edited (though none are editable right now). Is is theoretically possible that Blended terrains could be edited? If so, I'll jump over to blended right now.
#3
02/22/2007 (7:41 pm)
That road on the map is envious. Would definitley like to see the detailed instructions on how you accomplished that. Also as Mark said, we really need to know what will, and will not, be able to be edited with the terrain editor. (Still anxious for an ETA on that magic tool!) Hand editing 100 square miles for roads and climate variances in photoshop is just a bit too overwhelming for me. Really want to be able to see the terrain in relation to the world objects. Using photoshop for the opacity map sounds interesting. Would like to learn more about what you did with that.

Thanks for posting the SS and the ideas! Maybe it will help several developers in improving the appearance of TSE terrains.

Blessings to you,
-Sparkling
#4
02/22/2007 (8:24 pm)
Looks awesome, Yeah, i'm totally with you on the detail textures. just really doesnt work out. makes all the terrain look the same. Since you are sharing some of your success with your TGEA terrain, i might as well post out my success with TGE terrain

i126.photobucket.com/albums/p117/seijisota/ter/screenshot_004-00004.png
and I also found a way to inlarge the legacy terrain unit size greater then 256x256 :)
#5
02/22/2007 (8:53 pm)
Great job guys, I would love to know how you achieved the road and the detail. What size cells are you using etc? More info please :)

addikt
#6
02/23/2007 (12:42 am)
Please!!! I think I'm OMW to getting there but i wanna know how u did it, its definatly what im going for:)
#7
02/23/2007 (12:59 am)
Quote:
and I also found a way to inlarge the legacy terrain unit size greater then 256x256 :)

Care to share?
#8
02/23/2007 (9:37 am)
Ok, I'll try to be as clear as possible, and I'm sure some steps you won't need to go through. Here's what I did:

1. I essentially started with the starter.fps mod from here. Only problem is it runs on legacy terrain, so I moved the atlas shaders from the terrain_water_demo/client/scripts/shaders.cs (atlas*)

2. I removed most of the buildings and water block etc. for testing purposes from the mission, but that's up to you.

3. I got L3DT here, and created a 1024 size terrain, using a 1.5 meters per height point (so around 1.5KM x 1.5KM world). It's sort of important to go around this size, because it actually dictates your texture size. You can probably use another app to get a bigger terrain size (or maybe l3DT pro?), but I'd stick to about 1.5 meters per height point/heightmap pixel.

4. I just used standard terrain generation routines, but I didn't create water/water maps, because it creates fewer textures (we're limited to 4 right now on the terrain, but I'm working on that). Make sure you generate lightmap and texture map. You can also follow the GG guide over here if you want to import heightmaps and whatnot.

5. Once your L3DT maps are generated, you want to resize your map to 1025x1025 or you get weird seams apparently. Atlas requires the source .RAW file to be one pixel larger so resize the Heightfield map by going to Operations-->Heightfield-->Resample map and adding 1 to your map's Width and Height.

6. Go to View->Show Map->Heightfield to make sure the heightfield is active. Go to File->Export->Active Map. Choose RAW file format, save as heightmap.raw in some temp folder, and resize to 1025x1025 for export.

7. Go to View->Show Map->Light Map. Go to File->Export->Active Map. Choose JPG file format, save as lightmap.jpg in your temp folder.

8. Now we create an opacity map. Go to Operations->Alpha maps->Generate... You should see around 4 textures there. Hit next. Select an output filename like alphamap in your temp area. PNG/BMP choice doesn't really matter.

9. Boot up an image program. I use Photoshop, but something like Gimp works too. Open up the images saved in your temp area from the last step, the first probably called alphamap_Alpha1.bmp or something. Don't worry about the alphamap.xml, it's not important.

10. Create a new RGB image of the same size (1024x1024). Choose Channels from the layers/channels tool. Go back to the Alpha image 1 from last step, select-all (ctrl+a), copy (ctrl+c), paste into the Red channel of the new image. Repeat for Green, then Blue, then create a new channel called Alpha, and paste the 4th in there. I ran a blur filter a couple of times over my channels, because L3DT seems to only generate 1-bit (on or off) opacity settings, so the blends look sort of pixellated.

You can also draw all over this opacity map if you want, to create roads and whatnot. Draw bright Green on your map to get the second texture to show up, etc.

11. You should now have a mostly bright red opacity map. Save this file as opacity.png in your temp folder.

12. Now, you want to get your 4 textures that you want painted all over the map. To get good detail, I used 512x512 textures. The smaller your textures, the less they repeat over the map, but they will be stretched bigger close up, so they'll look worse. Even 1024x1024 works with awesome detail, if you can get good source images (not sure about the perf hits though).

As an aside... contrary to what it says in the docs, you can't seem to actually change the amount of texture repetition by changing the Virtual Texture size used in a blended terrain, though having that too low will cause blurry textures. The only things that seem to increase texture detail are shrinking the geometric density of the map (meters per heightmap pixel), and increasing the res of your textures.

Continued in next post...
#9
02/23/2007 (10:05 am)
Continued...

13. Convert your texture images into JPGs. Name them tile1.jpg...tile4.jpg Put them in your temp folder.

14. Now you should have all the base images you need. You want to move these to a folder under your TGEA/Example folder, like Example/TerrainTest.
- heightmap.raw
- lightmap.jpg
- opacity.png
- tile1.jpg, tile2.jpg, etc.

15. I created my actual terrain file using the atlasBuild.cs script from here. Copy the code from the AtlasBuild Script section into an atlasBuild.cs file and put it in your TGEA\example folder.

16. AtlasBuild.cs needs a little modification, because it's not actually complete.
The line:

atlasGenerateOpacityTOC(   %terrainPath @ "opacity.png",
                              true,
                              %opacityPath );

should be changed to:

atlasGenerateTextureTOCFromTiles
      (1, %terrainPath @ "opacity.png", %opacityPath, 1);

16. Modify the top of the atlasBuild.cs script and put in your Example/TerrainTest or whatever folder. These are the rest of the settings I used, but of course they'll vary based on your terrain:
/// The pixel size of the terrain RAW minus 1.  This
/// value must be power of two square!
%terrainSize = 1024;

/// The number of levels to the final tree for both 
/// the terrain geometry and the texture.
%terrainLevels = 8;

/// The number of output meters per heightmap pixel.
%terrainMetersPerPixel = 1.5;

/// The scale above goes into the terrain scale here.
%terrainScale = 0.0028;

/// The amount of error to allow when creating terrain
/// chunk LODs.  A good number is 1% of the unscaled height.
%terrainError = 0.1; //( 65536 * %terrainScale ) * 0.01;

%virtualMapSize = 512*512;

17. Run command tgea.exe atlasBuild.cs to create your map. You should get a terrain.atlas file in your TerrainTest folder if all goes well.

18. You can move the terrain.atlas file to the starter.fps/data/terrains, and create a mission in starter.fps/data/missions to test the terrain. Mine (simple.mis) looks kinda like this:
//--- OBJECT WRITE BEGIN ---
new SimGroup(MissionGroup) {
      musicTrack = "lush";
      cdTrack = "2";
      CTF_scoreLimit = "5";

   new ScriptObject(MissionInfo) {
         name = "Simple testbed";
         desc0 = "For Shader Testing.";
         descLines = "2";
   };
   new MissionArea(MissionArea) {
      area = "-360 -648 720 1296";
      flightCeiling = "300";
      flightCeilingRange = "20";
         locked = "true";
   };
   new AtlasInstance2(NewTerrain) {
      canSaveDynamicFields = "1";
      position = "0 0 40";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      detailTex = "~/data/terrains/details/detail1.png";
      atlasFile = "~/data/terrains/terrain.atlas";
      lightMapSize = "1024";
   };
...

// the rest is a bunch of stuff from starter.fps you can put in, like the sky/spawnspheres, etc.

Continued in next post...
#10
02/23/2007 (10:18 am)
Continued...

19. Turn off the Detail Texture. I did this via code, because I couldn't figure out where to do this via pref/script. Someone know how to do this as a pref?

In code, I just commented out line 490 at the bottom of atlasClipMapBatcher.cpp:
void AtlasClipMapBatcher::render()
{
   PROFILE_START(AtlasClipMapBatcher_render);

   renderClipMap();
   //renderDetail(); <-- comment this out to ignore the detail texture
   renderLight();
   renderFog();

   PROFILE_END();
}


20. The only other thing I did was boost the ClipMap from 512 to 1024 (note this may impact perf), because I felt the transitions between mipmaps were too drastic (i.e. things got blurry too quickly). It can be modified via changing the Pref::Atlas::clipMapSize, or change the default in [b]atlasInstance2.cpp line 164 from 512 to 1024[b]:
mClipMap->mClipMapSize = Con::getIntVariable("Pref::Atlas::clipMapSize", 1024);


That should be it! I'll probably be refining some of this as I figure out more about the inner workings of the blender, but this is basically what I've discovered so far.

Hope it's useful to some of you,

Marek
#11
02/23/2007 (1:52 pm)
Now, the real question becomes: when will Atlas2 be lit and shadowed like the legacy terrain picture above?
#12
02/23/2007 (7:48 pm)
@Peter Simard
Yeah sure, Its still a little bit buggy. I am actually going to do some final testing on it before i release it. its really not that hard =)
#13
07/16/2007 (4:41 pm)
@T Squared
When you use larger textures (512x512 or 1024x1024) do they get "fuzzy and blurry" i have a real issue with that and i cant find any way to get them sharp. Please drop me a email or post a hint. please :)
#14
07/16/2007 (6:51 pm)
@Alienforce
look through my post, and you'll find your answer.
#15
09/02/2007 (11:11 am)
Nice work :)
#16
10/20/2007 (2:58 pm)
Nice work both of you.. I spent a couple of day and got the followings:

i218.photobucket.com/albums/cc99/shaon007/tse3.jpg
and the second one.
i218.photobucket.com/albums/cc99/shaon007/tse1.jpg
#17
11/17/2007 (7:54 am)
Well this is what i have been able to come up with, I still have not been able to get a map size over 2048 though.
i226.photobucket.com/albums/dd113/krazyya/road.jpg?t=1195315501i226.photobucket.com/albums/dd113/krazyya/road2.jpg?t=1195315426
#18
11/19/2007 (1:10 am)
Does look good, I still can't figure out why im still suffering from blurry textures, tried increase virtual memory, gone upto 1024 res tiles, even increased the shader repetition so it tiles a greater amount but nothing seems to get rid of the blur. (using a 1 meter floating point, creating a 1km x 1km area size).

Anyideas?
#19
11/20/2007 (4:32 pm)
Well, since we're all sharing I may as well too.. I've been working with Atlas for about 2 weeks now and I managed to come up with this:

www.crysis-online.com/Media/Screenshots/Screenshots/Mountains-DX10.jpg
#20
11/20/2007 (4:44 pm)
@Robert: lol, you should remove the logo on the lower right part of the screenshot.
Page «Previous 1 2