thebookofshaders/12
Patricio Gonzalez Vivo 76342eff7a cel noise subdir
2015-12-02 16:47:52 -05:00
..
1d-fbm.frag cel noise subdir 2015-12-02 16:47:52 -05:00
2d-fbm.frag cel noise subdir 2015-12-02 16:47:52 -05:00
clouds.frag cel noise subdir 2015-12-02 16:47:52 -05:00
index.php cel noise subdir 2015-12-02 16:47:52 -05:00
noise.frag cel noise subdir 2015-12-02 16:47:52 -05:00
NOTES.md cel noise subdir 2015-12-02 16:47:52 -05:00
README.md cel noise subdir 2015-12-02 16:47:52 -05:00

Fractal Brownian Motion

http://www.iquilezles.org/www/articles/warp/warp.htm http://www.iquilezles.org/www/articles/morenoise/morenoise.htm

Noise is one of those subjects that you can dig and always find new exciting formulas. In fact noise tends to means different things for different people. Musicians will think in audio noise, communicators into interference, and astrophysics on cosmic microwave background. In fact noise could be interpreted as audio signals, and noise as well as sound can be constructed by the manipulation of the amplitud and frequency of the waves that compose it.

y = amplitud + sin( frequency );

An interesting property of waves in general is that they can be add up. The following graph shows what happen if you add sine waves of different frequencies and amplitudes.

Think on it as the surface of the ocean. Massive amount of water propagating waves across it surface. Waves of different heights (amplitud) and rhythms (frequencies) bouncing and interfering each other.

Musicians learn long time ago that there are sounds that play well with each other. Those sound, carried by waves of air, vibrate in such a particular way that the resultan sound seams to be bust and enhance. Those sounds are call harmonics.

Back to code, we can add harmonics together and see how the resultant looks like. Try the following code on the previous graph.

y = 0.;
for( int i = 0; i < 5; ++i) {
    y += sin(PI*x*float(i))/float(i);
}
y *= 0.6;

As you can see in the above code, on every iteration the frequency increase by the double. By augmenting the number of iterations (chaining the 5 for a 10, a 20 or 50) the wave tends to break into smaller fractions, with more details and sharper fluctuations.

Fractal Brownian Motion

So we try adding different waves together, and the result was chaotic, we add up harmonic waves and the result was a consistent fractal pattern. We can use the best of both worlds and add up harmonic noise waves to exacerbate a noise pattern.

By adding different octaves of increasing frequencies and decreasing amplitudes of noise we can obtain a bigger level of detail or granularity. This technique is call Fractal Brownian Motion and usually consist on a fractal sum of noise functions.

Take a look to the following example and progressively change the for loop to do 2,3,4,5,6,7 and 8 iterations. See want happens

If we apply this one dimensional example to a bidimentional space it will look like the following example:

Using Fractal Brownian Motion

In this article Iñigo Quilez describe an interesting use of fractal brownian motion constructing patterns by adding successive results of fractal brownian motions.

Take a look to the code and how it looks