|
9 years ago | |
---|---|---|
.. | ||
1d-fbm.frag | 9 years ago | |
2d-fbm.frag | 9 years ago | |
README.md | 10 years ago | |
clouds.frag | 9 years ago | |
index.html | 10 years ago | |
noise.frag | 9 years ago |
README.md
Fractal Brownian Motion
At the end of the previous chapter we were thinking about noise and discovering that in fact noise could be interpreted as audio signals. In fact sound can be constructed by the manipulation of the amplitud and frequency of a sine waves.
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