Jump to content

Tutorial: Converting a DEM to a heightmap


TrickyVein

Recommended Posts

Some Background:

For those who are curious, a digital elevation map, or DEM is a 2.5D, color coded representation of land surface. In its original form, a DEM is a swath of return values gleaned from remote sensing (commonly using radar) flown on aircraft, satellites, or on the late space shuttles (the SRTM mission). Lowest height values are returned as dark, highest values as white after processing. Data exist for the entire globe and are completely free. Better resolution DEM are always becoming available. What better resource is there for creating your own virtual piece of the world? All the work of creating valleys and mountains has already been done for you by mother nature over the course of 4bya. All you need to do is a bit of preparation work for importing DEM data into the GECK.

For the purposes of this tutorial I am assuming that you have knowledge of how to import images into the heightmap editor; the GECK is completely unforgiving which is why it may seem unstable for some. Until you become familiar with the general process of importing images into the GECK it will be frustrating. I guarantee it.

With that said, everything you need to know about how to import images into the GECK is outlined here. Images must be named correctly.

The Gist of it:

What I describe in this tutorial is a workflow for converting a DEM to a suitable heightmap. Here are some results using this method in-game, with absolutely NO editing within the GECK.* The DEM that was used covers area around Reno, NV.

  • http://img690.imageshack.us/img690/5637/heightmaplod4.jpg

  • http://img217.imageshack.us/img217/5182/heightmaplod5.jpg

  • http://img812.imageshack.us/img812/487/heightmaplod3.jpg

  • http://img714.imageshack.us/img714/9724/heightmaplod2.jpg

  • http://img836.imageshack.us/img836/7975/heightmaplod1.jpg


*Terrain meshes were generated in order for the heightmap to be visible from a distance. That is all.

Tools you will need:

 

  • Photoshop. Now FREE to download! (Link) Huzzah

The Tutorial, proper:

  • 1) Go to the USGS website and locate their NED 1 arc second download tool (LINK);
    • Select the state and county in which you are interested.
    • 1/3 arc sec offers greater resolution than 1 arc sec. 1/9 arc sec offers even greater resolution (if it is available). Bear in mind the size of the worldspace you would like to edit and figure out how much coverage and resolution you should really need. The size of the Mojave wasteland, while covering Vegas to the North and all the way South to Nipton in California obviously does not represent real-world, to-scale terrain. Liberties can and should be taken for practical purposes.
    • Absolutely always download the 'arcgrid' format.
  • 2) Import the DEM data from the package you should have downloaded from the USGS into VTP. Go to "Layer" on the menu bar, then "import data," then "Elevation."
    • Inspect the DEM. On the menu bar, pull down the "Elevation" tab and select "Fill in unknown areas." This should correct no-return values. Even if the DEM looks fine, it's a good idea, and you shouldn't have to look at a histogram to see if some data are outliers in order to correct them.
    • Export you DEM as a BMP. Go to "Elevation," "Export data," then select BMP.
  • 3) In Photoshop, open up your BMP image (it could be very large depending on what resolution DEM you have, like >100mb!) You should also note that the image has flipped vertically.
    • Select your region of interest, bearing in mind that quads within the GECK (named according to this map) are 1024x1024 pixels across at 72 pixel resolution.
    • Go to "Image," "Mode" then select 16-bit. If your image is not grayscale, make it so (go to "Image" then "mode" and select grayscale. Select yes to discard color information.) This is an important step. The GECK reads RAW, 16-bit data. The DEM you have just downloaded is only 8-bit. 8-bit data is much coarser than 16-bit. Banding will most likely occur over flat areas of ground in 8-bit imagery. Here's how you can correct this:
    • Go to "Image," "Adjustments," and select "Gradient Map." Make sure 'dithering' is enabled (either in the dialogue box or properties). This will apply the selected gradient over the entire range of values within your image resulting in a smoother, superior heightmap. *IMPORTANT* Choose appropriate colors for your lowest and highest values for your gradient map in the color boxes on the toolbar. I find that a total range of values between 10% and 35% gray (25 brightness values range) yields close to satisfactory results once you import into the GECK. Higher values = probably higher than Jacobstown, and lower = definitely underwater. This process might need to be repeated with different values to your liking and depending on the absolute values of your elevation in your DEM.
    • *IMPORTANT* Export your correctly sized images in this format, exactly: 16-bit, grayscale, RAW, non-interleaved, IBM bit order. If everything is formatted correctly they will be 2 MB each. Anything else will likely crash the GECK. Name them according to the map above. The Mojave Wasteland does not cover a playable area in excess of four quads (I think...anything more just seems waaaaay too big, and who would want to spend time working on something that large anyway?)
    • For importing large heightmaps (>2x2 quads) please check out TESAnnwyn. The GECK is a memory hog. We give what we can, but sometimes it just asks for too much.


...and you should be ready to import your images into the GECK!*


*The resulting heightmap is probably bumpy and looks noisy. However, the larger scale elevation changes are preserved. If one were to apply a blur effect to the image in photoshop you risk losing elevation data. HOWEVER applying a Gaussian blur with pixel radius of 1.0 and greater removes most noise. This was done to the heightmap data used in the example images.

 

http://img694.imageshack.us/img694/9623/heightmaplod12.jpg

Edited by TrickyVein
Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 101
  • Created
  • Last Reply

Top Posters In This Topic

  • 3 months later...

I've provided the link now to where you can download the DEM data. So sorry it wasn't there before! That's an awful important step.

 

So I've followed the tutorial, but once I am finished in Photoshop and save as a RAW file I am getting a 6 M file instead of 2 M. Any suggestions?

 

I started with the following image in VTBuilder:

 

http://www.thegeekenders.com/resources/FO2161/s1.jpg

 

Then this is what I got in Photoshop after saving as a BMP:

 

http://www.thegeekenders.com/resources/FO2161/s2.png

 

Then going down to my area at 1024 x 1024:

 

http://www.thegeekenders.com/resources/FO2161/s3.jpg

 

Finally after switching to 16 bit, applying gradient and Gaussian blur:

 

http://www.thegeekenders.com/resources/FO2161/s4.png

 

This is what I get when I do a save as in Photoshop:

 

http://www.thegeekenders.com/resources/FO2161/s5.jpg

Link to comment
Share on other sites

Hey Dakcenturi,

 

Your images *look* fine. This (getting 6mb instead of 2mb RAW images) is pretty common I've found, and I think here's why:

 

My guess is that you might not have switched the mode of the image to grayscale before converting to 16 bit. When you first open up the bitmap into pshop, try doing this first. If that doesn't work, I'll dot my Is and cross my Ts and see if there's something I've left out of the turtorial.

Link to comment
Share on other sites

That was exactly it. However, I am still crashing the GECK when I import. Just to make sure I am doing the import correctly:

 

1) Load up My ESP

2) Go to World > Heightmap Editing

3) Select the Worldspace I want to import the heightmap I created into

4) In heightmap editor go to File > Import

5) Click Yes to the import prompt

 

That is as far as I get and then it crashes. Any thoughts?

Link to comment
Share on other sites

What is the file called? Is it named correctly?

 

Also, the heightmap editor will preview the image if it's importable. If you don't see your image when you open up the editor, it probs won't import.

 

I've found that it's better to work always from the .bmp and save to a new RAW image than open up your RAW image and alter it, though I have been able to import my RAW images into photoshop specifying the correct settings, then exporting/saving them over.

 

Also, what photoshop cs are you using? I don't know if there's a difference between the photoshop raw 'PRAW' and the 'RAW' which the GECK uses. I use CS2, which saves a 'RAW.'

 

The GECK, this process is so exacting and unforgiving sometimes when I don't know what's running amok I just start the process over :|

Edited by TrickyVein
Link to comment
Share on other sites

Ok, the issue was with the file naming. For Photoshop I am using CS3. Got that, now... I need to figure out how to smooth it all out. Once it is in the GECK it is all ridged and multilevel. Am I missing something or did you smooth out your terrain in the Heightmap Editor with the smooth tool?

 

See here for what I'm referring to.

 

http://www.thegeekenders.com/resources/FO2161/test.jpg

 

Also, it seems like I can only get 4 images added at one time (0_0, -1_0, -1_-1, 0_-1) can I not add the other areas outside of those?

 

Finally how do you get the four squares to line up correctly I tried but ended up with them being off a bit and then have a big cross right at 0_0 through the terrain.

 

http://www.thegeekenders.com/resources/FO2161/test2.jpg

Link to comment
Share on other sites

Check the settings of the filters that you're using in photoshop. Blurring could be effecting the 'edges' of your image. Maybe its applying the gradient map that's doing it.

 

A clever workaround is to create a 2048x2048 image then cut => paste quarters of it into new 1024x1024 images when you're finished editing the 2048x2048 bmp.

 

Loading more than four quads into the heightmap editor at a time could be extremely memory intensive. I'd be curious to see just how many quads you could work across though.

 

It also looks like the amplitude of your heightmap is large, giving you pretty noticeable banding, or jagged looking terrain. You shouldn't have to use any tools inside of the GECK's heightmap editor (which is kinda the whole point) because it's buggy. At some point, there's simply no way to get around it. 16 bit imagery gives you a a total of 65536 height values, which is << however many game units you have to work across inside of the GECK from sea to mountaintop. But if you can fit those ~60k height values into a smaller range it should look more natural-like. That is, when you apply the gradient map, choose a smaller range of values.

 

The banding could also be an artifact of the DEM, which is itself imperfect. Sometimes the smaller scale elevation changes aren't detected across a large, flat area. Applying the 16 bit gradient is a step towards trying to correct for this.

Edited by TrickyVein
Link to comment
Share on other sites

This is really strange.

 

I'm making a third attempt at this tutorial. I am crashing upon importing the RAW in the heightmap editor. It seems as right as can be; I followed all steps exactly this time, aside from:

 

a. Select your region of interest, bearing in mind that quads within the GECK (named according to this map) are 1024x1024 pixels across at 72 pixel resolution.

 

because you did not specify HOW to "Select" an "area" of the image for dividing (into 4 1024x1024 pieces of the original 2048x2048 bmp?)

 

 

But yes, anyway, the RAW came out to be 2 mb, 1024x10024. I simply wanted to test if it would import properly, then start tweaking and ironing out the details. But the GECK crashes. Here is a screen of the bmp before saving as 16 bit grayscale RAW:

 

http://i1238.photobucket.com/albums/ff500/jeux793/Radiant%20Flux%20Screens/RAWimageproblem.jpg

 

 

 

Something else I've wanted to ask. Your tutorial is very in-depth in regards to DEMs, RAWs, and heightmaps, but you do not explain much in relation to worldspace setup. Ideal cell size, usable dimensions, ideal block count (for LOD generation), overall size of the worldspace once imported....I basically have been going off what you stated in regards to not being larger than 4 quads, and the New Vegas worldspace. Do you have any more specific criteria, so I can plan out/control how large or how small my worldspaces will be once this heightmap importing process is perfected?

 

 

...apologies for all the questions. Thanks.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...