Jump to content

Palaxin's Heightmap Guide


 Share

Recommended Posts

Introduction

  Reveal hidden contents

Basics

  Reveal hidden contents

Beginner

  Reveal hidden contents

Advanced

  Reveal hidden contents

Expert

  Reveal hidden contents

Changelog

  Reveal hidden contents

 

Edited by Palaxin
  • Like 7
  • Thanks 2
Link to comment
Share on other sites

Added illustrations to the Basics and Beginner sections :)

  On 28/05/2016 at 4:38 PM, FeXoR said:

EDIT: I wonder though if anyone could make a living with that "Pro" hints ... for that's what "professional" means AFAIK ^^

Expand  

You suggest to rename it to something else? E.g. Advanced II? Or a more content related caption like .pmp file hacks or scripting or something similar? BTW thanks for linking the guide ;)

Edited by Palaxin
Link to comment
Share on other sites

  • 5 years later...

Hi everyone,

Thanks to Palaxin for his tutorial. I was frustrated by the quality of the Atlas import, and have decided decided to tackle the expert method. The problem for me was that a script is needed, because of the way the .bmp files are encoded.

After some research, I found out that .tif file have a much friendlier encoding for our use, and we can literally copy-paste the pixels block inside the .pmp as is. As long as the tif file is correctly formatted. The good news is that GIMP nowadays supports 16 bits integer images and export!

I wrote a detailed tutorial, please tell me if something is unclear. Here we go:

 

Preparation

Create and save a basic map with the Atlas. Resize it and note the size, it's very important.
The map is made of two files: a .pmp and a .xml. In this tutorial, we will paste the height map into the pmp.

Sizes

Your initial height map can be any size. I've included a resize step in the process. But, depending on the size selected for your map in the Atlas, the final .tif height map must have the right number of pixels.
Here are the corresponding sizes in pixels:

Tiny:      129x129
Small:     193x193
Normal:    257x257
Medium:    321x321
Large:     385x385
Very Large:449x449
Giant:     513x513


Note 1: It is essential that all your exports are: uncompressed tif images, grayscale, with 16 bit integer precision, and no alpha channel. Every other setup changes the number of digits for each pixel, and will mess up your map quite badly.

Note 2: With the method here, the map will become a mirror copy of your original height map. If you don't want that, you can add the following point to the "Export operations":
2a) Image > Transform > Vertical mirror



I. Elevation file export with GIMP


IA) (only once per size) Create a a uniformly white image and follow the export operations. This is the .tif file used to find the extent of the pixels. You need to do that only once for each map size. I suggest you name it "white_template_size.tif".

IB) Open your elevation file in GIMP and follow the export operations. If it's an .xcf file, be careful NOT to hit Save at any point during the operations.


Export operations

1) Image > Flatten Image
        this ensures there is no alpha channel and only one layer

2) if you original file is not the right size:
        Image > Scale Image, select the "pixel" unit and enter the right size.

3) Image > Mode > Grayscale

4) Image > Precision
        choose 16-bit integer, linear light

5) (IB only) File > Export
        choose a name for your file, add something like "_full_height", and add the .tif extension
        choose Compression : none, and uncheck all boxes
        export
        note: you will probably have to try different curve settings, so it's useful to keep and reopen the "full_height" file for subsequent tries.

6) (IB only) Colors > Curves
        check the "linear" icon on the top right
        select the top-right point of the curve
        in the "output" field, enter a small number (I usually start with 5.00) and validate
        note: you can use Colors > Levels as well. Select "linear", enter your value in the rightmost "output levels" field.

7) File > Export As...
        choose a name for your file and add the .tif extension (let's call it MyMap_size.tif)
        choose "Compression : none", and uncheck all boxes
        export



II. Height map import with hexadecimal editor
 

You'll need an hexadecimal editor which allows to select large blocks with SHIFT. On Linux, I use the Bless Hex Editor.

1) Open "white_template_size.tif" and MyMap_size.tif with the hex editor side by side.
        note: on the editor, the cursor's position is referenced as "Offset" followed by an hexadecimal address

2) On the white_template file, notice that most of it is filled with "FF". This tells us where the actual pixels start and end. Go to the end of the file and place the cursor just after the last "FF". It's usually a "12". Read the offset.

3) On the MyMap file, go to the end of the file, and place the cursor at the exact same offset. It should also be a "12".

4) Scroll back to the start of this file. If you observe the white_template, you should notice that there are 8 positions before the "FF" start. Back to MyMap, count 8 double-digits and SHIFT+clic on the next one. A big block should be selected. COPY.

5) Open the .pmp file with the hex editor. Place the cursor at offset "10". It means 16 in base 10, so the cursor is actually at the 17th position.

6) Press the "INSERT" key. The info bar should now indicate "OVR" instead of "INS".

7) PASTE.

8) Save, open your map in Atlas. The relief is probably too accentuated, or too flat. Repeat the operations, starting from Ib) 6) above. Adjust the output of the curve with a different value. Don't forget to always set the curves in linear mode.

 

Cheers,
Pascal

 

Edited by Scallact
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  On 19/09/2021 at 8:23 PM, wowgetoffyourcellphone said:

My frustration comes from the exaggerated affect applied to the map in Atlas. This happened when the number of height units was increased some years ago and was never fixed. As a result, you have to use a very small range within the grayscale image.

Expand  

I take this into account. Also, with this method, we don't lose any height precision. We have access to the full 65536 discrete height values.
I strongly suggest to allway keep a copy of the original file you're working on, and only apply the linear curves in the last steps, as indicated in this tutorial.
Just don't be afraid to apply some curves with some crazy small output value. I can guarantee the 16bit exported file is still very precise! :-)

  • Like 1
Link to comment
Share on other sites

Hi,
Here is an example of import with the method above.
The first image is made from the height map in GIMP with some shading and altitude gradient.
The 2 others are from the Atlas, with some basic terrain covering so that we see the relief well. The map size is medium

Cheers!

P.S: the height map is shown before resizing to 321x321px, it's much higher resolution than the Atlas shots.

 

elevation11s.jpg

heightmaps_demo_01.jpg

heightmaps_demo_02.jpg

Edited by Scallact
Link to comment
Share on other sites

  • 1 month later...

Not wanting to go too far off-topic here, but you can also get heightmaps from existing skirmish maps for use in generating random maps. For example, when Jebel Barkel is generated, it imports a pmp file:

g_Map.log("Loading hill heightmap");
createArea(
    new MapBoundsPlacer(),
    new HeightmapPainter(
        translateHeightmap(
            new Vector2D(-12, scaleByMapSize(-12, -25)),
            undefined,
            convertHeightmap1Dto2D(Engine.LoadMapTerrain("maps/random/jebel_barkal.pmp").height)),
        minHeightSource,
        maxHeightSource));

One application for this method is that if you have a 2v2 skirmish map for example, one might create a random map that allows more flexibility with the number of players, using the same terrain as a nice skirmish map. :) There's some extra info in trac ticket 4816.

Link to comment
Share on other sites

  On 24/10/2021 at 7:13 PM, andy5995 said:

Not wanting to go too far off-topic here, but you can also get heightmaps from existing skirmish maps for use in generating random maps. For example, when Jebel Barkel is generated, it imports a pmp file:

[...]

One application for this method is that if you have a 2v2 skirmish map for example, one might create a random map that allows more flexibility with the number of players, using the same terrain as a nice skirmish map. :) There's some extra info in trac ticket 4816.

Expand  

If I understand well, this is useful to transfer an existing heightmap to another (especially random maps) ?

Link to comment
Share on other sites

  On 24/10/2021 at 10:12 PM, Palaxin said:

Glad to hear that the tutorial is still helpful after more than 5 years :D And thanks for the additions, @Scallact!
Since then, there have been quite some changes and new features to map generation, as @andy5995 mentionend...

Expand  

Very helpful indeed! The Atlas import function is far from perfect, and I really wanted to be able to "sculpt" my own heightmaps in GIMP and import them without loosing any quality. My initial idea was to experiment with symmetrical heightmaps, and maps where mountains/hills are not used as obstacles, but as tactical features.

I have found a more straightforward way to to the second part: heightmap import. With a small command line utility able to copy binary code from one file to the other. I will complete my post when I have time.

Of course, creating handmade heightmaps might seem a bit daunting. However, I'm more of a graphic guy, and that was the easy part for me ;-) I have developed some nice and accessible methods to build them with GIMP, and will share these in another post in the coming weeks.

  • Like 3
Link to comment
Share on other sites

  • 8 months later...
  On 24/07/2022 at 11:26 PM, andy5995 said:

Tangram Heightmapper seems like a great source to get a heightmap. I added the link to the wiki.

Expand  

Thanks!

Complementarily, I'm currently working on a GIMP script to create customized height maps. I've made many experiments since a few months, and It's starting to show nice results. I should be able to share it in the future.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...