Improve MapGen
parent
f572fa8167
commit
e82ae10259
|
@ -35,36 +35,76 @@ MapGen::MapGen(unsigned int seed, BlockAtlas& atlas) {
|
|||
FLOWERS[6] = atlas.fromIdentifier("default:flower_red_mushroom").index;
|
||||
FLOWERS[7] = atlas.fromIdentifier("default:flower_brown_mushroom").index;
|
||||
|
||||
//Set up Noise Parameters
|
||||
//First stage smooth elevation
|
||||
worldElevationBase.SetSeed(seed);
|
||||
worldElevationBase.SetFrequency(0.002);
|
||||
worldElevationBase.SetOctaveCount(8);
|
||||
|
||||
terrainGeneralElevation.SetFrequency(0.05);
|
||||
terrainGeneralElevation.SetPersistence(0.4);
|
||||
terrainGeneralElevation.SetOctaveCount(6);
|
||||
worldElevationScaled.SetSourceModule(0, worldElevationBase);
|
||||
worldElevationScaled.SetScale(500);
|
||||
|
||||
terrainFlatBase.SetFrequency(0.15);
|
||||
terrainFlatBase.SetPersistence(0.4);
|
||||
terrainFlatBase.SetOctaveCount(4);
|
||||
//Smooth elevation features
|
||||
worldFeatureBase.SetSeed(seed);
|
||||
worldFeatureBase.SetFrequency(0.2);
|
||||
worldFeatureBase.SetOctaveCount(3);
|
||||
worldFeatureScaled.SetSourceModule(0, worldFeatureBase);
|
||||
worldFeatureScaled.SetScale(6);
|
||||
worldFeatureScaled.SetBias(6);
|
||||
|
||||
terrainFlat.SetSourceModule(0, terrainFlatBase);
|
||||
terrainFlat.SetScale(0.125);
|
||||
terrainFlat.SetBias(-0.75);
|
||||
//Smooth elevation combined
|
||||
worldSmoothElevation.SetSourceModule(0, worldElevationScaled);
|
||||
worldSmoothElevation.SetSourceModule(1, worldFeatureScaled);
|
||||
|
||||
terrainType.SetFrequency(0.05);
|
||||
terrainType.SetPersistence(0.25);
|
||||
terrainType.SetOctaveCount(4);
|
||||
//Smooth mountain terrain
|
||||
mountainSmoothBase.SetSeed(seed);
|
||||
mountainSmoothBase.SetFrequency(0.05);
|
||||
mountainSmoothScaled.SetSourceModule(0, mountainSmoothBase);
|
||||
mountainSmoothScaled.SetScale(300);
|
||||
mountainSmoothScaled.SetBias(400);
|
||||
|
||||
//Craggy mountains hold
|
||||
mountainRoughHoldBase.SetSeed(seed);
|
||||
mountainRoughHoldBase.SetFrequency(0.05);
|
||||
mountainRoughHoldScaled.SetSourceModule(0, mountainRoughHoldBase);
|
||||
mountainRoughHoldScaled.SetScale(0.5);
|
||||
mountainRoughHoldScaled.SetBias(0.5);
|
||||
|
||||
//Craggy mountains
|
||||
mountainRoughBase.SetSeed(seed);
|
||||
mountainRoughBase.SetFrequency(0.75);
|
||||
mountainRoughBase.SetLacunarity(1.5);
|
||||
mountainRoughBase.SetOctaveCount(8);
|
||||
mountainRoughScaled.SetSourceModule(0, mountainRoughBase);
|
||||
mountainRoughScaled.SetScale(20);
|
||||
mountainRoughScaled.SetBias(20);
|
||||
|
||||
mountainRoughMultiplied.SetSourceModule(0, mountainRoughHoldScaled);
|
||||
mountainRoughMultiplied.SetSourceModule(1, mountainRoughScaled);
|
||||
|
||||
mountainNoise.SetSourceModule(0, mountainSmoothScaled);
|
||||
mountainNoise.SetSourceModule(1, mountainRoughMultiplied);
|
||||
|
||||
//Noise for the strength "multiplier" for mountains
|
||||
mountainMultiplierBase.SetSeed(seed);
|
||||
mountainMultiplierBase.SetFrequency(0.02);
|
||||
mountainMultiplierBase.SetPersistence(0.25f);
|
||||
mountainMultiplierScaled.SetSourceModule(0, mountainMultiplierBase);
|
||||
// mountainMultiplierScaled.SetScale(2);
|
||||
// mountainMultiplierScaled.SetBias(-1);
|
||||
mountainMultiplierClamped.SetSourceModule(0, mountainMultiplierScaled);
|
||||
mountainMultiplierClamped.SetBounds(0, 1);
|
||||
|
||||
//Multiply mountain terrain by the multiplier
|
||||
mountainMultiplied.SetSourceModule(0, mountainMultiplierClamped);
|
||||
mountainMultiplied.SetSourceModule(1, mountainNoise);
|
||||
|
||||
//Add both the general elevation and the mountain terrain
|
||||
terrainFinal.SetSourceModule(0, worldSmoothElevation);
|
||||
terrainFinal.SetSourceModule(1, mountainMultiplied);
|
||||
|
||||
terrainMountains.SetFrequency(0.1);
|
||||
terrainMountains.SetOctaveCount(4);
|
||||
|
||||
terrainPreElevation.SetSourceModule(0, terrainFlat);
|
||||
terrainPreElevation.SetSourceModule(1, terrainMountains);
|
||||
|
||||
terrainPreElevation.SetControlModule(terrainType);
|
||||
terrainPreElevation.SetBounds(0.0, 1000.0);
|
||||
terrainPreElevation.SetEdgeFalloff(0.1);
|
||||
|
||||
terrainFinal.SetSourceModule(0, terrainPreElevation);
|
||||
terrainFinal.SetSourceModule(1, terrainGeneralElevation);
|
||||
|
||||
grassNoise.SetFrequency(2);
|
||||
grassNoise.SetOctaveCount(3);
|
||||
|
@ -157,7 +197,7 @@ void MapGen::getDensityMap(MapGenJob &job) {
|
|||
|
||||
for (int m = 0; m < (int)pow(TransPos::CHUNK_SIZE, 3); m++) {
|
||||
VecUtils::indAssignVec(m, lp);
|
||||
job.density[m] = terrain_2d_sample.get(lp) * 24.0f - (lp.y + job.pos.y * TransPos::CHUNK_SIZE);
|
||||
job.density[m] = terrain_2d_sample.get(lp) - (lp.y + job.pos.y * TransPos::CHUNK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +254,7 @@ void MapGen::addTrees(MapGenJob &job) {
|
|||
}
|
||||
}
|
||||
|
||||
void MapGen::addBlock(glm::vec3 lp, int block, MapGenJob &j) {
|
||||
void MapGen::addBlock(glm::vec3 lp, unsigned int block, MapGenJob &j) {
|
||||
if (lp.x >= 0 && lp.x < TransPos::CHUNK_SIZE && lp.y >= 0 && lp.y < TransPos::CHUNK_SIZE && lp.z >= 0 && lp.z < TransPos::CHUNK_SIZE) {
|
||||
j.blocks[VecUtils::vecToInd(lp)] = block;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ using namespace noise;
|
|||
class MapGen {
|
||||
public:
|
||||
MapGen() = default;
|
||||
MapGen(const MapGen& mapGen);
|
||||
MapGen(unsigned int seed, BlockAtlas& atlas);
|
||||
BlockChunk* generate(glm::vec3 pos);
|
||||
private:
|
||||
|
@ -29,22 +28,57 @@ private:
|
|||
void fillChunk(MapGenJob &j);
|
||||
void addTrees(MapGenJob &j);
|
||||
|
||||
void addBlock(glm::vec3 lp, int block, MapGenJob &j);
|
||||
void addBlock(glm::vec3 lp, unsigned int block, MapGenJob &j);
|
||||
|
||||
unsigned int seed = 0;
|
||||
|
||||
int AIR = 0;
|
||||
int GRASS_BLOCK = 0, DIRT_BLOCK = 0, STONE_BLOCK = 0;
|
||||
int PLANT_STEM_BLOCK = 0, LEAVES_BLOCK = 0;
|
||||
int TALLGRASSES[6] = {0, 0, 0, 0, 0, 0};
|
||||
int FLOWERS[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
unsigned int AIR = 0;
|
||||
unsigned int GRASS_BLOCK = 0, DIRT_BLOCK = 0, STONE_BLOCK = 0;
|
||||
unsigned int PLANT_STEM_BLOCK = 0, LEAVES_BLOCK = 0;
|
||||
unsigned int TALLGRASSES[6] = {0, 0, 0, 0, 0, 0};
|
||||
unsigned int FLOWERS[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
//Smooth world noise factors
|
||||
module::Perlin worldElevationBase;
|
||||
module::ScaleBias worldElevationScaled;
|
||||
|
||||
module::Perlin worldFeatureBase;
|
||||
module::ScaleBias worldFeatureScaled;
|
||||
|
||||
module::Add worldSmoothElevation;
|
||||
|
||||
//Mountain hold
|
||||
module::Perlin mountainMultiplierBase;
|
||||
module::ScaleBias mountainMultiplierScaled;
|
||||
module::Clamp mountainMultiplierClamped;
|
||||
|
||||
//Mountain noise types
|
||||
module::Perlin mountainSmoothBase;
|
||||
module::ScaleBias mountainSmoothScaled;
|
||||
|
||||
module::RidgedMulti mountainRoughBase;
|
||||
module::ScaleBias mountainRoughScaled;
|
||||
module::Perlin mountainRoughHoldBase;
|
||||
module::ScaleBias mountainRoughHoldScaled;
|
||||
|
||||
module::Multiply mountainRoughMultiplied;
|
||||
|
||||
module::Add mountainNoise;
|
||||
|
||||
// module::Perlin mountainRoughnessMultiplierBase;
|
||||
// module::ScaleBias mountainRoughnessMultiplierScaled;
|
||||
//
|
||||
// module::RidgedMulti terrainMountainElevation;
|
||||
// module::ScaleBias terrainMountainElevationScaled;
|
||||
//
|
||||
// module::Perlin terrainMountainHold;
|
||||
// module::ScaleBias terrainMountainHoldScaled;
|
||||
// module::Multiply terrainMountainMultiplied;
|
||||
//
|
||||
// module::Add terrainElevation;
|
||||
|
||||
module::Multiply mountainMultiplied;
|
||||
|
||||
module::Perlin terrainGeneralElevation;
|
||||
module::RidgedMulti terrainMountains;
|
||||
module::Billow terrainFlatBase;
|
||||
module::ScaleBias terrainFlat;
|
||||
module::Perlin terrainType;
|
||||
module::Select terrainPreElevation;
|
||||
module::Add terrainFinal;
|
||||
|
||||
module::Perlin grassNoise;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
Renderer::Renderer() : Renderer(1366, 768) {};
|
||||
|
||||
Renderer::Renderer(GLint winWidth, GLint winHeight) :
|
||||
activeTexture(nullptr),
|
||||
activeTexture(nullptr),
|
||||
|
||||
window(winWidth, winHeight),
|
||||
swayData(new unsigned char[16 * 4 * 16]) {
|
||||
window(winWidth, winHeight),
|
||||
swayData(new unsigned char[16 * 4 * 16]) {
|
||||
|
||||
window.initialize();
|
||||
auto winSize = window.getSize();
|
||||
|
@ -27,9 +27,8 @@ Renderer::Renderer(GLint winWidth, GLint winHeight) :
|
|||
createWorldShaders();
|
||||
createGUIShader();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
void Renderer::createWorldShaders() {
|
||||
|
@ -207,6 +206,7 @@ void Renderer::beginChunkDeferredCalls() {
|
|||
glClearColor(clearColor.x, clearColor.y, clearColor.z, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glViewport(0, 0, static_cast<int>(winSize.x), static_cast<int>(winSize.y));
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, gBuffer);
|
||||
|
@ -250,6 +250,7 @@ void Renderer::endDeferredCalls() {
|
|||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, gColorSpec);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
renderQuad();
|
||||
|
||||
//Used to push the depth map to the default framebuffer
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
Server::Server(const std::string& path, unsigned short port) :
|
||||
defs(),
|
||||
clientList(),
|
||||
world(55, defs, clientList),
|
||||
world(10, defs, clientList),
|
||||
port(port),
|
||||
handler(port, 32),
|
||||
config(defs) {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
class ServerPlayer {
|
||||
public:
|
||||
const static int ACTIVE_RANGE_H = 24;
|
||||
const static int ACTIVE_RANGE_H = 20;
|
||||
const static int ACTIVE_RANGE_V = 8;
|
||||
|
||||
explicit ServerPlayer(glm::vec3 pos, unsigned int connectID, const std::string& username);
|
||||
|
|
Loading…
Reference in New Issue