You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thebookofshaders/12
..
1d-fbm.frag
2d-fbm.frag
README.md
clouds.frag
index.html
noise.frag

README.md

Fractal Brownian Motion

At the end of previus chapter we were thinking on noise as random smooth waves. This wavely nature of noise is what makes it such an interdisciplinary concept. In fact, in acustics, sound is constructed by the manipulation of the amplitud and frecuency of a sine waves.

y = amplitud + sin( frequency );

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

Think on the surface of the ocean. Massive amount of water propagating waves across it surface. Waves of diferent amplitud and frequencies coliding together.

On other side if those sine waves are harmonics produce interesting patterns. Try the following code on the previus graph. As you can see in each iteration the frequency increase, while the amplitud decrese.

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

Fractal Brownian Motion

By adding different octaves of increasing frequencies and decreasing amplitudes of noise we can gain some extra granularity. This technique is call Fractal Brownian Motion and is very well documented in this two articles of Iñigo Quilez.

Take a look to the following example and progresively change the for loop to do 2,3,4,5,6,7 and 8 iterations. See how incrisinly fragmented this wave function becomes.

If we apply this to 2D will look like the following code:

Using Fractal Braownian Motion

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

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

http://www.iquilezles.org/www/articles/dynclouds/dynclouds.htm

great!