Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the randomness quality of the Perlin/Simplex Noise algorithms?

What's the randomness quality of the Perlin Noise algorithm and Simplex Noise algorithm?

Which algorithm of the two has better randomness?

Compared with standard pseudo-random generators, does it make sense to use Perlin/Simplex as random number generator?

Update: I know what the Perlin/Simplex Noise is used for. I'm only curious of randomness properties.

like image 759
Zhen Avatar asked Sep 18 '12 08:09

Zhen


People also ask

Is Perlin noise random?

Perlin noise is a procedural texture primitive, a type of gradient noise used by visual effects artists to increase the appearance of realism in computer graphics. The function has a pseudo-random appearance, yet all of its visual details are the same size.

Is simplex noise better than Perlin noise?

The advantages of simplex noise over Perlin noise: Simplex noise has lower computational complexity and requires fewer multiplications. Simplex noise scales to higher dimensions (4D, 5D) with much less computational cost: the complexity is. for.

What is the algorithm for Perlin noise?

Perlin noise is a popular procedural generation algorithm invented by Ken Perlin. It can be used to generate things like textures and terrain procedurally, meaning without them being manually made by an artist or designer. The algorithm can have 1 or more dimensions, which is basically the number of inputs it gets.

Is simplex faster than Perlin?

simplex noise looks worse imho, and lots of people think it looks "increasingly bad" in higher dimensions. I'd still recommend it over perlin for most applications, as most won't be using just raw simplex but octaves of it which looks roughly the same as octaves of perlin and is significantly faster for octaves.


3 Answers

Perlin noise and simplex noise are meant to generate useful noise, not to be completely random. These algorithms are generally used to create procedurally generated landscapes and the like. For example, it can generate terrain such as this (image from here):

Terrain generated from perlin noise

In this image, the noise generates a 2D heightmap such as this (image from here):

Heightmap generated by perlin noise

Each pixel's color represents a height. After producing a heightmap, a renderer is used to create terrain matching the "heights" (colors) of the image.

Therefore, the results of the algorithm are not actually "random"; there are lots of easily discernible patterns, as you can see.

Simplex supposedly looks a bit "nicer", which would imply less randomness, but its main purpose is that it produces similar noise but scales to higher dimensions better. That is, if one would produce 3D,4D,5D noise, simplex noise would outperform Perlin noise, and produce similar results.

If you want a general psuedo-random number generator, look at the Mersenne twister or other prngs. Be warned, wrt to cryptography, prngs can be full of caveats.

Update:

(response to OPs updated question)

As for the random properties of these noise functions, I know perlin noise uses a (very) poor man's prng as input, and does some smoothing/interpolation between neighboring "random" pixels. The input randomness is really just pseudorandom indexing into a precomputed random vector.

The index is computed using some simple integer operations, nothing too fancy. For example, the noise++ project uses precomputed "randomVectors" (see here) to obtain its source noise, and interpolates between different values from this vector. It generates a "random" index into this vector with some simple integer operations, adding a small amount of pseudorandomness. Here is a snippet:

int vIndex = (NOISE_X_FACTOR * ix + NOISE_Y_FACTOR * iy + NOISE_Z_FACTOR * iz + NOISE_SEED_FACTOR * seed) & 0xffffffff;
vIndex ^= (vIndex >> NOISE_SHIFT);
vIndex &= 0xff;

const Real xGradient = randomVectors3D[(vIndex<<2)];

...

The somewhat random noise is then smoothed over and in effect blended with neighboring pixels, producing the patterns.

After producing the initial noise, perlin/simplex noise has the concept of octaves of noise; that is, reblending the noise into itself at different scales. This produces yet more patters. So the initial quality of the noise is probably only as good as the precomputed random arrays, plus the effect of the psuedorandom indexing. But after all that the perlin noise does to it, the apparent randomness decreases significantly (it actually spreads over a wider area I think).

like image 124
Realz Slaw Avatar answered Nov 15 '22 05:11

Realz Slaw


As stated in "The Statistics of Random Numbers", AI Game Wisdom 2, asking which produces 'better' randomness depends what you're using it for. Generally, the quality of PRNGs are compared via test batteries. At the time of print, the author indicates that the best known & most widely used test batteries for testing the randomness of PRNGs are ENT & Diehard. Also, see related questions of how to test random numbers and why statistical randomness tests seem ad-hoc.

Beyond the standard issues of testing typical PRNGs, testing Perlin Noise or Simplex Noise as PRNGs is more complicated because:

  1. Both internally require a PRNG, thus the randomness of their output is influenced by the underlying PRNG.
  2. Most PRNGs have lack tunable parameters. In contrast, Perlin noise is summation of one or more coherent-noise functions (octaves) with ever-increasing frequencies and ever-decreasing amplitudes. Since the final image depends on the number and nature of the octaves used, the quality of the randomness will vary accordingly. libnoise: Modifying the Parameters of the Noise Module
  3. An argument similar to #2 holds for varying the number of dimensions used in Simplex noise as "a 3D section of 4D simplex noise is different from 3D simplex noise." Stefan Gustavson's Simplex noise demystified.
like image 23
Pikalek Avatar answered Nov 15 '22 05:11

Pikalek


i think you are confused.

perlin and simplex take random numbers from some other source and make them less random so that they look more like natural landscapes (random numbers alone do not look like natural landscapes).

so they are not a source of random numbers - they are a way of processing random numbers from somewhere else.

and even if they were a source, they would not be a good source (the numbers are strongly correlated).

like image 23
andrew cooke Avatar answered Nov 15 '22 07:11

andrew cooke