Sign in to follow this  

Code for fractal heightmap generation?

This topic is 1597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Fractal heightmap terrain is a common algorithm.  I was wondering if there was a pre-existing code library, or even just a snippet, that did this?  It could save me a few days of experimentation if there's already something out there I can use and modify.

 

Thanks!

Share this post


Link to post
Share on other sites

If you don't want to muck around too much with noise you can check out the mid-point displacement algorithm (described here: http://www.gameprogrammer.com/fractal.html with height-map source here: http://pastie.org/1927076 ). Otherwise (as the above posters can tell you) you can check out perlin noise ( http://mrl.nyu.edu/~perlin/noise/ ) and use a simple fractal algorithm like fractional brownian motion like so: 

float fBm( Vector3 vertex, float H, float lacunarity, int octaves )
{
float value = 0.0;

for (i=0; i<octaves; i++) {
value += noise(vertex) * pow( lacunarity, -H*i );
vertex *= lacunarity;
}

return value;
}

to create cool organic patterns. Creating a height-map is as simple as using the result of an algorithm like that as a color and setting a pixel on your desired map to that color...

Good luck. 

Edited by multifractal

Share this post


Link to post
Share on other sites

It's not exactly what you are asking for, but a generation of heightmap technique based on hydrology as been presented at the siggreph 2013:

Terrain Generation Using Procedural Models Based on Hydrology, (paper)

It don't looks too complicated, so if you need a finite, precomputed terrain, I think it could be a good idea to consider it.

Share this post


Link to post
Share on other sites

This topic is 1597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this