Jump to content


Photo

DEM to Heightmap to Unity terrain


  • Please log in to reply
15 replies to this topic

#1 LasseThid

LasseThid

    Advanced Member

  • Members
  • PipPipPip
  • 151 posts
  • LocationMölndal, Sweden

Posted 04 February 2014 - 09:10 PM

I had a slow day at work and spent most of the time trying to find out how to create a heightmap that I can import into Unity, preferably from a DEM file.

I found a great tutorial that let you take any DEM file and create a heightmap from it that you can import into Unity. It's a bit of a hassle, but for those of you who want to give it a try you can find the tutorial here: http://www.scribd.co...ghtmap-Tutorial

One thing though... you need to somehow make your overhead match the heighmap perfectly and that's a PITA!!!

I used Global Mapper and zoomed into the area I wanted to use. Added the world data and grabbed a screenshot, closed that layer and made another screenshot of the terrain. I then imported the DEM in to MicroDEM and zoomed in to the same area and changed the size of the window to make it match the screenshot from Global Mapper as closely as possible. After that I created the heightmap image and saved as a GEOtiff.

Then I went to Photoshop, opened up the two screenshots and the GEOtiff, pasted them into separate layers and alligned them. Then I cropped the image and resized to 2049x2049 pixels and save the overhead as a jpeg, the heightmap I converted to 16-bit grey scale and saved as a Photoshop RAW.

After that I went back to Global Mapper and opened up the DEM, zoomed to the area I want to use and loaded the wold data image and measure the distance between the edges of my overhead. Then I created topolines and checked the difference in height between the lowest and the highest part of the area.

Now I start Unity, create a new project, create Terrain and set to the measurement I got from Global Mapper, Import RAW-file. Next I imported the Overhead as a new Asset, switch to textures and created a new texture with my overhead and set the size to the same as my plot.

Added a directional light object and voíla...

As I said, a pain in the behind, but worth it if you want to work with terrain from a DEM and don't want to wait for the Terrain importer to be released...  :lol:

Unity_Castle_Pines.jpg

And yes, that's my nemesis... Castle Pines Golf Club... :lol:


Mobo: Asus Sabertooth P67 CPU: Intel Core i7-2600K CPU Cooler: Corsair Hydro H60 RAM: Corsair Vengeance DDR 3 1600 MHz 8GB GPU: MSI GeForce 970 GTX Gaming 4G Sound: Creative Soundblaster Extreme Gamer SSD: OCZ Agility 3 64GB HDD: 1x 2TB, 1x 1TB, 1x 320 GB Western Digital PSU: Corsair CX 600W Chassi: Thermaltake Aguila


#2 olazaboll

olazaboll

    Advanced Member

  • Members
  • PipPipPip
  • 559 posts

Posted 04 February 2014 - 10:41 PM

Lasse ... can´t you finnish that CPGC project once and for all ..... so you can start on Hills or something   :lol:



#3 olazaboll

olazaboll

    Advanced Member

  • Members
  • PipPipPip
  • 559 posts

Posted 04 February 2014 - 10:46 PM

No frankly ... I'm happy that there are some "Swedes" that understand this part of the game(s)... bcs I'm sure lost as hell .... If I get in Swedish, thoguh, I might be able to do it myself .. ( even if Im a "Zero/Eight :) .. ) My hopes is that I one day manage to import one of my APCD projects and get a PP/CF version of it 



#4 shimonko

shimonko

    Advanced Member

  • Members
  • PipPipPip
  • 1,718 posts

Posted 05 February 2014 - 02:22 AM

Nice. If you have GlobalMapper though, you shouldn't need to bother with MicroDem, or was there some issue? Because if you stay in GlobalMapper, it will align the two for you. It looks like you have a white line at the edge of your heightmap btw.



#5 LasseThid

LasseThid

    Advanced Member

  • Members
  • PipPipPip
  • 151 posts
  • LocationMölndal, Sweden

Posted 05 February 2014 - 05:50 AM

Shimonko: I downloaded Global Mapper from their site and you can use it for free for a while.
MicroDEM is able to create a grey scale heightmap for you, which you can't do with Global Mapper, hence the need for it.
I'm aware of the white part in the heightmap. I made it 2049x2049, but since the course is wider than it is higher I made the heightmap rectangular which cause the problem, but since this was just a test I didn't bother fixing it.

 

Ola: Of course I can explain it to you in swedish and I can also try to answer any questions you might have.
Not sure if/when I might actually get the thumb out of my butt and finish Castle Pines though... LOL
The lack of DEM's for Sweden makes it tough to do a good job on swedish courses.
Perhaps once we can import elevation data from Google Earth it might happen.

Btw, we stopped calling you 08:or a long time ago, now it's 99:or since you're not 100%  :lol:  (Swedish joke)


Mobo: Asus Sabertooth P67 CPU: Intel Core i7-2600K CPU Cooler: Corsair Hydro H60 RAM: Corsair Vengeance DDR 3 1600 MHz 8GB GPU: MSI GeForce 970 GTX Gaming 4G Sound: Creative Soundblaster Extreme Gamer SSD: OCZ Agility 3 64GB HDD: 1x 2TB, 1x 1TB, 1x 320 GB Western Digital PSU: Corsair CX 600W Chassi: Thermaltake Aguila


#6 olazaboll

olazaboll

    Advanced Member

  • Members
  • PipPipPip
  • 559 posts

Posted 05 February 2014 - 11:22 AM

Thx Lasse ... I let you know when the day come , and I might need some assistance ... 



#7 shimonko

shimonko

    Advanced Member

  • Members
  • PipPipPip
  • 1,718 posts

Posted 06 February 2014 - 03:05 AM

LasseThid, on 05 Feb 2014 - 05:50 AM, said:

Shimonko: I downloaded Global Mapper from their site and you can use it for free for a while.
MicroDEM is able to create a grey scale heightmap for you, which you can't do with Global Mapper, hence the need for it.

 

Ok, sounds like a trial limitation not being able to export.

When you're in Unity, might be worth checking (with the terrain height sampler tool) that your heights are as you expect. It sounds like you took a screenshot a heightmap image, and if so, I suspect the some gamma or maybe 16 to 8 bit clipboard conversion along the way may shift the greys. Not sure, just a suspicion.



#8 Joe Habiger

Joe Habiger

    Advanced Member

  • Members
  • PipPipPip
  • 1,037 posts
  • LocationCoon Rapids, MN

Posted 06 February 2014 - 06:04 PM

shimonko, on 06 Feb 2014 - 03:05 AM, said:

Ok, sounds like a trial limitation not being able to export.

When you're in Unity, might be worth checking (with the terrain height sampler tool) that your heights are as you expect. It sounds like you took a screenshot a heightmap image, and if so, I suspect the some gamma or maybe 16 to 8 bit clipboard conversion along the way may shift the greys. Not sure, just a suspicion.

No... You can export a heightmap (and overhead image that goes with it) from global mapper but I don't know of the exact steps from work. I'll try to get it perfect tonight and then do a tutorial on it but I need to make sure it's perfect first because I don't want to show people the wrong way.


  • AMD Ryzen 7 5800X
  • Asus ROG Strix B550-F Gaming
  • Sapphire Nitro+ SE AMD Radeon 6800XT
  • G.Skill Trident Z Royal RGB 16GB DDR4-3600
  • Sabrent 2TB Rocket NVMe 4.0 Gen 4 PCIe M.2
  • Samsung 970 EVO Plus 1TB SSD M.2 NVMe
  • Samsung 850 EVO 512GB SSD
  • Sound Blaster ZX Soundcard
  • EVGA 750 Gold Power Supply
  • Fractal Design Meshify S2 Case
  • Cooler Master MasterLiquid ML360R
  • "43 inch Vizio 4k Monitor

#9 shimonko

shimonko

    Advanced Member

  • Members
  • PipPipPip
  • 1,718 posts

Posted 06 February 2014 - 10:19 PM

Are you saying the trial version of Global Mapper can export a heightmap? Their site says the trial won't export anything.



#10 Joe Habiger

Joe Habiger

    Advanced Member

  • Members
  • PipPipPip
  • 1,037 posts
  • LocationCoon Rapids, MN

Posted 06 February 2014 - 11:45 PM

shimonko, on 06 Feb 2014 - 10:19 PM, said:

Are you saying the trial version of Global Mapper can export a heightmap? Their site says the trial won't export anything.

Oh.. I don't have the trial version..hehe, I didn't know that.


  • AMD Ryzen 7 5800X
  • Asus ROG Strix B550-F Gaming
  • Sapphire Nitro+ SE AMD Radeon 6800XT
  • G.Skill Trident Z Royal RGB 16GB DDR4-3600
  • Sabrent 2TB Rocket NVMe 4.0 Gen 4 PCIe M.2
  • Samsung 970 EVO Plus 1TB SSD M.2 NVMe
  • Samsung 850 EVO 512GB SSD
  • Sound Blaster ZX Soundcard
  • EVGA 750 Gold Power Supply
  • Fractal Design Meshify S2 Case
  • Cooler Master MasterLiquid ML360R
  • "43 inch Vizio 4k Monitor

#11 LasseThid

LasseThid

    Advanced Member

  • Members
  • PipPipPip
  • 151 posts
  • LocationMölndal, Sweden

Posted 07 February 2014 - 08:26 AM

I guess that's why they used MicroDEM, because it can create and export a heightmap and the program is free to use.


Mobo: Asus Sabertooth P67 CPU: Intel Core i7-2600K CPU Cooler: Corsair Hydro H60 RAM: Corsair Vengeance DDR 3 1600 MHz 8GB GPU: MSI GeForce 970 GTX Gaming 4G Sound: Creative Soundblaster Extreme Gamer SSD: OCZ Agility 3 64GB HDD: 1x 2TB, 1x 1TB, 1x 320 GB Western Digital PSU: Corsair CX 600W Chassi: Thermaltake Aguila


#12 Jimbobh

Jimbobh

    Advanced Member

  • Members
  • PipPipPip
  • 539 posts
  • LocationMaine

Posted 25 February 2015 - 01:13 AM

LasseThid, on 04 Feb 2014 - 9:10 PM, said:



I had a slow day at work and spent most of the time trying to find out how to create a heightmap that I can import into Unity, preferably from a DEM file.

I found a great tutorial that let you take any DEM file and create a heightmap from it that you can import into Unity. It's a bit of a hassle, but for those of you who want to give it a try you can find the tutorial here: http://www.scribd.co...ghtmap-Tutorial

One thing though... you need to somehow make your overhead match the heighmap perfectly and that's a PITA!!!

I used Global Mapper and zoomed into the area I wanted to use. Added the world data and grabbed a screenshot, closed that layer and made another screenshot of the terrain. I then imported the DEM in to MicroDEM and zoomed in to the same area and changed the size of the window to make it match the screenshot from Global Mapper as closely as possible. After that I created the heightmap image and saved as a GEOtiff.

Then I went to Photoshop, opened up the two screenshots and the GEOtiff, pasted them into separate layers and alligned them. Then I cropped the image and resized to 2049x2049 pixels and save the overhead as a jpeg, the heightmap I converted to 16-bit grey scale and saved as a Photoshop RAW.

After that I went back to Global Mapper and opened up the DEM, zoomed to the area I want to use and loaded the wold data image and measure the distance between the edges of my overhead. Then I created topolines and checked the difference in height between the lowest and the highest part of the area.

Now I start Unity, create a new project, create Terrain and set to the measurement I got from Global Mapper, Import RAW-file. Next I imported the Overhead as a new Asset, switch to textures and created a new texture with my overhead and set the size to the same as my plot.

Added a directional light object and voíla...

As I said, a pain in the behind, but worth it if you want to work with terrain from a DEM and don't want to wait for the Terrain importer to be released...  :lol:

Unity_Castle_Pines.jpg

And yes, that's my nemesis... Castle Pines Golf Club... :lol:

I have been working on it for you too, it has just taken me a while. I have 191 high res. jpg's stitched together and I still have to confirm if the image is lined up close enough to the terrain, or I could just hand over what I have and you can figure it out,  ;)  Hard to tell with this plot of land and the holes spread so far apart, and me not being too familiar with the course. Just thought I would give you an update.

 

Unity_Castle_Pines_2_zpsrxmovpd4.jpg


Gigabyte ga-z68x-ud3h-b3 Motherboard

Intel Core i5-2400 CPU@3.1GHz 3.70GHz

GeForce GTX 1050 Ti
16GB Ram   (2)G.Skill Ripjaws F3-10666L9S-8GBXL
Windows 7 Home Premium


#13 LasseThid

LasseThid

    Advanced Member

  • Members
  • PipPipPip
  • 151 posts
  • LocationMölndal, Sweden

Posted 25 February 2015 - 02:46 PM

Go for it Jimboh... Or if you want to send it over I can take a look at it.

Castle Pines is one of the first courses I really loved in Links and I've been tinkering with it on and off for the last 15 years with the APCD for Links.

The problem is that the best DEM's and Google Earth elevations I've found, left me a lot to desire and you need a rectangular plot which Unity doesn't really like.

Besides with no CF and no possibility to play test there's only so much you can do in Unity.


Mobo: Asus Sabertooth P67 CPU: Intel Core i7-2600K CPU Cooler: Corsair Hydro H60 RAM: Corsair Vengeance DDR 3 1600 MHz 8GB GPU: MSI GeForce 970 GTX Gaming 4G Sound: Creative Soundblaster Extreme Gamer SSD: OCZ Agility 3 64GB HDD: 1x 2TB, 1x 1TB, 1x 320 GB Western Digital PSU: Corsair CX 600W Chassi: Thermaltake Aguila


#14 M Rose

M Rose

    Advanced Member

  • Members
  • PipPipPip
  • 1,918 posts
  • LocationMelbourne, Australia

Posted 03 March 2015 - 01:11 AM

I've got a version of Castle Pines in APCD and it's kicking my behind! Good luck to whomever is working on it for this format. I may try something flatter :)


VG2 • PG • 2k21 • 2019 • Links • GBC • JN5


#15 LasseThid

LasseThid

    Advanced Member

  • Members
  • PipPipPip
  • 151 posts
  • LocationMölndal, Sweden

Posted 03 March 2015 - 06:07 PM

I just downloaded and installed Unity 5.0, but their license server is under a wee bit of pressure at the moment... lol...

Will try to have a look at the file Jimbobh sent me later.


Mobo: Asus Sabertooth P67 CPU: Intel Core i7-2600K CPU Cooler: Corsair Hydro H60 RAM: Corsair Vengeance DDR 3 1600 MHz 8GB GPU: MSI GeForce 970 GTX Gaming 4G Sound: Creative Soundblaster Extreme Gamer SSD: OCZ Agility 3 64GB HDD: 1x 2TB, 1x 1TB, 1x 320 GB Western Digital PSU: Corsair CX 600W Chassi: Thermaltake Aguila


#16 TheOtherRick

TheOtherRick

    Advanced Member

  • Members
  • PipPipPip
  • 214 posts
  • LocationHeart of Dixie

Posted 14 March 2015 - 05:12 PM

The link you provided for the tutorial in your original post is no longer viable...  :(


Ye Olde Computing Machine
CPU - Intel i5-8600K Six Core @ 3.60 GHz
MB - ASRock Z370 Pro 4

RAM - G.Skill Ripjaws 32 GB DDR4 2666 MHz
OS - Windows 10 Home  (64-bit)
GPU - Nvidia GeForce GTX 1060 6GB





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users