mapgen tweaking

This commit is contained in:
Perttu Ahola 2011-03-01 01:32:54 +02:00
parent f923c1fb66
commit 9a22d02903
4 changed files with 181 additions and 100 deletions

@ -496,7 +496,7 @@ Inventory local_inventory;
u16 g_selected_item = 0; u16 g_selected_item = 0;
bool g_show_map_plot = false; bool g_show_map_plot = false;
bool g_refresh_map_plot = true; bool g_refresh_map_plot = false;
/* /*
Debug streams Debug streams
@ -1267,7 +1267,7 @@ void draw_hotbar(video::IVideoDriver *driver, gui::IGUIFont *font,
} }
video::ITexture *g_map_plot_texture = NULL; video::ITexture *g_map_plot_texture = NULL;
float g_map_plot_texture_scale = 2; float g_map_plot_texture_scale = 4;
void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver, void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver,
Client *client) Client *client)
@ -1306,21 +1306,24 @@ void updateMapPlotTexture(v2f centerpos, video::IVideoDriver* driver,
c.set(255, 160, 160, 160); c.set(255, 160, 160, 160);
else if(h < WATER_LEVEL - 0.5) // Water else if(h < WATER_LEVEL - 0.5) // Water
c.set(255, 50, 50, 255); c.set(255, 50, 50, 255);
else if(h < WATER_LEVEL + 2 else if(h < WATER_LEVEL + 2 // Sand
&& get_have_sand(client->getMapSeed(), pf)) && get_have_sand(client->getMapSeed(), pf))
// Sand
c.set(255, 237, 201, 175); c.set(255, 237, 201, 175);
#if 1 #if 1
else if(h < WATER_LEVEL + 10) // Green else if(h < WATER_LEVEL + 10)
c.set(255, 50, 150, 50); c.set(255, 50, 150, 50); // Green
else if(h < WATER_LEVEL + 20) // Greenish yellow else if(h < WATER_LEVEL + 20)
c.set(255, 110, 185, 50); c.set(255, 110, 185, 50); // Yellowish green
else if(h < WATER_LEVEL + 50) // Yellow else if(h < WATER_LEVEL + 40)
c.set(255, 220, 220, 50); c.set(255, 180, 210, 50); // Greenish yellow
else if(h < WATER_LEVEL + 100) // White else if(h < WATER_LEVEL + 60)
c.set(255, 180, 180, 180); c.set(255, 220, 220, 50); // Yellow
else if(h < WATER_LEVEL + 80)
c.set(255, 200, 200, 110); // Yellowish white
else if(h < WATER_LEVEL + 100)
c.set(255, 190, 190, 190); // Grey
else else
c.set(255, 255, 255, 255); c.set(255, 255, 255, 255); // White
#endif #endif
/*else if(h < WATER_LEVEL + d1) /*else if(h < WATER_LEVEL + d1)
{ {

@ -2027,7 +2027,7 @@ double base_rock_level_2d(u64 seed, v2f p)
(seed>>32)+78593, 5, 0.55), 0.15); (seed>>32)+78593, 5, 0.55), 0.15);
h += 30 * tm2;*/ h += 30 * tm2;*/
#if 1 #if 0
{ {
// Large mountains // Large mountains
double m3 = 100.0 - 600.0 * noise2d_perlin_abs( double m3 = 100.0 - 600.0 * noise2d_perlin_abs(
@ -2038,24 +2038,13 @@ double base_rock_level_2d(u64 seed, v2f p)
} }
#endif #endif
#if 1
{
// Pretty neat looking mountains
double m4 = 100.0 - 400.0 * noise2d_perlin_abs(
0.324+(float)p.X/2000., 0.423+(float)p.Y/2000.,
(seed>>32)+65012102, 8, 0.6);
if(m4 > h)
h = m4;
}
#endif
#if 0 #if 0
{ {
// More neat looking mountain ranges // More mountain ranges
double d = 100; double d = 100;
double a1 = d*2 - d*5 * noise2d_perlin_abs( double a1 = d*2.0 - d*7 * noise2d_perlin_abs(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/1000., 0.5+(float)p.Y/1000.,
seed+850342, 6, 0.55); seed+850342, 7, 0.55);
/*if(a1 > d) /*if(a1 > d)
a1 = d + sqrt(a1-d);*/ a1 = d + sqrt(a1-d);*/
a1 = (1.0 - exp(-a1/d))*d; a1 = (1.0 - exp(-a1/d))*d;
@ -2066,11 +2055,28 @@ double base_rock_level_2d(u64 seed, v2f p)
} }
#endif #endif
#if 1 #if 0
{
// More mountain ranges
double d = 60;
double a1 = d*2.0 - d*7 * noise2d_perlin_abs(
0.5+(float)p.X/1000., 0.5+(float)p.Y/1000.,
seed+850342, 7, 0.55);
/*if(a1 > d)
a1 = d + sqrt(a1-d);*/
a1 = (1.0 - exp(-a1/d))*d;
/*if(a1 > h)
h = a1;*/
if(a1 > 0)
h += a1;
}
#endif
#if 0
{ {
// Very steep mountain ranges // Very steep mountain ranges
double d = 150; double d = 120;
double a1 = d*2 - d*7.5 * noise2d_perlin_abs( double a1 = d*2 - d*6.5 * noise2d_perlin_abs(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
seed+850342, 6, 0.6); seed+850342, 6, 0.6);
/*if(a1 > d) /*if(a1 > d)
@ -2089,6 +2095,22 @@ double base_rock_level_2d(u64 seed, v2f p)
} }
#endif #endif
/*
The sutff before this comment is usually not used.
The stuff after this comment is usually used.
*/
#if 1
{
// Pretty neat looking mountains
double m4 = 100.0 - 400.0 * noise2d_perlin_abs(
0.324+(float)p.X/2000., 0.423+(float)p.Y/2000.,
(seed>>32)+65012102, 7, 0.6);
if(m4 > h)
h = m4;
}
#endif
#if 1 #if 1
// Some kind of hill chains or something // Some kind of hill chains or something
{ {
@ -2106,17 +2128,22 @@ double base_rock_level_2d(u64 seed, v2f p)
#endif #endif
#if 1 #if 1
double base = -2. + 25. * noise2d_perlin( double base = -2. + 30. * noise2d_perlin(
0.5+(float)p.X/500., 0.5+(float)p.Y/500., 0.5+(float)p.X/1000., 0.5+(float)p.Y/1000.,
(seed>>32)+653876, 7, 0.6); (seed>>32)+653876, 7, 0.6);
#else #else
double base = 0; double base = 0;
#endif #endif
#if 1 #if 1
/*
Combined with turbulence, this thing here is able to make very
awesome terrain, albeit rarely.
*/
double higher = 40. * noise2d_perlin( double higher = 40. * noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250., 0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed+39292, 7, 0.55); seed+39292, 6, 0.50);
/*double higher = 50. * noise2d_perlin_abs( /*double higher = 50. * noise2d_perlin_abs(
0.5+(float)p.X/250., 0.5+(float)p.Y/250., 0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed+85039, 5, 0.63);*/ seed+85039, 5, 0.63);*/
@ -2127,7 +2154,7 @@ double base_rock_level_2d(u64 seed, v2f p)
// Steepness factor of cliffs // Steepness factor of cliffs
double b = 1.0 + 1.0 * noise2d_perlin( double b = 1.0 + 1.0 * noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250., 0.5+(float)p.X/250., 0.5+(float)p.Y/250.,
seed-932, 7, 0.7); seed-932, 6, 0.7);
b = rangelim(b, 0.0, 1000.0); b = rangelim(b, 0.0, 1000.0);
#if 1 #if 1
b = pow(b, 5); b = pow(b, 5);
@ -2137,11 +2164,11 @@ double base_rock_level_2d(u64 seed, v2f p)
//double b = 20; //double b = 20;
// Offset to more low // Offset to more low
//double a_off = -0.30; //double a_off = -0.30;
double a_off = -0.00; double a_off = -0.20;
// High/low selector // High/low selector
double a = (double)0.5 + b * (a_off + noise2d_perlin( double a = (double)0.5 + b * (a_off + noise2d_perlin(
0.5+(float)p.X/250., 0.5+(float)p.Y/250., 0.5+(float)p.X/500., 0.5+(float)p.Y/500.,
seed-359, 6, 0.70)); seed-359, 7, 0.70));
#endif #endif
#if 0 #if 0
/*b = pow(b, 5); /*b = pow(b, 5);
@ -2190,15 +2217,48 @@ v2f base_ground_turbulence(u64 seed, v3f p)
#if 1 #if 1
double f = 20; double f = 20;
double vv = 1.0 - 1.0 * noise3d_perlin_abs( #if 1
0.5+p.X/500, // Cut off at a minimum height
0.5+p.Y/500, {
0.5+p.Z/500, double d = 5;
double min = WATER_LEVEL;
if(p.Y < min)
return v2f(0,0);
else if(p.Y < min + d)
f *= ((p.Y-min)/d);
}
#endif
#if 1
double vv = 0.75 + 1.0 * noise3d_perlin(
0.5+p.X/250,
0.5+p.Y/250,
0.5+p.Z/250,
seed+1324381, 4, 0.5);
double vve = rangelim(vv, 0.0, 1.0);
/*double vv = 1.0 - 2.0 * noise3d_perlin_abs(
0.5+p.X/250,
0.5+p.Y/250,
0.5+p.Z/250,
seed+1324031, 4, 0.5); seed+1324031, 4, 0.5);
//double vve = 1.0 - exp(-MYMAX(0, vv*2.0)); double vve = 1.0 - exp(-MYMAX(0, vv*2.0));*/
double vve = MYMAX(0, vv); //double vve = rangelim(vv, 0, 1.0);
//dstream<<"vve="<<vve<<std::endl; //dstream<<"vve="<<vve<<std::endl;
/*// Limit turbulence near water level
double a = contour((p.Y-WATER_LEVEL)/10.0);
vve = (1.-a) * vve;*/
// Increase turbulence in elevated heights
double ah = WATER_LEVEL + 40;
if(p.Y > ah)
{
vve *= p.Y/ah;
}
#else
double vve = 1;
#endif
double v1 = f * noise3d_perlin( double v1 = f * noise3d_perlin(
0.5+p.X/200, 0.5+p.X/200,
0.5+p.Y/200, 0.5+p.Y/200,
@ -2289,47 +2349,64 @@ bool is_base_ground(u64 seed, v3f p, double *depth_guess=NULL)
} }
#endif #endif
v2f t = base_ground_turbulence(seed, p); bool is_ground = true;
double surface_y_f = base_rock_level_2d(seed, v2f(p.X+t.X, p.Z+t.Y)); #if 1
if(is_carved(seed, p))
is_ground = false;
#endif
/*if(depth_guess) if(depth_guess || is_ground == true)
*depth_guess = surface_y_f - p.Y;*/
if(depth_guess)
{ {
// Find highest surface near current v2f t = base_ground_turbulence(seed, p);
v3f dirs[4] = {
v3f(1,0,0), double surface_y_f = base_rock_level_2d(seed, v2f(p.X+t.X, p.Z+t.Y));
v3f(-1,0,0),
v3f(0,0,1), #if 0
v3f(0,0,-1) if(depth_guess)
};
double s2 = surface_y_f;
for(u32 i=0; i<4; i++)
{ {
v3f dir = dirs[i]; // Find highest surface near current
// Get turbulence at around there v3f dirs[4] = {
v2f t2 = base_ground_turbulence(seed, p+dir); v3f(1,0,0),
// Get ground height v3f(-1,0,0),
v2f l = v2f(p.X+t2.X+dir.X, p.Z+t2.Y+dir.Z); v3f(0,0,1),
double s = base_rock_level_2d(seed, l); v3f(0,0,-1)
if(s > s2) };
s2 = s; double s2 = surface_y_f;
} for(u32 i=0; i<4; i++)
*depth_guess = s2 - p.Y; {
} v3f dir = dirs[i];
// Get turbulence at around there
/*if(depth_guess) v2f t2 = base_ground_turbulence(seed, p+dir);
{ // Get ground height
// Check a bit lower also, take highest surface v2f l = v2f(p.X+t2.X+dir.X, p.Z+t2.Y+dir.Z);
v2f t2 = base_ground_turbulence(seed, p + v3f(0,-2,0)); double s = base_rock_level_2d(seed, l);
double s2 = base_rock_level_2d(seed, v2f(p.X+t2.X, p.Z+t2.Y)); if(s > s2)
if(s2 > surface_y_f) s2 = s;
}
*depth_guess = s2 - p.Y; *depth_guess = s2 - p.Y;
else }
#endif
#if 1
if(depth_guess)
{
// Check a bit lower also, take highest surface
v2f t2 = base_ground_turbulence(seed, p + v3f(0,-2,0));
double s2 = base_rock_level_2d(seed, v2f(p.X+t2.X, p.Z+t2.Y));
if(s2 > surface_y_f)
*depth_guess = s2 - p.Y;
else
*depth_guess = surface_y_f - p.Y;
}
#endif
#if 0
if(depth_guess)
*depth_guess = surface_y_f - p.Y; *depth_guess = surface_y_f - p.Y;
}*/ #endif
if(p.Y > surface_y_f)
is_ground = false;
}
/*if(depth_guess) /*if(depth_guess)
{ {
@ -2340,13 +2417,6 @@ bool is_base_ground(u64 seed, v3f p, double *depth_guess=NULL)
double s1 = base_rock_level_2d(seed, v2f(p.X+v1,p.Z+v2)); double s1 = base_rock_level_2d(seed, v2f(p.X+v1,p.Z+v2));
}*/ }*/
bool is_ground = (p.Y <= surface_y_f);
#if 1
if(is_carved(seed, p))
is_ground = false;
#endif
return is_ground; return is_ground;
} }
@ -4171,7 +4241,7 @@ MapBlock * ServerMap::generateBlock(
} block_type = BT_SURFACE; } block_type = BT_SURFACE;
{// ground_timer (0ms or ~100ms) {// ground_timer (0ms or ~100ms)
//TimeTaker ground_timer("Ground generation"); TimeTaker ground_timer("Ground generation");
/* /*
Approximate whether this block is a surface block, an air Approximate whether this block is a surface block, an air
@ -4930,8 +5000,12 @@ continue_generating:
// Lighting is invalid after generation for surface blocks // Lighting is invalid after generation for surface blocks
if(block_type == BT_SURFACE) if(block_type == BT_SURFACE)
{ {
#if 1
block->setLightingExpired(true); block->setLightingExpired(true);
lighting_invalidated_blocks.insert(p, block); lighting_invalidated_blocks.insert(p, block);
#else
block->setLightingExpired(false);
#endif
} }
// Lighting is not invalid for other blocks // Lighting is not invalid for other blocks
else else

@ -44,8 +44,10 @@ double linearInterpolation(double x0, double x1, double t){
} }
double biLinearInterpolation(double x0y0, double x1y0, double x0y1, double x1y1, double x, double y){ double biLinearInterpolation(double x0y0, double x1y0, double x0y1, double x1y1, double x, double y){
double tx = easeCurve(x); /*double tx = easeCurve(x);
double ty = easeCurve(y); double ty = easeCurve(y);*/
double tx = x;
double ty = y;
double u = linearInterpolation(x0y0,x1y0,tx); double u = linearInterpolation(x0y0,x1y0,tx);
double v = linearInterpolation(x0y1,x1y1,tx); double v = linearInterpolation(x0y1,x1y1,tx);
return linearInterpolation(u,v,ty); return linearInterpolation(u,v,ty);
@ -92,7 +94,7 @@ double noise3d(int x, int y, int z, int seed)
return 1.0 - (double)n/1073741824; return 1.0 - (double)n/1073741824;
} }
#if 1 #if 0
double noise2d_gradient(double x, double y, int seed) double noise2d_gradient(double x, double y, int seed)
{ {
// Calculate the integer coordinates // Calculate the integer coordinates
@ -117,7 +119,7 @@ double noise2d_gradient(double x, double y, int seed)
} }
#endif #endif
#if 0 #if 1
double noise2d_gradient(double x, double y, int seed) double noise2d_gradient(double x, double y, int seed)
{ {
// Calculate the integer coordinates // Calculate the integer coordinates

@ -232,15 +232,17 @@ void * EmergeThread::Thread()
*/ */
if(lighting_invalidated_blocks.size() > 0) if(lighting_invalidated_blocks.size() > 0)
{
dstream<<"lighting "<<lighting_invalidated_blocks.size() dstream<<"lighting "<<lighting_invalidated_blocks.size()
<<" blocks"<<std::endl; <<" blocks"<<std::endl;
// 50-100ms for single block generation // 50-100ms for single block generation
//TimeTaker timer("** EmergeThread updateLighting"); TimeTaker timer("** EmergeThread updateLighting");
// Update lighting without locking the environment mutex, // Update lighting without locking the environment mutex,
// add modified blocks to changed blocks // add modified blocks to changed blocks
map.updateLighting(lighting_invalidated_blocks, modified_blocks); map.updateLighting(lighting_invalidated_blocks, modified_blocks);
}
// Add all from changed_blocks to modified_blocks // Add all from changed_blocks to modified_blocks
for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator(); for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator();
@ -3411,7 +3413,7 @@ Player *Server::emergePlayer(const char *name, const char *password,
s16 groundheight = 0; s16 groundheight = 0;
#if 1 #if 1
// Try to find a good place a few times // Try to find a good place a few times
for(s32 i=0; i<500; i++) for(s32 i=0; i<1000; i++)
{ {
s32 range = 1 + i; s32 range = 1 + i;
// We're going to try to throw the player to this position // We're going to try to throw the player to this position