shrub biome

This commit is contained in:
tylermurphy534 2022-09-28 23:20:37 -04:00
parent 078f974398
commit 3edd271b81
7 changed files with 16 additions and 8 deletions

BIN
res/image/shrub.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
res/image/shrub_top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -6,7 +6,7 @@ layout (location = 2) in flat int fragTex;
layout (location = 0) out vec4 outColor; layout (location = 0) out vec4 outColor;
layout (binding = 1) uniform sampler2D texSampler[6]; layout (binding = 1) uniform sampler2D texSampler[9];
void main() { void main() {
outColor = texture(texSampler[fragTex], fragUv) + fragLight; outColor = texture(texSampler[fragTex], fragUv) + fragLight;

View file

@ -73,11 +73,13 @@ std::vector<xe::Image*>& Chunk::getTextures() {
void Chunk::load() { void Chunk::load() {
blocks[DIRT] = {{getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE), getTexture(DIRT_TEXTURE)}}; 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[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[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[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[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[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() { void Chunk::unload() {
@ -178,8 +180,10 @@ void Chunk::generate(Chunk* c) {
for(int x = 0; x < 16; x++) { for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) { 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); 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++) { for(int y = 0; y < std::max(height, WATER_LEVEL); y++) {
int difference = y - WATER_LEVEL; int difference = y - WATER_LEVEL;
if (difference < 0) { if (difference < 0) {
@ -189,9 +193,9 @@ void Chunk::generate(Chunk* c) {
} else if(difference < 5) { } else if(difference < 5) {
c->setBlock(x, y, z, DIRT); c->setBlock(x, y, z, DIRT);
} else if(difference < 6) { } else if(difference < 6) {
c->setBlock(x, y, z, GRASS); c->setBlock(x, y, z, biome > 1 ? GRASS : SHRUB);
} else if(difference < 10) { } 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) { } else if(difference < 16) {
c->setBlock(x, y, z, STONE); c->setBlock(x, y, z, STONE);
} else if(difference < 18) { } else if(difference < 18) {

View file

@ -19,11 +19,13 @@
#define AIR 0 #define AIR 0
#define DIRT 1 #define DIRT 1
#define GRASS 2 #define GRASS 2
#define GREEN 3 #define FULL_GRASS 3
#define STONE 4 #define STONE 4
#define SNOW 5 #define SNOW 5
#define SAND 6 #define SAND 6
#define WATER 7 #define WATER 7
#define SHRUB 8
#define FULL_SHRUB 9
#define DIRT_TEXTURE "res/image/dirt.png" #define DIRT_TEXTURE "res/image/dirt.png"
#define GRASS_TEXTURE "res/image/grass.png" #define GRASS_TEXTURE "res/image/grass.png"
@ -32,6 +34,8 @@
#define SNOW_TEXTURE "res/image/snow.png" #define SNOW_TEXTURE "res/image/snow.png"
#define SAND_TEXTURE "res/image/sand.png" #define SAND_TEXTURE "res/image/sand.png"
#define WATER_TEXTURE "res/image/water.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; static constexpr int WATER_LEVEL = 20;

View file

@ -32,7 +32,7 @@ class FirstApp {
static constexpr int WIDTH = 800; static constexpr int WIDTH = 800;
static constexpr int HEIGHT = 600; static constexpr int HEIGHT = 600;
static constexpr int RENDER_DISTANCE = 15; static constexpr int RENDER_DISTANCE = 25;
void createGameObjects(xe::GameObject& viewer); void createGameObjects(xe::GameObject& viewer);
void reloadLoadedChunks(xe::GameObject& viewer); void reloadLoadedChunks(xe::GameObject& viewer);

View file

@ -36,7 +36,7 @@ namespace app {
xe::GameObject &viewerObject; xe::GameObject &viewerObject;
KeyMappings keys{}; KeyMappings keys{};
float moveSpeed{30.f}; float moveSpeed{250.f};
float lookSpeed{1.5f}; float lookSpeed{1.5f};
}; };