I was always fascinated by games, and the problems game developers solve on a daily basis. One of the most interesting topics for me was procedural terrain generation. The idea of building a massive world purely described by algorithm looked very intriguing.

A couple of months ago I decided to get my head around it and understand how it’s done from the ground up. It turned out to be quite an interesting journey and I ended up giving a talk about it during one of our regular tech lunches at carwow. Several people asked if I’d write it up as a blog post, so here it is!

What is noise?

First of all, when I mention noise, I mean a function that receives a pair of coordinates and returns a floating-point value, usually between 0 and 1. In the image below, the elevation graph simply shows the change of noise output from 0 to 1, while the image graph uses grayscale for the same purpose with black and white representing 0 and 1 respectively. To generate regular noise, we just need to select a random value for each point. You can see the results of this in the first image below. But for our case of procedural generation, it’s too random.

Enter Perlin noise

So what exactly is Perlin noise? How is it different from regular noise?

P erlin noise is a type of gradient noise developed by Ken Perlin in 1983 as a result of his frustration with the “machine-like” look of computer graphics at the time.

You can see in the second example below that there is still ‘randomness’ to the image, but the gradients smooth out the differences.