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.

5 Replies

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:

create a 2049x2049 heightmap and import it

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.

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.

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"

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.