diff --git a/res/image/shrub.png b/res/image/shrub.png new file mode 100644 index 0000000..a6421d4 Binary files /dev/null and b/res/image/shrub.png differ diff --git a/res/image/shrub_top.png b/res/image/shrub_top.png new file mode 100644 index 0000000..a3121e4 Binary files /dev/null and b/res/image/shrub_top.png differ diff --git a/res/shaders/simple_shader.frag b/res/shaders/simple_shader.frag index e7d6bdb..622c3bb 100755 --- a/res/shaders/simple_shader.frag +++ b/res/shaders/simple_shader.frag @@ -6,7 +6,7 @@ layout (location = 2) in flat int fragTex; layout (location = 0) out vec4 outColor; -layout (binding = 1) uniform sampler2D texSampler[6]; +layout (binding = 1) uniform sampler2D texSampler[9]; void main() { outColor = texture(texSampler[fragTex], fragUv) + fragLight; diff --git a/src/chunk.cpp b/src/chunk.cpp index 0fc52fe..41f8014 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -73,11 +73,13 @@ std::vector& Chunk::getTextures() { void Chunk::load() { blocks[DIRT] = {{getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE)}}; blocks[GRASS] = {{getTexture(GRASS_TEXTURE), getTexture(GRASS_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(GRASS_TEXTURE), getTexture(GRASS_TEXTURE)}}; - blocks[GREEN] = {{getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE)}}; + blocks[FULL_GRASS] = {{getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE), getTexture(GRASS_TOP_TEXTURE)}}; blocks[STONE] = {{getTexture(STONE_TEXTURE), getTexture(STONE_TEXTURE), getTexture(STONE_TEXTURE), getTexture(STONE_TEXTURE), getTexture(STONE_TEXTURE), getTexture(STONE_TEXTURE)}}; blocks[SNOW] = {{getTexture(SNOW_TEXTURE), getTexture(SNOW_TEXTURE), getTexture(SNOW_TEXTURE), getTexture(SNOW_TEXTURE), getTexture(SNOW_TEXTURE), getTexture(SNOW_TEXTURE)}}; blocks[SAND] = {{getTexture(SAND_TEXTURE), getTexture(SAND_TEXTURE), getTexture(SAND_TEXTURE), getTexture(SAND_TEXTURE), getTexture(SAND_TEXTURE), getTexture(SAND_TEXTURE)}}; blocks[WATER] = {{getTexture(WATER_TEXTURE), getTexture(WATER_TEXTURE), getTexture(WATER_TEXTURE), getTexture(WATER_TEXTURE), getTexture(WATER_TEXTURE), getTexture(WATER_TEXTURE)}}; + blocks[SHRUB] = {{getTexture(SHRUB_TEXTURE), getTexture(SHRUB_TEXTURE), getTexture(SHRUB_TOP_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(SHRUB_TEXTURE), getTexture(SHRUB_TEXTURE)}}; + blocks[FULL_SHRUB] = {{getTexture(SHRUB_TOP_TEXTURE), getTexture(SHRUB_TOP_TEXTURE), getTexture(SHRUB_TOP_TEXTURE), getTexture(SHRUB_TOP_TEXTURE), getTexture(SHRUB_TOP_TEXTURE), getTexture(SHRUB_TOP_TEXTURE)}}; } void Chunk::unload() { @@ -178,8 +180,10 @@ void Chunk::generate(Chunk* c) { for(int x = 0; x < 16; x++) { for(int z = 0; z < 16; z++) { + double biome = perlin.octave2D_01((( x + c->gridX * 13) * 0.0005), ((z + c->gridZ * 13) * 0.0005), 4) * 2; + double continent = perlin.octave2D_01((( x + c->gridX * 16) * 0.001), ((z + c->gridZ * 16) * 0.001), 4) * 10 - 5; double noise = perlin.octave2D_01((( x + c->gridX * 16) * 0.01), ((z + c->gridZ * 16) * 0.01), 4); - int height = noise * 40; + int height = noise * 40 + continent; for(int y = 0; y < std::max(height, WATER_LEVEL); y++) { int difference = y - WATER_LEVEL; if (difference < 0) { @@ -189,9 +193,9 @@ void Chunk::generate(Chunk* c) { } else if(difference < 5) { c->setBlock(x, y, z, DIRT); } else if(difference < 6) { - c->setBlock(x, y, z, GRASS); + c->setBlock(x, y, z, biome > 1 ? GRASS : SHRUB); } else if(difference < 10) { - c->setBlock(x, y, z, GREEN); + c->setBlock(x, y, z, biome > 1 ? FULL_GRASS : FULL_SHRUB); } else if(difference < 16) { c->setBlock(x, y, z, STONE); } else if(difference < 18) { diff --git a/src/chunk.hpp b/src/chunk.hpp index 8d1f03c..18230c8 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -19,11 +19,13 @@ #define AIR 0 #define DIRT 1 #define GRASS 2 -#define GREEN 3 +#define FULL_GRASS 3 #define STONE 4 #define SNOW 5 #define SAND 6 #define WATER 7 +#define SHRUB 8 +#define FULL_SHRUB 9 #define DIRT_TEXTURE "res/image/dirt.png" #define GRASS_TEXTURE "res/image/grass.png" @@ -32,6 +34,8 @@ #define SNOW_TEXTURE "res/image/snow.png" #define SAND_TEXTURE "res/image/sand.png" #define WATER_TEXTURE "res/image/water.png" +#define SHRUB_TEXTURE "res/image/shrub.png" +#define SHRUB_TOP_TEXTURE "res/image/shrub_top.png" static constexpr int WATER_LEVEL = 20; diff --git a/src/first_app.hpp b/src/first_app.hpp index dc912fb..3d97bad 100755 --- a/src/first_app.hpp +++ b/src/first_app.hpp @@ -32,7 +32,7 @@ class FirstApp { static constexpr int WIDTH = 800; static constexpr int HEIGHT = 600; - static constexpr int RENDER_DISTANCE = 15; + static constexpr int RENDER_DISTANCE = 25; void createGameObjects(xe::GameObject& viewer); void reloadLoadedChunks(xe::GameObject& viewer); diff --git a/src/keyboard_movement_controller.hpp b/src/keyboard_movement_controller.hpp index 5577bbf..ff7faf8 100644 --- a/src/keyboard_movement_controller.hpp +++ b/src/keyboard_movement_controller.hpp @@ -36,7 +36,7 @@ namespace app { xe::GameObject &viewerObject; KeyMappings keys{}; - float moveSpeed{30.f}; + float moveSpeed{250.f}; float lookSpeed{1.5f}; };