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...

http://www.screencast.com/users/Abdullah.Ahmed/folders/Jing/media/f8a422f9-2851-45d4-8223-254db6b886c2

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?

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

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.

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.

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"

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: Convert RGB heightmap to greyscale - Unity Answers.