You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let value =fbm(x, y, octaves, amplitude, frequency, persistence, lacunarity);
9
+
10
+
// simplex_noise_2d.min.js
11
+
s(1337);
12
+
let value =b(x, y, octaves, amplitude, frequency, persistence, lacunarity);
13
+
```
14
+
15
+
## Simplex noise
16
+
17
+
[Simplex noise](https://en.wikipedia.org/wiki/Simplex_noise) is the result of an $n$-dimensional noise function comparable to [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) ("classic" noise) but with fewer directional artifacts and, in higher dimensions, a lower computational overhead. [Ken Perlin](https://en.wikipedia.org/wiki/Ken_Perlin) designed the algorithm in 2001 to address the limitations of his classic noise function, especially in higher dimensions.
18
+
19
+
The advantages of simplex noise over Perlin noise:
20
+
21
+
- Simplex noise has lower computational complexity and requires fewer multiplications.
22
+
- Simplex noise scales to higher dimensions (4D, 5D) with much less computational cost: the complexity is $O(n^2)$ for $n$ dimensions instead of the $O(n2^n)$ of classic noise.
23
+
- Simplex noise has no noticeable directional artifacts (is visually [isotropic](https://en.wikipedia.org/wiki/Isotropy)), though noise generated for different dimensions is visually distinct (e.g. 2D noise has a different look than 2D slices of 3D noise, and it looks increasingly worse for higher dimensions).
24
+
- Simplex noise has a well-defined and continuous gradient (almost) everywhere that can be computed quite cheaply.
25
+
- Simplex noise is easy to implement in hardware.
26
+
27
+
Whereas classical noise interpolates between the [gradients](https://en.wikipedia.org/wiki/Gradient) at the surrounding hypergrid end points (i.e., northeast, northwest, southeast and southwest in 2D), simplex noise divides the space into [simplices](https://en.wikipedia.org/wiki/Simplex) (i.e., $n$-dimensional triangles). This reduces the number of data points. While a hypercube in $n$ dimensions has $2^n$ corners, a simplex in $n$ dimensions has only $n+1$ corners. The triangles are [equilateral](https://en.wikipedia.org/wiki/Equilateral_triangle) in 2D, but in higher dimensions the simplices are only approximately regular. For example, the tiling in the 3D case of the function is an orientation of the [tetragonal disphenoid honeycomb](https://en.wikipedia.org/wiki/Tetragonal_disphenoid_honeycomb).
28
+
29
+
Simplex noise is useful for computer graphics applications, where noise is usually computed over 2, 3, 4, or possibly 5 dimensions. For higher dimensions, n-spheres around n-simplex corners are not densely enough packed, reducing the support of the function and making it zero in large portions of space.
30
+
31
+
## About Perlin's "Simplex" Noise
32
+
33
+
- Perlin's "Classic" Noise (1984) is an algorithm producing pseudo-random fluctuations simulating natural looking variations, producing paterns all of the same size. It is a kind of gradiant-noise algorithm, invented by Ken Perlin while working on visual special effects for the Tron movie (1982). It works by interpolating pseudo-random gradiants defined in a multi-dimensionnal grid. [Ken Perlin original references](http://mrl.nyu.edu/~perlin/doc/oscar.html)
34
+
- Perlin's "Improved" Noise (2002) switches to a new interpolation fonction with a 2nd derivative zero at t=0 and t=1 to remove artifacts on integer values, and switches to using predefined gradients of unit lenght to the middle of each edges. [Ken Perlin original references](http://mrl.nyu.edu/~perlin/paper445.pdf)
35
+
- Perlin's "Simplex" Noise (2001) rather than placing each input point into a cubic grid, based on the integer parts of its (x,y,z) coordinate values, placed them onto a simplicial grid (think triangles instead of squares, pyramids instead of cubes...) [Ken Perlin original references](http://www.csee.umbc.edu/~olano/s2002c36/ch02.pdf)
36
+
37
+
## Fractional Brownian Motion
38
+
39
+
[Fractional Brownian Motion](https://en.wikipedia.org/wiki/Fractional_Brownian_motion) is the summation of successive octaves of noise, each with higher frequency and lower amplitude. It doesn't especially matter what kind of noise, most will do. Fractional Brownian Motion (often abbreviated as fBm) is often confused with noise algorithms like [Value Noise](https://en.wikipedia.org/wiki/Value_noise) and Perlin Noise, when in fact it just takes a type of noise and makes a more interesting picture.
40
+
41
+
```javascript
42
+
functionfBm(x, y, octaves, amplitude, frequency, persistence, lacunarity) {
43
+
let total =0;
44
+
45
+
for (let i =0; i < octaves; i++) {
46
+
total +=noise(x * frequency, y * frequency) * amplitude;
47
+
frequency *= lacunarity;
48
+
amplitude *= persistence;
49
+
}
50
+
51
+
return total;
52
+
}
53
+
```
54
+
55
+
There are five terms here: octaves, amplitude, frequency, lacunarity, and persistence.
56
+
57
+
**Octaves** are how many layers you are putting together. If you start with big features, the number of octaves determines how detailed the map will look.
58
+
59
+
The **amplitude** is how tall the features should be. Frequency determines the width of features, amplitude determines the height. Each octave the amplitude shrinks, meaning small features are also short. This doesn't have to be the case, but for this case it makes pleasing maps.
60
+
61
+
The **frequency** of a layer is how many points fit into the space you've created. So for the mountain scale, you only need a few points, but at the rock scale you may need hundreds of points. In the code above, I start with a small frequency (which equates to large features) and move to higher frequencies which produce smaller details.
62
+
63
+
**Persistence**, also called **gain**, is what makes the amplitude shrink (or not shrink). Each octave the amplitude is multiplied by the gain. I use a gain of 0.65. If it is higher then the amplitude will barely shrink, and maps get crazy. Too low and the details become miniscule, and the map looks washed out. However, most use 1/lacunarity. Since the standard for lacunarity is 2.0, the standard for the gain is 0.5. Noise that has a gain of 0.5 and a lacunarity of 2.0 is referred to as 1/f noise, and is the industry standard.
64
+
65
+
**Lacunarity** is what makes the frequency grow. Each octave the frequency is multiplied by the lacunarity. I use a lacunarity of 2.0, however values of 1.8715 or 2.1042 can help to reduce artifacts in some algorithms. A lacunarity of 2.0 means that the frequency doubles each octave, so if the first octave had 3 points the second would have 6, then 12, then 24, etc. This is used almost exclusively, partly because octaves in music double in frequency. Other values are perfectly acceptable, but the results will vary.
66
+
67
+
## SplitMix32
68
+
69
+
SplitMix32 is a transformation of the `fmix32` finalizer from MurmurHash3 into a PRNG. It has a 32-bit internal state, like Xorshift and Mulberry32.
70
+
71
+
```js
72
+
functionsplitmix32(a) {
73
+
returnfunction() {
74
+
a |=0; a = a +0x9e3779b9|0;
75
+
var t = a ^ a >>>16; t =Math.imul(t, 0x21f0aaad);
76
+
t = t ^ t >>>15; t =Math.imul(t, 0x735a2d97);
77
+
return ((t = t ^ t >>>15) >>>0) /4294967296;
78
+
}
79
+
}
80
+
```
81
+
82
+
This is based on an algorithm known as `SplitMix` included in Java JDK8. It uses 64-bit arithmetic and doesn't define a 32-bit version. However, It is derived from the `fmix64` finalizer used in MurmurHash3 and appears to be an application of Weyl sequences. MurmurHash3 also contains a 32-bit equivalent of this function, `fmix32`. The constant `0x9e3779b` is the 32-bit truncation of the golden ratio, which is also what is used in the original.
-[Patent, Standard for perlin noise](https://www.google.com/patents/US6867776)
90
+
-[The Perlin noise math FAQ](https://web.archive.org/web/20120107051039/http://webstaff.itn.liu.se/~stegu/TNM022-2005/perlinnoiselinks/perlin-noise-math-faq.html)
0 commit comments