I'm trying to get my head around heightmap terrain generation. If I have a plane say 64 x 64 verts will I need to create a 64px by 64px greyscale heightmap in order to displace the geometry of the plane correctly?


1 Answer 1


You may be confusing some details. A height map is simply a 2D array of data. Each point represents 3 pieces of information: an x and y location and a number to represent the height at that point. For a simpler example, lets look at a 1D array of data that creates some 2D terrain. Each data point here will contain an x location and a number to represent the height at that point:

enter image description here

Pretty simple right? It's just a regular old graph. As you can see, the numbers on the x axis go up by tens. We could easily change that to go up by 100's or by .01's. Same goes for the data displayed on the y axis. We can scale those values however we like.

Basically, it's just numbers until you decide how you're going to visually represent it. So, saying a height map of 64px by 64px is already one step beyond where we need to go. Since a grayscale image is just another way to display the same data as a 3D height map. The data to represent each is coming from the same place.

enter image description here

Further, you don't even need a 1 to 1 relationship between data and display. You could have far more vertices than you have data points, or far fewer. They don't even need to be equally spaced.

For the most basic example: Yes, generate an array of [64][64] data points to make a grayscale image or a 3D heightmap. Each [x][y] of your array will correspond to the x, y of your vertices and the value stored in each [x][y] will represent the z value of your vertex.

  • \$\begingroup\$ Very clear informative answer, thank you. In effect it's just a 2D array of points being visualised. \$\endgroup\$ Dec 4, 2012 at 0:07
  • \$\begingroup\$ @CaiusEugene Correct. There are multiple ways to visualize it, a simple one being gray scale images. Where the "height" value is just visualized as a color between bottom (black) and top (white). \$\endgroup\$
    – House
    Dec 4, 2012 at 0:09
  • \$\begingroup\$ I'm working on creating a "good looking" eroded terrain, my attempts so far are looking awful, I think I may have the wrong approach but I'm irritating through my vertices and displacing there z value based on a pixel from a greyscale image. My results are all "jagged" and don't resemble the height mapped terrains I've seen elsewhere. What could I be overlooking in this case? \$\endgroup\$ Dec 4, 2012 at 0:13
  • 2
    \$\begingroup\$ That's likely a scale issue. You can try applying smoothing to the vertices after you've set them. Something like the diamond square algorithm could work. \$\endgroup\$
    – House
    Dec 4, 2012 at 0:23
  • \$\begingroup\$ Perfect solution by the looks of a quick google! Thanks @Byte56 \$\endgroup\$ Dec 4, 2012 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .