Perlin Noise

I’ve been working on testing some realtime data visualisation architecture (SignalR / In-Memory Caching vs Ajax / Redis Queue) and I needed some test data.

I needed a smooth-ish curve (i.e. not totally random numbers), but something that didn’t contain too much repetition (e.g. a sine wave) and Perlin Noise seemed like a good fit for this.

Until a few weeks ago I’d never heard of Perlin Noise, but I’ve just read the first couple of chapters of Nature of Code which has a chapter on using pseudo-random numbers to simulate physical forces and generate textures.

The book uses Processing which has a built-in function for generating Perlin Noise. You can try it out yourself on Khan Academy’s Programming Natural Simulations course. It’s also worth having a read about it on Ken Perlin’s Website:

C# implementations I found were 2d or 3d so I minimally ported Ken Perlin’s 1983 C code to C# (LinqPad script below). Maybe you’ll find it useful…

1d noise:


2d noise: