I've got one little question: Is there any code or sample which shows how the simplex noise works? I cannot find anything about it... How should I implement it, without the knowledge how the algorithm works?...

The other question is: Is the simplex noise a good algorithm for island generation? I need huge islands (really huge), with different layers (sand, gras, stone) and clearly visible height-differences, which have soft-edges, so you can go out/into water without jumping over uneven surfaces.

  • \$\begingroup\$ Check out gamedev.stackexchange.com/questions/4628/… Also, are you looking for specifically simplex noise? I have a noise sample I wrote myself, but it's not simplex (or perlin really..it's the so-called 'value' noise, which looks close enough) \$\endgroup\$ Jun 8, 2011 at 18:18
  • \$\begingroup\$ hmm, there is no more information about simplex noise... or nevertheless? The sample would be helpful :) maybe you can give it to me? thanks :) \$\endgroup\$
    – SharpShade
    Jun 8, 2011 at 18:26
  • \$\begingroup\$ I do not want this to be an answer because its not my work, but you can get the Research article on Simplex Noise that Ken wrote at: cs.umbc.edu/~olano/s2002c36/ch02.pdf (This link was from the bottom of the wikipedia article linked to from the article you posted below.) PS: It include code for C and Java at the end of the article. \$\endgroup\$
    – James
    Jun 8, 2011 at 22:14

3 Answers 3


My noise generator in C#, based off this:

static class NoiseGenerator
    public static int Seed { get; private set; }

    public static int Octaves { get; set; }

    public static double Amplitude { get; set; }

    public static double Persistence { get; set; }

    public static double Frequency { get; set; }

    static NoiseGenerator()
        Random r = new Random();
        NoiseGenerator.Seed = r.Next(Int32.MaxValue);
        NoiseGenerator.Octaves = 8;
        NoiseGenerator.Amplitude = 1;
        NoiseGenerator.Frequency = 0.015;
        NoiseGenerator.Persistence = 0.65;

    public static double Noise(int x, int y)
        //returns -1 to 1
        double total = 0.0;
        double freq = NoiseGenerator.Frequency, amp = NoiseGenerator.Amplitude;
        for (int i = 0; i < NoiseGenerator.Octaves; ++i)
            total = total + NoiseGenerator.Smooth(x * freq, y * freq) * amp;
            freq *= 2;
            amp *= NoiseGenerator.Persistence;
        if (total < -2.4) total = -2.4;
        else if (total > 2.4) total = 2.4;

        return (total/ 2.4);

    public static double NoiseGeneration(int x, int y)
        int n = x + y * 57;
        n = (n << 13) ^ n;

        return (1.0 - ((n * (n * n * 15731 + 789221) + NoiseGenerator.Seed) & 0x7fffffff) / 1073741824.0);

    private static double Interpolate(double x, double y, double a)
        double value = (1 - Math.Cos(a * Math.PI)) * 0.5;
        return x * (1 - value) + y * value;

    private static double Smooth(double x, double y)
        double n1 = NoiseGeneration((int)x, (int)y);
        double n2 = NoiseGeneration((int)x + 1, (int)y);
        double n3 = NoiseGeneration((int)x, (int)y + 1);
        double n4 = NoiseGeneration((int)x + 1, (int)y + 1);

        double i1 = Interpolate(n1, n2, x - (int)x);
        double i2 = Interpolate(n3, n4, x - (int)x);

        return Interpolate(i1, i2, y - (int)y);

It isn't commented, but the main parts:

Seed is a value used to make it random - so you don't generate the same thing each time. Here I have put it in the NoiseGenerator.

Amplitude, Frequency, Persistence, and Octaves are explained in the article - they basically affect what the resulting noise looks like.

NoiseGenerator function is literally a PRNG - give it an input, and it generates a random number with that as a seed.

Noise is what you call to get a noise value. I found the values were around -2.4 to 2.4 (actually about 2.40032483 or something so they are clamped) and I fixed them to doubles between -1 and 1.

I have not had any speed problems with this. I was rendering a 400x400 grid of 1x1 sprites with values set by this and was getting only minor lag (and that was recalculating noise each frame).

For the island generation, check out this question - in particular, this link is almost exactly what you want, albeit in AS3.

  • \$\begingroup\$ Ehm, sorry i forgot to say that i need a generator which generates a heightmap. Or how can i use this to generate terrain? At the moment, i generate a heightmap (i tried various algorithms ...) and then calculate the vertices. The big thing is, i need a generation algorithm that generates good looking isles :-/ i know, i´m difficult, but i don´t know how i should make this ... \$\endgroup\$
    – SharpShade
    Jun 8, 2011 at 19:00
  • \$\begingroup\$ @Razer Use the coordinates of your heightmap - say x,y - as the input to the Noise function. It will assign each point a value between -1 and 1, so you may need to do some normalizing ((value+1)*127.5f works to get it between 0 and 255) \$\endgroup\$ Jun 8, 2011 at 20:07
  • \$\begingroup\$ It works, but not very nice... What i want is something like this: hazelmckendrick.com/demos/terrain-generation-tropical-island \$\endgroup\$
    – SharpShade
    Jun 8, 2011 at 21:10
  • 1
    \$\begingroup\$ @Razer Why not use that source? \$\endgroup\$ Jun 9, 2011 at 9:03
  • \$\begingroup\$ Because there is no description of the used algorithms, no code and nothing. Yes i know, source is included, but it´s c++. I don´t understand C++ :-/ \$\endgroup\$
    – SharpShade
    Jun 9, 2011 at 15:35

Ok thanks to all for the help :)

2 days ago i found "Libnoise" and a good C# port. I will take this one, because there´s a renderer which renders smoother heightmaps :)


If you haven't come across it already, Stefan Gustavson's Simplex Noise Demystified is a good explanation of how the algorithm works.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .