terraineer SourceForge.net Logo


plasma (midpoint displacement)
v0.1; caminoix; 30.06.2006
v0.2; caminoix; 10.07.2006
v0.3; caminoix; 03.09.2006
download source | binary

plasma (midpoint displacement) heightmap


the plasma algorithm is pretty simple and well-known. i'd like to credit the person who invented it but unfortunatelly it seems to have become common knowledge to such extent that people can't any longer remember the actual author.

plasma is a recursive algorithm. here's how you do it:

1. take the corners of the map, and fill them with random values.

2. here the recursive part begins:

plasma (midpoint displacement) heightmap

2a. divide each side of your map in half.
fill the middle points with the average of the two ends: 1=(A+B)/2; 2=(B+C)/2; 3=(D+C)/2; 4=(A+D)/2;
fill the centre point with the average of the four corners: 5=(A+B+C+D)/4, and alter it slightly (midpoint displacement!)

2b. repeat 2a. with all the four rectangles you obtained: A154, 1B25, 52C3 and 453D.

and that's it! it's as easy as that! it's also fast, and as you can see, gives pretty neat results.

NOTE: with version 0.2, a new setting has been introduced: max. initial which lets you set the maximal height of the first 4 points (see 1.). unsurprisingly enough, it can change quite a bit so you're most welcome to experiment with it.

konqueror  valid xhtml  valid css  nemerle  opensource  gpl