Fractal Heightmaps?

Blitz3D Forums/Blitz3D Programming/Fractal Heightmaps?

Gabriel(Posted 2003) [#1]
Does anyone have any code ( or pseudo code ) for doing this?

I read Hugo Elias' article on Perlin noise and wrote a blitz program to generate heightmaps that way. But there a couple of problems :

1) It's slow. I'm not aiming for realtime, but several minutes for a 1024x1024 texture is not up to scratch.

2) The landscapes are ugly.



I'm currently working my way though an article by Paul Martz, but it's slow going.


sswift(Posted 2003) [#2]
If it takes several minutes you programmed it wrong.

You don't need to write the image until you finish calculating the terrain. Store everything in an array of floats, operate on that, and output the numbers to the image at the end.

And Perlin noise terrains aren't ugly, but you do have to set the height multipliers for each level right or else you'll just end up with something flat and boring, or something way too hilly.

Of course maybe you think realistic terrains that have high and low areas and only vary in height from that a little are ugly. I dunno. I tohught they looked nice.

I was able to calculate a 64x64 perlin noise terrain in DARK BASIC in under 2 seconds. It will take 256 times as long to calculate a 1024x1024 terrain, but Blitz is also about a thousand times faster than Dark Basic, and that was on a 433mhz processor.

Post your code. Then people can suggest ways to optimize it.


Gabriel(Posted 2003) [#3]
I don't think it was my code that was making it slow. Since coding it myself, I've found that there was already a perlin noise function in the code archives. His version is slightly neater but it's no quicker. He used the same source, and he appears to be doing almost exactly the same thing. So feel free to see if that code is slow, it might be.

You may be right that I could get some better results if I fiddle with the values.


sswift(Posted 2003) [#4]
I don't know WHAT possessed me to spend the last four and a half hours on this, but here you go. :-)

http://www.blitzbasic.com/codearcs/codearcs.php?code=696


Gabriel(Posted 2003) [#5]
Wow, thanks. :D