Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Fill a 2D Array With Perlin Noise?

I've devised a small personal project to help me learn how to use Perlin Noise. This project involves filling a 2D array of r rows and c columns with random, coherent data generated with a Perlin Noise algorithm.

Now, I've just spent hours reading a wide variety of resources about generating Perlin Noise. However, it's all over my head and I'm totally lost. I understand the basic concept, but I don't have a clue how to begin implementing this in Java. I think it would be most helpful if someone could show me some well-commented code that accomplishes my goal so I can work backwards and apply it myself.

like image 206
Sonic42 Avatar asked Feb 01 '12 04:02

Sonic42


People also ask

How 2D Perlin noise is generated?

Perlin's approach to producing a noisy 2-dimensional terrain involves computing a random 2- dimensional gradient vector at each vertex of the grid with the eventual aim that the smoothed noise function have this gradient value.

What is 2D Perlin noise?

The Perlin Noise 2D modifier adds one-dimensional Perlin noise to the stroke. The modifier generates noisy displacements using 2D coordinates of stroke vertices as the input of the noise generator.

Is Perlin noise normally distributed?

But a perlin noise is normal distributed (ranges from -1 to 1, mean at 0) so it's not that easy.

What can you do with Perlin noise?

Perlin noise can be used to generate various effects with natural qualities, such as clouds, landscapes, and patterned textures like marble. Perlin noise has a more organic appearance because it produces a naturally ordered (“smooth”) sequence of pseudo-random numbers.


1 Answers

If you want a perfectly documented implementation, check out this. You can download the source code and open src\java\org\j3d\texture\procedural\PerlinNoiseGenerator.java to get your commented code. I take no credit for any of this. All I did was hunt around on Google a bit.

Since it's licensed under LGLPL, I'll also provide a direct link to it. (If I'm mistaken about what LGLPL means and my ability to do this, please notify me.)

like image 174
Zenexer Avatar answered Oct 16 '22 15:10

Zenexer