Perlin noise

Posted on November 20, 2014

My last project has been the World generator. This project uses perlin noise algorithm to generate a world. Perlin noise is a wide used algorithm in procedural generation (Minecraft uses it) so I'm going to explain how this is made.

Many people have used random number generators to generate textures. Random number generators certainly have their uses, but at times their output can be too harsh to appear natural. Perlin noise is a function which has a very wide range of uses, more than I can think of, but basically anywhere where you need something to look natural in origin.

If you look at many things in nature, you will notice that they are fractal. They have various levels of detail. A common example is the outline of a mountain range. It contains large variations in height (the mountains), medium variations (hills), small variations (boulders), tiny variations (stones)... you could go on. Look at almost anything: the distribution of patchy grass on a field, waves in the sea, the movements of an ant, the movement of branches of a tree, patterns in marble, winds. All these phenomena exhibit the same pattern of large and small variations. The Perlin Noise function recreates this by simply adding up noisy functions at a range of different scales.

A noise function is essentially a seeded random number generator. It takes an integer as a parameter, and returns a random number based on that parameter. If you pass it the same parameter twice, it produces the same number twice. It is very important that it behaves in this way, otherwise the Perlin function will simply produce nonsense. By smoothly interpolating between the values, we can define a continuous function that takes a non-integer as a parameter.

Now, if you take lots of such smooth functions, with various frequencies and amplitudes (called octaves), you can add them all together to create a nice noisy function. This is the Perlin Noise Function.

Click over the noise to reload it with another seed.

You can, of course, do the same in 2 dimensions, interpolating the 2D noise function. Then, a height map is generated, and you can color it depending on the height.

On this image, the same height map is rendered 4 different ways. The top left render paints it with a blue-cyan-yellow-green-grey-white gradient, and appears to be an earth drawing. Top right render uses a colour spectrum, similar to heat maps. The left bottom one renders it as a level curve. The right bottom one uses a threshold, and the result is similar to clouds. There are lots of possibilites rendering the map, for example, using a sine function over the height:

At last, you can use as many octaves as you want. The more octaves you use, the sharper the height map will be:

Hope you like this explanation, you can get more info about perlin noise at, the main reference I've used. Now, you can try it yourself!

Tagged as instructive, generator, project | View comments

I'm back!

Posted on November 19, 2014

Hey! It may seem that I'm totally out but it isn't! Indeed, I'm doing lot of things right now. I have been working at University of Seville with a research contract this summer, and now I'm on a collaboration scholarship while I finish my degree.

The research experience has been fascinating, my job consisted on developing an advanced Faceted Search browser for schools on Andalusia using Open Data and Structured Markup, and implementing social media analysis techniques. Taking tweets from a Twitter query, I was able to identify relevant terms, and cluster them into similar groups. I worked with algorithms such as Latent Dirichlet Allocation, Latent Semantic Analysis, k-means... I also fought against Mahout and Hadoop on Windows.

I am really grateful with Dynamic Area, for letting me use Opileaks for free. Opileak is a social media analysis tool, that allows to create queries against Twitter, Facebook, Youtube... and taking the results: raw documents, relevant terms, timeline evolution and sentiment analysis.

I couldn't have done this without the support and efforts of Computer Languages and Systems Department, letting me use their remote computers, and a research facility.

I have developed new personal projects (of course), that I'm going to upload to this website soon, so stay tuned!

Tagged as meta | View comments

Hello, blog

Posted on November 03, 2013

The idea of adding a blog to my portfolio was in the air since I designed it. Every time I finish a project, I think it would be awesome to explain how I made it.

I was going to use WordPress, but the idea of making it from the ground up has been more challenging.

Tagged as meta | View comments

Private page