Diamond Square Algorithm for random heightmap generation

Hello,

since this is my first post here, wanted to say hi :wink:
I’ve been reading these forums for a while now and finally decide to post something.

Since I’ve played with Terrain recently I decided to try and write some random terrain generators. I was looking in the web for a decent algorithm for the beginning and found this here:
http://www.gameprogrammer.com/fractal.html#heightmaps

So I thought I should give it a try and I added the algorithm to jMonkey, here are some results:

Imgur
Imgur
Imgur
Imgur

The splat texture mapping is pretty crappy though :stuck_out_tongue:

Overall the terrain isn’t very useful if you take it as whole, but it might be able to build some decent looking mountains if you use the generator for maybe a part of the terrain grid.

Here is the class, it extends from AbstractHeightMap, so very easy to use.
Just make a size power of 2 and call the load method.

Feel free to use it for what ever you like.

2 Likes

I just found out that JME already implemented this algorithm:

http://hub.jmonkeyengine.org/javadoc/com/jme3/terrain/heightmap/MidpointDisplacementHeightMap.html

Better stick with that! :slight_smile:
Sorry for the post, but I still learned something :smiley:

1 Like