paysages : Noise adjustements.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@428 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-08-29 20:29:41 +00:00 committed by ThunderK
parent 960847ebf9
commit 0c7a8205c5
3 changed files with 39 additions and 11 deletions

View file

@ -31,6 +31,26 @@ void noiseInit()
noiseSimplexInit();
noisePerlinInit();
noiseNaiveInit();
/* Noise stats */
/*NoiseGenerator* noise;
int x;
double min, max, value;
noise = noiseCreateGenerator();
noiseSetFunctionParams(noise, NOISE_FUNCTION_NAIVE, 0.0);
noiseAddLevelSimple(noise, 1.0, 1.0);
min = 100000.0;
max = -100000.0;
for (x = 0; x < 1000000; x++)
{
value = noiseGet1DTotal(noise, toolsRandom() * 10000.0);
value = noiseGet2DTotal(noise, toolsRandom() * 10000.0, toolsRandom() * 10000.0);
value = noiseGet3DTotal(noise, toolsRandom() * 10000.0, toolsRandom() * 10000.0, toolsRandom() * 10000.0);
if (value < min) min = value;
if (value > max) max = value;
}
printf("%f %f\n", min, max);
noiseDeleteGenerator(noise);*/
}
void noiseQuit()

View file

@ -55,8 +55,9 @@ void noiseNaiveLoad(PackStream* stream)
double noiseNaiveGet1DValue(double x)
{
x *= 3.0;
int size = _noise_pool_size;
int xbase = (int)floor(x);
double xinternal = x - (double)xbase;
@ -88,12 +89,15 @@ double noiseNaiveGet1DValue(double x)
buf_cubic_x[1] = _noise_pool[x1 % _noise_pool_size];
buf_cubic_x[2] = _noise_pool[x2 % _noise_pool_size];
buf_cubic_x[3] = _noise_pool[x3 % _noise_pool_size];
return toolsCubicInterpolate(buf_cubic_x, xinternal);
return toolsCubicInterpolate(buf_cubic_x, xinternal) * 0.837;
}
double noiseNaiveGet2DValue(double x, double y)
{
x *= 3.0;
y *= 3.0;
int size = (int)pow(_noise_pool_size, 0.5);
int xbase = (int)floor(x);
@ -171,11 +175,15 @@ double noiseNaiveGet2DValue(double x, double y)
buf_cubic_x[3] = _noise_pool[(y3 * size + x3) % _noise_pool_size];
buf_cubic_y[3] = toolsCubicInterpolate(buf_cubic_x, xinternal);
return toolsCubicInterpolate(buf_cubic_y, yinternal);
return toolsCubicInterpolate(buf_cubic_y, yinternal) * 0.723;
}
double noiseNaiveGet3DValue(double x, double y, double z)
{
x *= 3.0;
y *= 3.0;
z *= 3.0;
int size = (int)pow(_noise_pool_size, 0.33333333333333333);
int xbase = (int)floor(x);
@ -357,7 +365,7 @@ double noiseNaiveGet3DValue(double x, double y, double z)
buf_cubic_z[3] = toolsCubicInterpolate(buf_cubic_y, yinternal);
return toolsCubicInterpolate(buf_cubic_z, zinternal);
return toolsCubicInterpolate(buf_cubic_z, zinternal) * 0.794;
}
/*double noiseNaiveGet4DValue(double x, double y, double z, double w)

View file

@ -39,7 +39,7 @@ static double g1[B + B + 2];
double noisePerlinGet1DValue(double x)
{
double vec[1] = {x};
double vec[1] = {x*2.0};
int bx0, bx1;
double rx0, rx1, sx, t, u, v;
@ -50,12 +50,12 @@ double noisePerlinGet1DValue(double x)
u = rx0 * g1[ p[ bx0 ] ];
v = rx1 * g1[ p[ bx1 ] ];
return lerp(sx, u, v);
return lerp(sx, u, v) * 1.068;
}
double noisePerlinGet2DValue(double x, double y)
{
double vec[2] = {x, y};
double vec[2] = {x*2.0, y*2.0};
int bx0, bx1, by0, by1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
@ -84,12 +84,12 @@ double noisePerlinGet2DValue(double x, double y)
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
return lerp(sy, a, b) * 0.709;
}
double noisePerlinGet3DValue(double x, double y, double z)
{
double vec[3] = {x, y, z};
double vec[3] = {x*2.0, y*2.0, z*2.0};
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
int i, j;
@ -132,7 +132,7 @@ double noisePerlinGet3DValue(double x, double y, double z)
d = lerp(sy, a, b);
return lerp(sz, c, d);
return lerp(sz, c, d) * 0.661;
}
static void _normalize2(double v[2])