Terrain generation with sine waves

 from Red Blob Games
20 Aug 2017

I often use Perlin/Simplex noise to generate terrain. A few years ago I played around with terrain generating using the Fourier transform[1]. With Perlin/Simplex noise I use several “octaves”, each with its own amplitude. That’s 4 to 8 amplitude parameters. The Fourier transform lets you specify all amplitudes. In the demo I wrote, that was 16,384 amplitude parameters!

For js13k[2] we need something that takes as little code as possible, because the code needs to fit in 13k. Perlin noise is around 1k. Fast Fourier Transform is plenty of code too.

The Fourier transform is based on sine waves. Fast Fourier Transform is a fast way of calculating them. Can I write something that’s slower but uses a lot less code?


I played with it a little. I think the answer kind of, but I got some artifacts that I wasn’t able to eliminate in the short amount of time I put into this, and I don’t understand the math well enough to point to a solution.

Email me , or tweet @redblobgames, or comment: