Fractional Brownian Motion for Terrain Generation
iquilezles.org
iquilezles.org
I guess the provided code examples must return values which are ordered somehow by properties of the `noise` function, which must involve some memory of previously given values. But this function is described as:
>some noise function of our choice... the choice doesn't matter much
The nature of that function is really essential, if it has any independent random distribution, the examples will just return values with an independent random distribution that is bell or triangular or spike shaped.
The basic method of creating a sequence which has different variability at difference scales is to create separate random walks, scale (resample) them and then sum them together. This can be optimized by generating the component walks (with different scales) on the fly, but there is no way to create such a sequence on the fly from a function which returns values which are independent of the sequences previous values.
The order in which sample values are retrieved doesn't matter — of course it doesn't! It's important that fragments (think 'pixels' in case you're wondering what fragments are) can be evaluated independently and in any order, as computing fragments is supposed to be a massively parallel operation.
It this context, you have to throw out the concept of 'previous' sample values and replace it with 'nearby' values.
Still on the face of it that advice "the choice of noise function doesn't matter much" is tricky, considering "white noise" is mentioned in the intro which takes no coordinates, but white noise walks of different scales can be combined I think to produce a non-white noise walk.
Besides this combining in a loop the same kind of noise/texture with different power over different scales, I would be interested in also varying the kinds of texture that are layered into different scales.
float fbm( in vecN x, in float H )
{
float t = 0.0;
for( int i=0; i<numOctaves; i++ )
{
float f = pow( 2.0, float(i) );
float a = pow( f, -H );
t += a*noise(f*x);
}
return t;
}
Shouldn't "float a = pow( f, -H );" be "float a = pow( i, -H );"?It's a terrain + trees and other stuff written in about 1000 lines as a shader, using the algorithm described in the article.
This goes a bit against my intuition of self-similar, but I guess I should interpret "resembles" as *statistically resembles" here as well? Does it mean something like the distribution being the same at all zoom levels?
>If the memory is negatively correlated, a positive change will be most likely followed by a negative change, and the path will be much more random.
Wouldn't the path be less random because you're introducing constraints? Perhaps a better phrasing would be "the path will be much more variable"?