# A Better Explanation for Perlin Noise?

I’ve been spending hours trying to understand what perlin noise is, but I can’t quite wrap my head around it. I’m really interested in a better explanation.

# What I know

• What “Perlin Noise” is
• What it returns

# What I want to know

• What does it do?
• What is the formula for the algorithm?
• What do I do with the returned information (-0.5, 0.5)
• What does the X, Y and Z arguments mean and what should I input for each?
• How should I implement it?

I’m interested in some explanations and some code examples in simplified terms.

2 Likes

I did a talk at RDC this year about procedural generation using Perlin Noise:

All the code used in the video above can be find in this GitHub repo.

What is the formula?

What does the X, Y, and Z arguments mean?
The video covers this, but I don’t go into using ‘Z’ except for the Q&A afterward (which isn’t in the video unfortunately). But basically this describes the values from which you want to derive your noise value. The Perlin Noise function is a “pure” function, which means that it will always give the same output if you give it the same input. Thus, it’s really useful to use coordinate locations as the arguments to the noise function.

7 Likes

While I absolutely recommend watching Clone trooper’s talk about procedural generation, I would also like to add a few things.

On an abstract level, you can thing of perlin noise as a random number generator that outputs a value between -.5 and .5, and will always return the same value if it’s given the same input. The useful thing about perlin noise is that “nearby” inputs produce similar outputs, hence allowing it to simulate hills and etc. You don’t need to have an understanding of exactly how it’s calculated and how it works to use this algorithm.

It’s not only for procedural generation though.

I am using noise in a project of mine to augment animations with a bit of randomness, but I don’t want the animation jumping between offset values, as would happen with “normal” random numbers. This could also be achieved with other functions, but noise suits my use case perfectly.
I am also using it to slightly offset the colour of blocks around a minecraft-style map, giving a nice texture to everything and making the map a lot more interesting. I can simply use the block coordinates as the inputs (scaled down/with a reduced frequency), and it has many desirable properties. Nearby blocks have similar colours, and I don’t need to sync between clients because they are all using the same inputs anyway. Traditional random numbers would be a huge headache, requiring syncing (if I want everything the same on each client) and causing a much more (ironically) noisy and messy result.