Perlin 2-d noise problem
kholdstayr

I've been experimenting with random heightmaps using noise functions. I've implemented one based off of the Diamond-Square algorithm and now I want to try Perlin Noise. The problem is that I find Perlin Noise a bit confusing and the official code at Perlin's website is over my head.

So, I've been following the guide at this website:
http://www.cs.cmu.edu/~mzucker/code/perlin-noise-math-faq.html

However, after implementing everything talked about on that site I am not getting satisfactory images. I am thinking it is because I am not using a good random function for the code. I tried a random function from this website: http://freespace.virgin.net/hugo.elias/models/m_perlin.htm and one other one. I've attached two screenshots to this post that shows the noise effects I am getting with two different random functions.

I also have a question. If you notice the first link I displayed, it talks about how the Perlin Noise is implemented on a plane with real numbers. Obviously, an array full of color values doesn't have real number coordinates. So, I set up a scale value and divide my array coordinates by the scale value to get a real number distribution. For example, on my 500x500 array, my scale might be 100 for example. I take my array coordinate, like say 50,50, and turn it into a real number by dividing 50 / 100 = 0.5,0.5 .

I am really not sure of what to do with the system on that page because of the real number plane. This could be another reason why my images are not working. If you notice the attached images they are obviously tiled, which is due to the scale system I mentioned above. At each scale increment you get an obvious tiling effect.

miran

Attached is my 2D Perlin noise generator, based on the code from Hugo Elias. I use this module all the time. An example that shows how it's used is included.

The code should be pretty much self explanatory. The exposed noise function returns a value in the range [-1..+1] multiplied by amplitude. What you do with it and what input you feed it is up to you.

Use the frequency parameter to zoom in/out of the noise plane, persistence, lacunarity and number of octaves (up to 8) to control the smoothness/detail of the noise and phase to move around the noise space. You can pass the output through various other functions such as abs, square, sin and so on to get different effects that will make the texture look like marble, wood, lava, mountain ridges, etc.

To make a heightmap, just use the noise function once instead of three times (for each colour channel) as I did in the example.

To make the texture tileable, you simply have to crossfade at the borders. Google it...

The example program should look like this:

http://www.allegro.cc/files/attachment/592394

kholdstayr

Just for the record here I managed to implement some Perlin noise last night by using the "layman's version" of a Perlin noise generator (the same way you have done it). Hugo's site, despite being rather descriptive, partially confused me so I had to use this http://student.kuleuven.be/~m0216922/CG/randomnoise.html site as well as Hugo's site together to implement it. Thanks for demonstrating your program though.

The version I was attempting before (the "real" Perlin way) seems to be a one pass method. You add 2-d vectors together and do some averaging with the vectors on an S curve and get the final pixel result. Nothing on that page mentioned octaves and it seems to mostly match the code that is in Perlin's actual C program example. Have you looked at this site yet ttp://www.cs.cmu.edu/~mzucker/code/perlin-noise-math-faq.html ?

It doesn't seem like adding octaves is required for that method and the math required to make the noise is more advanced so it seems possible.

*****EDIT****************

After scratching my head for a couple of hours I found my mistakes and now I have REAL Perlin working. It is indeed a one pass algorithm and does not use octave mashing to get a usable image. Here is a result from my "real" Perlin noise generator:
http://www.allegro.cc/files/attachment/592400

Thread #591965. Printed from Allegro.cc