- Home /
Problem with heightmap and terrain height maxing out at 10000, proportions *Solved*
I will be the first one to recognize that I'm a n00b by all means but I generally am able to work around most problems on my own. However not this time.
I'm trying to import a real world terrain heightmap into unity and I have a problem with "scaling" it to the right proportions. The heightmap I'm using is originally a 32 bit (1025x1025 pixel) geotiff provided by the Norwegian Polar Data Center that I, in order to be able to use, have processed with the following line of code through gdal to maket it a 16 bit RAW file, which for some reason seems to work better than saving it as a 16-bit RAW file from photoshop (which hasn't worked for me at all):
gdal_translate –ot UInt16 –scale –of ENVI –outsize 1025 1025 P5.tif heightmap5.raw
I have no problem importing this RAW file into unity, however after import there seems to be an issue with proportions. The side of the original tif that I'm using in the real world is equal to about 5.2km and I would like it to be that measurement in the game world aswell, however in order for me to even see the terrain I, for a terrain with a width of 500 and length of 500 (which isn't nearly a 10th of what I would like), have to set the Terrain height to 10000 which is the maximum. And, I should say 10000 isn't near the real max height of the terrain which is more like 700 meters or so. So after tinkering around a bit I'm figuring that in order to get the side of my heightmap in the game world to match the length of the heightmap in the real world I would need to increase the terrain height well beyond 10000. I'm figuring this has got to do something with ratio between terrain height and width/length of the terrain since I'm able to scale it all down to smaller measurements (approx 10x10 widthxlength and 30~something) and still maintain what looks like the right proportions?*
So my question is:
How do I work around this? What is at fault? Is there some way to manipulate the heightmap so that the height-span in the map better equals the proportions of the real world?
And please remember I'm a n00b, so please explain accordingly! Oh and I would be greatful if you do have other general tips and tricks for me!
Cheers! And thanks in advance!
*I'm adding a picture (since it won't let me upload the tif) of the original heightmap (.tif) and a screenshot of the terrain in Unity where you can also see the settings, just to prove I'm not lying:
UPDATE 1 I'm starting to think the issue is that when converting the tif to a 16-bit RAW using the -scale command it automatically scales the height data in the tif to a range from 0-65535 (highest 16-bit number). Tips on how to counter this or other workarounds are welcome!
UPDATE 2 Solved Turns out I was right! And even solved the issue before this post has been moderated! It was the 16-bit conversion that was the problem! So I converted the 32-bit to 8-bit instead using:
-ot Byte
In gdal instead of
-ot UInt16
This solved the issue, since the height data then instead of 0-65535 scales to 0-255, more than enough headroom to scale my terrain as I like! Planning to leave this here in case someone else encounters the same problem.
[1]: /storage/temp/89605-p5.png
[2]: /storage/temp/89606-game.png
Your answer
Follow this Question
Related Questions
Controlling height when importing heightmaps 1 Answer
Import RAW height map not working 0 Answers
How to use Height Maps 2 Answers
Best way to get terrain positions from a given height range 2 Answers
Importing Heightmaps 1 Answer