Issue with importing raw heightmaps (made in photoshop)

I just want to make some temporary terrain and for that purpose I go in photoshop, create a new 1024x1024 16bit, greyscale image. I then render clouds, do some manipulation on it and save it as a raw file (macintosh format).

When I import heightmap in unity using the raw file above it imports almost fine except there are always jagged edges (as tall as the max height of the terrain) on two of the edges of the terrain.

Here is a screenshot of what happens...


Any idea what I can do to stop this from happening? It is terribly timeconsuming to flatten those areas out using the flatten height tool. Is there some other way of fixing it?

more ▼

asked Oct 31, 2009 at 05:13 AM

abdullah.ahmed gravatar image

252 10 12 23

(comments are locked)
10|3000 characters needed characters left

5 answers: sort voted first

The resolution of your heightmap needs to match that of the "Heightmap Resolution" field. Your screenshot shows a heightmap resolution of 2049, and yet you are supplying a 1024x1024 heightmap. You can fix this in a couple ways:

  1. create a 2049x2049 heightmap and import it
  2. change the heightmap resolution to 1025, and resize your heightmap to 1025x1025.

Optimally you would first set this resolution when you create the terrain asset in Unity, second, create a heightmap with the correct resolution, and third, import the heightmap.

Also, the heightma resolution clamps to specific sizes. You can not set it to 1024. If you enter that number into the field it will result in 1025. Resolutions of heightmaps follow the classic pattern of x+1, where x is a doubling number following this pattern: 2, 4, 8 etc... So heightmap resolutions are numbers like 257, 513, ,1025, 2049.

For an in depth explanation of Terrain Assets see the reference section of the documentation: http://unity3d.com/support/documentation/Components/terrain-UsingTerrains.html

more ▼

answered Nov 01, 2009 at 03:48 PM

aaron parr gravatar image

aaron parr
71 1 2 13

Thanks. I figured out that I need to make sure the heightmaps I am making are x+1 width and height in pixels as you mentioned above and that solves the issue.

Nov 01, 2009 at 04:14 PM abdullah.ahmed
(comments are locked)
10|3000 characters needed characters left

You want to see something really cool, open Photoshop (any flavor) create a height map /map, click file, save as, choose RAW, save the file, make sure you put a solid white number 1 in the upper left of the map image so that it stands out on the terrain, also make sure that when you do this save, you choose Non-interleaved order, otherwise the map is all screwy on import, see on Photoshop CS4 and even Photoshop 7, File Type is greyed out as PRAW and File Creator if greyed out as 8BIM, header is set to 0 by default. Ok, now in Unity, create a new blank terrain and import height map, choose the RAW exported file and apply it, you will now see that the terrain is horizontally flipped, verticaly flipped, and inverted, so Unity is improperly importing RAW heightmaps, you have to flip the item in Photoshop horizontally, the flip it vertically then import it into Unity, otherwise you will not be able to import it at all and have it correct.

more ▼

answered Dec 04, 2009 at 10:45 PM

zumwalt gravatar image

85 5 6 13

(comments are locked)
10|3000 characters needed characters left

If you're getting a "lip" on your terrain, what might fix it is to switch your Byte Order (in your RAW export dialog in Photoshop) from Mac to Windows - and do the same when importing your map. I've found that using Mac byte order will give you that annoying "lip"

more ▼

answered Feb 01, 2010 at 09:44 PM

JoeW gravatar image

21 4 4 6

(comments are locked)
10|3000 characters needed characters left

Some of your numbers don't match up. The terrain resolution is 2000x2000 with a height map resolution of 2049. Your texture is only 1024x1024. How wide is the area of the error? It could be because the resolution of the height map is 2049 instead of 2000 or the resolution of the terrain has to match the texture.

more ▼

answered Oct 31, 2009 at 09:26 PM

MSylvia gravatar image

189 8 14 24

(comments are locked)
10|3000 characters needed characters left

I see this is answered, but I keep getting directed here with my Google queries, so I figured I'd throw in what I've been searching for, for a while.....

I took a raw file from OpenSim and wanted to import it into Unity3D. Had the same jagged edges in the picture above, except it was the entire terrain. Problem was that the raw was RGB, and Unity only works with greyscale. I'm currently looking for a converter, asking if anyone knows about one here: http://answers.unity3d.com/questions/187059/convert-rgb-heightmap-to-greyscale.html?viewedQuestions=7652&viewedQuestions=8574.

more ▼

answered Nov 17, 2011 at 08:05 PM

zachypin gravatar image

121 98 75 75

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Oct 31, 2009 at 05:13 AM

Seen: 28195 times

Last Updated: Nov 17, 2011 at 08:05 PM