Game Development Community

My return to what I love most: Terrain

by Jacob Dankovchik · in Torque 3D Professional · 05/06/2009 (1:10 pm) · 82 replies

For the longest time I've been completely out of the GG community. Truth be told, after TGEA, which I considered a total flop, I had completely lost faith. With the comming of this new engine, I decided to give GG one last shot.

My biggest thing back in the day was particle effects, and terrain. I would spend hours on end playing with Atlas, making terrain after another. Mostly I'm waiting for the soft particles to make it in before I tear into those. So for now, I'm playing with terrains, and this is the result of about.. 1 day of playing.


First off, I'd like to mention the lighting. While it appears to be great at a small scale, when you scale the terrains up, it starts getting very ugly. Tweak some settings and it gets better, sometimes much better. Basically, some nice default values are going to have to be found and a good, all-inclusive menu for easily changing all settings. But, as many as there are, it would still be good to have default access to all of them, such as through an Advanced Settings menu. In other words, there's a lot of numbers to tweak, but that's a good thing because you get a lot of control.

There seems to be some inevitable lose of shadow accuracy as size goes up, which concerns me a bit, but I'll worry about that more at a later date, if it's in any way an issue.

I'd like to state that the realtime tools is a MASSIVE plus. Being able to cook up a beautiful heightmap in L3DT and then further changing it in-game is such a wonderful step for me.

One thing that I found which concerned me a bit was the height limit of 2047. While some may find this to be enough, I simply don't. :P All my time with Atlas, I did nothing but push the limits with it, as I'm doing with this new setup and honestly 2047 meters just isn't enough. For some people who are trying to make a beautiful set of mountains, it's just too small. Perhaps this is something easily fixed/changed, I'm not sure yet as I've no way to mess with source on this comp yet. But just pointing it out.

Basically, I think there is a LOT of potential in the terrain system and I'd certainly like to see some of the other people here get in on it as well. :D


Since I've just barely begun touching on the terrain, I haven't taken the time to really work with texturing yet. That's the next step for me. But here are a few shots of what I've thrown together right away. Max height is 550m, 4096x4096 in area. Had to tweak a few settings to get it to something I can find acceptable.

img148.imageshack.us/img148/3006/screenshot00200000.pngimg152.imageshack.us/img152/1940/screenshot00200001.pngimg110.imageshack.us/img110/144/screenshot00200002.png
#21
05/19/2009 (12:26 am)
Looks good :)

Btw, anyone got normal mapping to work on terrain ??, i cant seem to see any changes at all when i use them.
#22
05/19/2009 (12:56 am)
I had read days past that normal mapping is not currently working. It is what i am also waiting on, with anticipation.
#23
05/19/2009 (1:06 am)
Ah, thanks Caylo

While at it, is it possible to increase terrain resolution (lets say 2x or 3x current) in the code, without increasing the "size" of terrain.

at 128x128 - 1m, the terrain is too low res for my taste, alot of hard edges and such where they are not wantet.

As im making isometric/ortho looking game, i dont see why i coudnt run alot higher terrain resolution as not that much on screen at any given time anyways.

If anyone has experience with that, or know where/what source files to edit (terrCell.cpp ?) or even how/what to change, please let me know, would be appriciated :)
#24
05/19/2009 (1:14 am)
You can definitely get higher res than 128x128. It uses the resolution of the heightmap, so make a higher res highmap! I suggest something like 1024x1024.
#25
05/19/2009 (1:22 am)
How did you get 128X128 to work. I can not get lower then 256x256. Most of my little projects use small terrain maps, and often terrain resolution is not a concern, the lower the better, for the sake of FPS speed and room for HIGH detail on lower end hardware (its a secret of mine, scale the terrain down, and often that is all i need to do for older hardware, have not fully tested this with T3D yet).
#26
05/19/2009 (1:52 am)
@James

What i mean, at 256x256, you get 256m size terrain, with 1m pr cell.

I want 256x256 with maybe 50 cm pr cell (double the cells) but it still is 256m in size.

what i mean is, half the square size of current, same terrain size (eg 512x512 squares inside 256x256 terrain block).

kind of like increase res of a mesh inside zbrush ect, object stays the same, but it gets more triangles.

Tried increase heightmap res to 2048x2048, still same amount of cells on terrain block.

@Caylo

My terrain is 256x256, sorry my bad :)
#27
05/19/2009 (2:12 am)
Try setting squareSize to something fractional, like 0.5, I'm not positive this works but if it doesn't it should probably be fixed.
#28
05/19/2009 (2:22 am)
If i set squareSize to 0.5, it makes terrain half size, and not double the cells (as it probably should), so i guess thats a bug then.

Oh, and "size 1 1 1" on terrain cannot be changed inside editor it seems.
#29
05/19/2009 (2:30 am)
Then make your heightmap 512x512 and you have what you want... right?
#30
05/19/2009 (3:17 am)
No, i need higher map resolution, not a bigger map size.

If i make map 512x512, and 0.5, then terrain gets 256x256 and at same res at default 256x256 terrain, dont ask my why, i got no clue.

I test it by doing the terrain wireframe mode, and check it based on player size.

And i see no change in terrain cell resolution, no mather what i do.

I think the "SquareSize" does not only do the squares, but also the terrain size at the same time, and thats where it bugs up..
#31
05/19/2009 (3:24 am)
Ok I'll take a look at fixing this. It sounds like squareSize and the heightmap resolution are not interacting as they should for squareSize values less than 1.
#32
05/19/2009 (3:32 am)
Actually, I just tried this out and it appears to be working fine. For an extreme example, stand the player on top of the terrain in wireframe, as you described. And change the squareSize between 10 and 0.1, the "resolution" as measured by a the grids relative size to that of the player does change.

So by reexporting your 256x256 heightmap as 512x512 and changing your squareSize to 0.5, you 'did' just double the resolution of your terrain.
#33
05/19/2009 (3:37 am)
But, the square size is the same ( i tested this by placing a object on the cell, and see how much of the cell it cowers ).

See here

const U32 width         = U32( ( max.x - min.x ) / squareSize );
   const U32 height        = U32( ( max.y - min.y ) / squareSize );

   const U32 numVertices   = ( width + 1 ) * ( height + 1 );
   const U32 numTriangles  = width * height * 2;

This says that width and height of plane is devided by squareSize.

So, by changing squaresize, you are infact changing the terrain size, it might just be me, but it seems wrong, and in my testing, the terrain cell verts is remaining the same size nomather what.

btw, im looking around in the "groundPlane.cpp" file incase anyone wondered

edit

looking some more, it does seem like it uses SquareSize just to calculate map width/height and not "size" in editor

for( F32 y = min.y; y <= max.y; y += squareSize )
      for( F32 x = min.x; x <= max.x; x += squareSize )
      {
         ....

as you see here, if you make it 0.5, then it creates a map, half size.

Might just be me, but i would think SIZE is the map size, and not squareSize (should be size of terrain squares).

If map size is set to 1 1 0 (w/h/d) in editor, it should use those to calculate size (right now those size numbers does not work), and then use squareSize sololy to calculate the amount of squares inside map block.
#34
05/19/2009 (3:51 am)
Bo, I have a feeling you're overthinking this a bit. You don't need to look in any code files at all, so you can just close that stuff and stop worrying about it. ;)

These shots here were taken with a 2048x2048 heightmap. Here is the heightmap imported at a squareSize of 1.
img156.imageshack.us/img156/1540/screenshot00300000.png
And here is a wireframe of the same heightmap, only at a 0.25 squareSize:
img297.imageshack.us/img297/5826/screenshot00300001.png


Also, here are 2 shots of the same map with wireframe off, in the terrain editor. Compare the size of the red square in relation to the player.
squareSize = 1:
img168.imageshack.us/img168/5258/screenshot00300003.png



And squareSize = 0.25:
img156.imageshack.us/img156/558/screenshot00300002.png


As you can see, the square is much smaller on when squareSize is smaller, meaning the terrain is higher in resolution. However, this WILL make the terrain smaller, yes. This is not a bug however, simply how it has to work.

Say for example, you wanted to make a terrain 512x512 meters, but also very high resolution. To do this, you would set your terrain resolution to something higher then 512, but set your squareSize to something smaller than 1.

So let's say you decided to go with something really high resolution and you made your heightmap 2048x2048, like in my example. Now, if you use a squareSize of 1, you'd get a terrain that's 2048 meters long, way more than the 512 that we want. So, you need to set your squareSize to a number that when multiplied with the dimensions of your terrain, you get the size you want. For that, you'd want to use 0.25, also like in my example. This will pack all the data of a 2048x2048 image into the space of 512x512 meters, thus increasing resolution.
#35
05/19/2009 (3:52 am)
SquareSize is working properly. Your terrain can only be as high resolution as the heightmap, that value is fixed when you create your terrain. If you change the squareSize all it can do is make it smaller or larger.

What you said before was that you have a 256x256 heightmap terrain with a squareSize of 1.0, and want to make it higher resolution than it is now but maintain the same size.

Ok, here's how you do that.

Resize/export your heightmap image file to be 512x512. Create a terrain with it and set stepSize to 0.5

#36
05/19/2009 (3:57 am)
@Jacob

As you can see, the square is much smaller on when squareSize is smaller, meaning the terrain is higher in resolution. However, this WILL make the terrain smaller, yes. This is not a bug however, simply how it has to work

your math ect sounds very nice, however, its a HELLA lot of work for the terrain.

Size should be size.
squareSize should be squareSize.

Create terrain, 256x256, set squareSize 0.5, and get 512x512 squares, and you dont have to sit and resize and so forth, and you can change squaresize while you work on terrain if you want (make it resize the heightmap aswell).

Sounds ALOT easier to me TBH, and i dont see the logic (as Spock would say) in the system as you descripe it, sounds like a whoooooole lot of work for something that shouldnt have been.

-[edit]-
Right now, if i want to create this, i have to sit and do math and stuff before even considering exporting heightmap (and what if i use internal map editor w/ no heightmap ??)..

i need 256x256, with 0.25, so i have to import a 1024x1024 heightmap, and set it to 0.25, but i have to remember those, but then again, if that was too much, i have to reexport heightmap to 512x512, then import it (after having to delete old terrain *doh* hope i didnt work on it!) and set it to 0.50.. ect

Sounds goofy x.x
#37
05/19/2009 (4:02 am)
The way it works is squareSize is the number in meters that each pixel on your heightmap represents. So, at 1, 1 pixel = 1 meter. At 0.25, 1 pixel = 0.25 meters... *shrug* I thought it was fairly simple myself.
#38
05/19/2009 (4:08 am)
I hear where you are coming from Bo. But there are limits to what you can do in the Terrain editor. Some things are better done in other art applications. That's why you can export your terrain you've worked on in torque to a heightmap, and import a heightmap into torque you've worked on in another app.

Edit: you're right though, something here could probably be improved but I'm not sure what the fix is.
#39
05/19/2009 (4:27 am)
Btw Jacob, when you do a 2048x2048 squareSize of 1 and then 0.25, your map change size, dont you have to sit a change size of all your assets aswell then ?

I just imported a blank heightmap 1024x1024, squareSize 0.25, and the size of the cells dont seem to be smaller.

Also a 2048x2048, squareSize 0.125, and cells seems same size as 1024 one.

Maybe its just me whos dumb, but i can use Maya, Grome, and many more applications quite easy, but this terrain creation is way over my head, way too confusing :P

@James

Could definiatly use work, its not very "friendly" as it is right now (unless you just want to use default settings).
#40
05/19/2009 (4:32 am)
Yes, you'd have to change your position of everything, possibly scaling, and adjust your height scale accordingly.

Frankly, terrain work isn't terribly easy, if you want to get good results. There's just a million and one little variables that can effect a whole lot. Maybe later today I'll write up a tutorial like I did for TSE. Since L3DT is my tool of choice, I'll focus on that again and write an all-inclusive tutorial from start to finish.