1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

A third try on terrain generation. No trees yet.

This commit is contained in:
Perttu Ahola 2011-02-28 02:01:40 +02:00
parent 5707c309c9
commit c8be58a65c
13 changed files with 998 additions and 250 deletions

View file

@ -92,8 +92,7 @@ double noise3d(int x, int y, int z, int seed)
return 1.0 - (double)n/1073741824;
}
#if 0
// This is too slow
#if 1
double noise2d_gradient(double x, double y, int seed)
{
// Calculate the integer coordinates
@ -118,7 +117,7 @@ double noise2d_gradient(double x, double y, int seed)
}
#endif
#if 1
#if 0
double noise2d_gradient(double x, double y, int seed)
{
// Calculate the integer coordinates
@ -175,6 +174,21 @@ double noise2d_perlin(double x, double y, int seed,
return a;
}
double noise2d_perlin_abs(double x, double y, int seed,
int octaves, double persistence)
{
double a = 0;
double f = 1.0;
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * fabs(noise2d_gradient(x*f, y*f, seed+i));
f *= 2.0;
g *= persistence;
}
return a;
}
double noise3d_perlin(double x, double y, double z, int seed,
int octaves, double persistence)
{
@ -190,3 +204,18 @@ double noise3d_perlin(double x, double y, double z, int seed,
return a;
}
double noise3d_perlin_abs(double x, double y, double z, int seed,
int octaves, double persistence)
{
double a = 0;
double f = 1.0;
double g = 1.0;
for(int i=0; i<octaves; i++)
{
a += g * fabs(noise3d_gradient(x*f, y*f, z*f, seed+i));
f *= 2.0;
g *= persistence;
}
return a;
}