Tuesday, February 20, 2007

Perlin Noise

Perlin noise is a useful technique to be aware of when making games. It’s useful for creating apparently random ‘noise’, which is restricted to a range of numbers. Some potential uses in games are:

  • Make a random looking heightmap of a mountainous area, without going outside certain bounds.
  • Create the jagged line for a lightning bolt between two exact points.
  • Apply a subtle random wander to the game camera to make it look like the camera is hand held, while still pointing generally at the target.
  • Create a tiling plasma texture.

Perlin noise works by starting with a straight line and recursively bisecting it. Each bisection point is shifted some random amount from it’s initial position. Each recursion can specify a different range from the random offset. By varying the level of recursion and the shift range for the different recursion depths, you can get a range of different types of shape.

Actually, the above is just my simple/para-phrased understanding of Perlin. Here’s a better page which really goes into it in depth.

1 comment:

James said...

"Apply a subtle random wander to the game camera to make it look like the camera is hand held, while still pointing generally at the target."

But do be careful doing this. I got a fantastically realistic handheld look using Perlin noise this way. The only problem was that by the end of the day I had a splitting headache and motion sickness.

Who says programming is a safe job?