tga2ter - Convert your heightmaps into terrain!

Releasing the source files for your mod or map? Post em' here. (Applies to both SWBF1 & SWBF2)

Moderator: Moderators

theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Download: https://docs.google.com/uc?export=downl ... C1pMGdQMzQ
Previous version: http://www.gamefront.com/files/24001765/tga2ter.exe


Hello everyone.

I've finally got my terrain generation tool to a level that makes it actually useful. It's far from finished, but I won't have much time to work on it in the near future so I figured I may as well release a very early version.

Now, to business. This program takes a heightmap as an uncompressed TGA file, and converts it into a TER file for use in SWBFII. It's executed in the command line, and you can pass it multiple options. These options are (for now) limited to:
  • -i or --input - specifies the input TGA file. This is a required argument!
  • -o or --output - specifies the output TER file. This is a required argument!
  • -g or --grid - sets the terrain's grid size. If not set, defaults to 8.0.
  • -h or --help - displays the usage guidelines.
  • -n or --normals - specifies the normal map input TGA file. Used to created automatically textured terrain based off terrain gradient. If this is used, you should also set -t0 and -t1. This file must have the same dimensions as the heightmap file.
  • -s or --scale - sets the scale multiplier. If unset, deafults to 100.
  • -t0 or --tex0 - sets the main terrain texture. If unset, defaults to "wipe_black.tga".
  • -t1 or --tex1 - sets the steep gradient terrain texture. This does not default to anything. If you use a normal map, make sure to set this value.
As an example, let's say that I want to create a terrain which takes the input "heights.tga", normal map "norms.tga", and writes the output to "terrain.ter". We want to use the textures "yav2_main_1.tga" and "yav2_main_3.tga" for the flat and slope textures respectively. Here's how we would do it:
  • Put all the required input files into the same folder as the executable (the textures don't count as inputs)
    Image
  • Next open up a command prompt window and navigate to the correct folder, then, for our example, we would type

    Code: Select all

    tga2ter -i heights.tga -o terrain.ter -n norms.tga -t0 yav2_main_1.tga -t1 yav2_main_3.tga
    and hit Enter. This would be the correct output:

    Image

    leading to the following files in our folder:

    Image
It's important to note that the slope texturing is still very primitive, so I'd not really recommend using it. Also, a note about the grid size. If you set this to lower, the mesh will appear smaller in game, but will also look higher quality. Because of this, if you want to use a smaller grid size, use a larger heightmap to compensate for the change. A problem with changing the grid size is that it makes ZE extremely laggy, at least on my machine, but it doesn't appear to have much of an fps hit in game. Here's a picture of a 1024x1024 terrain with a grid size of 1.0:
Hidden/Spoiler:
Image
Anyway, I hope you all enjoy it and put it to good use: Old link removed, for most recent version see the top of this post.

I'll try and hop on here from time to time to answer any questions you may have. If you have any errors please feel free to post them here and I'll see what I can do. If I don't reply for a while it may be worth sending me a PM so I get the email notification.

Also, a big thanks to noMatt, who helped me test out this program when I didn't have access to my modding computer. Thanks again mate!

Happy modding!
Last edited by theultimat on Sat Feb 22, 2014 5:24 pm, edited 5 times in total.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by Noobasaurus »

Wow this looks really cool! :thumbs: Definitely going to give it a try. Maybe the terrain will actually look good now!

EDIT: Well, I fixed one dll error, but I can't seem to install libstdc++-6.dll. And just when I thought I did, the program simply closes on startup.
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Right, sorry about that. I've updated the file so it should work fine now! Apologies for the inconvenience.
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

Thanks now for finally releasing it :)
And thanks that i was alowed to beta test it already helped me out pretty good :)

Feature request: It would be cool to give a color map and a material mask map as input, so you can give the terrain color (Painting it in ZERO is horrible :D And a mask is a black and white thing so you can specify where which material should be applyed :) But thats not nescessary it would be just super freaking awesome)


But like this your tool is already awesome :) Thanks for it and your great awesome work


EDIT: And as an tip for eventual futur heightmap works: Dont use a tga because its a 8 bit format. Thats making much harder level difrences then a 32 or 16 bit file format.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by Noobasaurus »

OK I'm a silly goose. I didn't read the first post. :P I realize that I have to use cmd to use the program.

But hey, now I'm trying it out! Pretty cool so far.
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

BUG: Since this update heightmaps are roated by 180 degrees :D So i am going to use the old one again :D
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by Noobasaurus »

Well dang, this thing makes me want to come out of my "modding retirement." I've been experimenting with fractals and some of the stuff looks really good. All I need to do is add objects in...


SO TEMPTING. I just might.
Nullen
Private
Posts: 41
Joined: Sun Sep 18, 2011 9:20 pm
Projects :: HL2 Insolence mod
xbox live or psn: No gamertag set

Re: tga2ter - Convert your heightmaps into terrain!

Post by Nullen »

Wow, this is awesome! Sure it has its flaws at the moment but I'll finally have a use for the heightmaps I have laying around. :bowdown:
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

Ok i tested it and the terrain is really of its right position. But thats not important easy fix:

set -s (Multibler) to -100 and everything is alright again


Edit: theres another bug. if the height gets below a certain value it gots read wrong.
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Hi guys, apologies for lack of bug-fixes and updates - I've got exams this week and the next so I've been rather busy.

@noMatt - I've decided to drop the automatic slope textures for now in favour of texture splatting. With regard to the heightmap rotation, you can choose the origin of the TGA file when you save it (at least in GIMP). For the heights being read incorrectly, I've started completely re-writing it in a more maintainable manner, so this shouldn't be an issue in new version.
@Noobasaurs - Fractal terrain can look pretty amazing, I'd love to see how it goes if you do decide to have a bash at it. :)
@Nullen - Glad you're finding it useful.

Also, I was wondering what people were thinking of adding a kind of foliage splatting option, or would you say there isn't much point given the ease with which it can be done in ZE anyway?
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

Glad to see you are still workin on this. I though you were off from gt for now... :D I really look forward to the update :)

Thanks again for this awesome tool this makes Terrain sculpting soo much easier
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by Noobasaurus »

Well I did actually do some stuff with randomly generated fractals. However, the map started crashing after the first few seconds and I didn't want to deal with it. So have some pictures.
Hidden/Spoiler:
First I started with some fractals/islands. Some of them didn't work too great. The last one worked the best.Image
Image
Image
Image
Image



So then I took the last fractal and used it to generate terrain. You only get ZE screenshots though.
Image
Image
Image
Image

After smoothing it a bit, it looks pretty nice!

Oh: The second to last fractal created this giant island. It was pretty awesome. It had a volcano on an island too. I thought that it would be great for an open world game.
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Hello again everyone, I think I've done enough changes to release the next version. Here's a complete list of changes:
  • Added support for setting 16 textures.
  • Added support to set the tile-range for each texture.
  • Added texture splatting with alpha maps.
  • Added option to have a border.
  • Removed automatic texturing from normals (for now).
Below I've put the new usage guidelines. Where there is an <n>, you need to replace this with a number from 0 to 15. For example, if you wanted to set texture 0 you would type -t0 or --tex0.
  • -i, --input - Specify the input TGA file.
  • -o, --output - Specify the output TER file.
  • -a<n>, --alpha<n> - Set the n-th terrain texture's alpha map.
  • -b, --border - Specify whether the map needs a border.
  • -g, --grid - Set the terrain's grid size.
  • -h, --help - Display usage help.
  • -r<n>, --range<n> - Set the n-th tile-range.
  • -s, --scale - Set terrain scale multiplier.
  • -t<n>, --tex<n> - Set the n-th texture.
And now for a demonstration.
Firstly, make sure you have the required input files in your chosen folder, along with the executable. You do not need to have the terrain textures in this folder, as the program does not read data from them. Suppose we're making a terrain which we want to automatically texture with 3 alpha maps. Therefore, we would have the following:

Image

We would then open a command prompt window, and navigate the previously mentioned folder. Then we would run the following command:

Code: Select all

tga2ter -i heightmap.tga -o TES.ter -t0 grass.tga -t1 rock.tga -t2 snow.tga -a0 alpha0.tga -a1 alpha1.tga -a2 alpha2.tga -b
This should run as follows:

Image

Which would lead to the following files being in our folder:

Image

Then you just need to place your new terrain file in the correct place, and all should be well. Here's what my example looks like in ZeroEditor:
Hidden/Spoiler:
Image
And here's the three alpha maps used (note that white is fully opaque, and black is fully transparent).
Hidden/Spoiler:
alpha0.tga:
Image
alpha1.tga:
Image
alpha2.tga:
Image
With regards to when to use the border option - it should be used when the player will be able to reach or clearly see the edge of the map. If it is not used, the terrain "tiles" itself; that is to say, if you have a height of 100 on the left, and 0 on the right, you will get a steep jump up from 0 to 100 on the right hand side as the two vertices are joined by an edge. This also happens with textures, such that you will get the transition between the two if they are different on opposite sides of the map. With the border option, none of this happens - but the size of the TER file will increase.

And here's the download link: http://www.gamefront.com/files/24001765/tga2ter.exe

Enjoy.
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

Thats what i waited for :D Now i can start workin on me map :D
Thank you my god :)

EDIT: Texturing doesnt seems to work

NEVERMIND :) Works
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Glad it's working. Just out of interest, what made you think that it wasn't?
noMatt
2nd Lieutenant
2nd Lieutenant
Posts: 398
Joined: Sun Mar 10, 2013 12:30 pm
Projects :: The Map has no name so see alpha
Games I'm Playing :: Crysis Battlefront
xbox live or psn: No gamertag set
Location: Germaneeee
Contact:

Re: tga2ter - Convert your heightmaps into terrain!

Post by noMatt »

The texture is not displaying in ZeroEditor :) at least not in bigger terrains.
Easy fix: Select an empty layer, choose "paint" and paint the whole map. Press undo, now the texture shows up correctly
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Yeah, I also get that - not only when using the tool, but also when creating a new terrain in ZE. I normally just go to the colour tab and paint everything white to solve the problem. Not entirely sure why it happens, but I'll look into it all the same.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by MileHighGuy »

Wow cool! So the grid size is not locked? Is it possible to add an option for this in zeroeditor?

I will try out a heightmap for the grand canyon

Edit:I imported a 1024x1024 texture with a grid size of 1. it is magnificent, but this program would GREATLY benefit from a height smoothing option. I had to smooth down the entire thing to get it looking natural.

PS: can you provide an example of a normal map used to make this? Can I make my own from a black and white texture?

Edit: SCREENSHOT!
Hidden/Spoiler:
Image
theultimat
Lieutenant General
Lieutenant General
Posts: 679
Joined: Sun Apr 13, 2008 1:39 pm
Location: UK

Re: tga2ter - Convert your heightmaps into terrain!

Post by theultimat »

Hi MileHighGuy, I agree - on some heightmaps the terrain looks pretty awful due to how sharp the changes are. One solution I found was to give the heightmap a very slight Gaussian blur - this generated a much smoother terrain, so it may be worth giving it a shot in your case.
A normal map is a texture where the RGB values for each pixel correspond to the XYZ values for the vertex's normal, so a black and white texture wouldn't be of much use. To create my normal maps I use a plugin for GIMP (http://code.google.com/p/gimp-normalmap/). Although all that being said, in the latest version normal mapping isn't enabled, so you're probably using the outdated version. I would highly recommend using the latest version as it fixes a TGA reading error present in the original. I'm hoping to add the feature back in at some point, but I can't make any promises as to when.
MileHighGuy
Jedi
Jedi
Posts: 1194
Joined: Fri Dec 19, 2008 7:58 pm

Re: tga2ter - Convert your heightmaps into terrain!

Post by MileHighGuy »

Thanks for the reply. I also was wondering, what heights do black and white translate to? Black looks like it is zero and white looks around 260?

Can you add an option to set black to -327 and white to 327? It would help create more dramatic mountains.
Post Reply