4. Top-Level FBM Function

All of this document culminates into a single top-level function called monolith_fbm.

monolith_fbm takes in 3 paramters: an x and y coordinate (given as normalized values), and the number of octaves.

It returns a corresponding amplitude in range 0-1.

<<funcdefs>>=
float monolith_fbm(float x, float y, int oct);
<<funcs>>=
float monolith_fbm(float x, float y, int oct)
{
    vec2 st;
    float value;
    float amplitude;
    int i;

    st = mkvec2(x, y);
    value = 0;
    amplitude = 0.5;

    for (i = 0; i < oct; i++) {
        value += amplitude * noise(st);
        st = muls(st, 2);
        amplitude *= 0.6;
    }

    return value;
}



prev | home | next