Author Topic: L3DT Heightmap weirdness work-around  (Read 1520 times)

Offline 8thJinx

  • Silver Member
  • ****
  • Posts: 991
L3DT Heightmap weirdness work-around
« on: January 06, 2018, 12:00:50 AM »
So I found a heightmap of the Falkland Islands in PNG on the web.  I wanted something to act as a test terrain for berms and land objects.  In the process, I managed to line up all of the scalings perfectly (lots of trial and error), so I figured I should document the method here for anyone else who tries it this way.

1. Find a heightmap (or generate one) of a real piece of terrain.  I was lucky and quickly found a rectangular, grayscale, heightmap in JPEG of the Falklands.  But you could use anything.  Artik's program works well, but it doesn't let you tweak things in L3DT before it goes into the TE, which can be very useful when it comes to setting heights of mountain ranges. 

2. Using Paint, I squared off the rectangular JPEG.  The square turned out to be about 1470x1470 pixels.  I saved this as a BMP. 

3. Knowing from google Earth that the Falklands are about 260 miles across, I cropped the BMP to the 260 mile mark, using Paint. Now I was down to about 1300x1300 pixels. 

4. Since the scaling you need in the import from L3DT to the TE is 660 "meters" per pixel (even though it ends up in feet in the TE), a 512-mile "final product" square needs to be 4096x4096 pixels.  So, using Paint.net, I made a 4096x4096 black image file.  This would serve as my full map.  All I had to do was copy the file created in the steps above (properly scaled) into this one.

5. Since my heightmap BMP of the Falklands needed to end up being 260 miles across within the "final product" 512-mile (4096x4096) square, I resized the 1300x1300 pixel image (which was 260x260 miles) to be 260x4096/512 = 2080 pixels square.  I saved this, and pasted it into a layer on top of my 4096x4096 black square, and then saved the resulting image as a BMP.

6. Now, an important step.  For some reason when you import a heightfield from L3DT into the TE, it flips on you.  It's as if your heightfield was a dinner plate, and someone grabbed the rim at 6:00, and flipped it over towards 12:00.  So to outwit the software, I flipped it vertically myself in Paint.net, as a pre-emptive move.

7. I then opened L3DT, and started a new project as a Blank Designable Map.  Width and Height were set to 4096 pixels.  Horizontal scale was 660 "meters" per pixel (again, that ends up being feet in the TE). HM/DF was left as 64, and I left all of parameter sliders in their defaults.  The last 'wizard' step was the calculation queue, where I only left Design Map checked.  The wizard then generated a generic terrain, which was soon to be overridden.

8. I selected File / Import / Heightfield, and selected the flipped 4096x4096 bitmap I had created in step 6 above.  My file format was bitmap, my horizontal scale was 660.  I specified minimum alt to be -135, and max alt to be 2000.  Again, these end up being feet in the TE.

9. Now I had my flipped over heightfield in L3DT.  I checked it out in Tools/Heightfield Editor 3D, and it looked good.  I could have played around with it more, but I left it as is.

10. I then selected File / Export / Export Active Map Layer, and got the export wizard.  Format was set to RAW, Options set to 16-bit signed manual scale, InvertY set to true.  I clicked OK, and I now had a signed heightmap ready for the TE.

11.  I opened the TE and started a new project.  I set the map size to 512 miles.  I selected File / Import Signed Heightmap, and found my file.  I clicked OK, and the Falkland Islands appeared in my Terrain Editor window, at the correct orientation, at perfect real-world scale.




Join Date: Nov 2012

B-24H Liberator SN 294837-T, "The Jinx", 848th BS, 490th BG, 8th AF, RAF Station Eye, delivered 1943.  Piloted by Lt. Thomas Keyes, named by by his crew, and adorned with bad luck symbols, the aircraft survived the entire war.

Offline bustr

  • Plutonium Member
  • *******
  • Posts: 12436
Re: L3DT Heightmap weirdness work-around
« Reply #1 on: January 06, 2018, 02:13:31 PM »
Since I don't use real world topomaps, I do this long hand with a 16bit grayscale png knowing sea level in the TE corresponds to gray value 1000. I map primary elevations and land mass shapes, then pull a Michelangelo in the TE after I import the converted unsigned RAW file. There are some topo gradient tools I've tried in Krita that created mountains for me after I defined the base elevation gray color. I still had to Michelangelo the whole project space at that point in Krita with topo grayscale gradients before converting it to RAW and importing it. The png grayscale file looked like a heightmap RAW file after I created it in Krita. It's more fun doing the creation inside of the TE from the basic blocks I create in Paint.Net and export into Krita. The TE is in color and has sunlight versus living in the "dark universe" creating topography in shades of gray on an ocean of black. And you have to do it in gazillions of layers like building a skin for a fighter in the game so you don't have light gray transition pixillation boarders around each gradient top feature you build. That is how you get those thousands of foot high "needles" outlining things in the TE after you import a heightmap.

Knowing that 8pixel=1mile and the work space is 4096x4096, yes you can scale just about anything to the work space and convert for an import. The ongoing posts I did for BowlMA, Oceania, and now Riftval. I covered this in detail and how to do it with each project to demystify the procedure.

When you get up close and look at topo features in the TE, you will notice they are horribly imperfect because of the limitations of the polygon grid. Once I realized that, it's very fast creating things by hand in the TE. Knowing the limitations makes touch up simple because the results will always turn out the same when you get down to the smallest brush width of the tools. That is why our terrains are a grand illusion and you try to use the "built in illusion system" to give a player's eyeballs just enough that his brain will fill in the rest. Just like Zen sumi-e ink wash paintings.
bustr - POTW 1st Wing


This is like the old joke that voters are harsher to their beer brewer if he has an outage, than their politicians after raising their taxes. Death and taxes are certain but, fun and sex is only now.

Offline 8thJinx

  • Silver Member
  • ****
  • Posts: 991
Re: L3DT Heightmap weirdness work-around
« Reply #2 on: January 06, 2018, 04:16:09 PM »
What's with the flipping of the heightmap when it gets imported into TE?  Has it always been that way?
Join Date: Nov 2012

B-24H Liberator SN 294837-T, "The Jinx", 848th BS, 490th BG, 8th AF, RAF Station Eye, delivered 1943.  Piloted by Lt. Thomas Keyes, named by by his crew, and adorned with bad luck symbols, the aircraft survived the entire war.

Offline bustr

  • Plutonium Member
  • *******
  • Posts: 12436
Re: L3DT Heightmap weirdness work-around
« Reply #3 on: January 06, 2018, 06:54:29 PM »
Yuppers, a quarter turn to the right I believe.........in Krita I save the converted 16bit gray scale file rotated 90 to the right before exporting for conversion out of ImageJ as an unsigned RAW. I always end up screwing a few files before I remember that....... :O

I used to cut faceted gem stones, I love the AH3 terrain editor because it allows me that kind of creativity without the all or nothing consequences of screwing a gem. But, it has the complexities of keeping track of the cheater knob angle rotations and dialing in the facet angles through 32-64 faces and ending up with a "gem" of a result. The terrain editor has nothing on the mental boredom and agony of a 32 facet brilliant cut. Creating a terrain from scratch is child's play after that. Hitech probably goes through something like that as a master programmer. 
bustr - POTW 1st Wing


This is like the old joke that voters are harsher to their beer brewer if he has an outage, than their politicians after raising their taxes. Death and taxes are certain but, fun and sex is only now.