Browse Source

mipmaps, noise experiments

Kajetan Johannes Hammerle 3 years ago
parent
commit
4c59f1b90c

+ 1 - 1
client/Game.cpp

@@ -15,7 +15,7 @@ void Game::tick() {
     Vector3 up = rotation * Vector3(0.0f, 1.0f, 0.0f);
     Vector3 back = rotation * Vector3(0.0f, 0.0f, -1.0f);
 
-    const float speed = 3.0f;
+    const float speed = 6.0f;
     if(controller.down.isDown()) {
         pos += back * speed;
     }

+ 1 - 1
client/rendering/RenderSettings.cpp

@@ -1,4 +1,4 @@
 #include "client/rendering/RenderSettings.h"
 
-RenderSettings::RenderSettings() : ssao(true), shadows(true), testRadius(0.01f), testBias(0.0002f), bump(0.5f) {
+RenderSettings::RenderSettings() : ssao(true), shadows(false), testRadius(0.01f), testBias(0.0002f), bump(0.5f) {
 }

+ 12 - 6
client/rendering/renderer/WorldRenderer.cpp

@@ -1,6 +1,6 @@
 #include "client/rendering/renderer/WorldRenderer.h"
 
-WorldRenderer::WorldRenderer(const World& world) : world(world), texture("resources/textures.png") {
+WorldRenderer::WorldRenderer(const World& world) : world(world), texture("resources/textures.png", 4) {
     TypedBuffer<Triangle> buffer(100);
     for(int x = 0; x < world.getSize(); x++) {
         for(int y = 0; y < world.getHeight(); y++) {
@@ -18,7 +18,12 @@ void WorldRenderer::render(float lag, Renderer& renderer) {
     (void)lag;
     (void)renderer;
     texture.bindTo(0);
-    mesh.draw();
+    for(int x = -1; x <= 1; x++) {
+        for(int z = -1; z <= 1; z++) {
+            renderer.translateTo(world.getSize() * x, 0.0f, world.getSize() * z).update();
+            mesh.draw();
+        }
+    }
 }
 
 bool WorldRenderer::isAir(int x, int y, int z) const {
@@ -35,10 +40,11 @@ void WorldRenderer::addCube(TypedBuffer<Triangle>& buffer, float x, float y, flo
     Vector3 v110(x + 1, y + 1, z);
     Vector3 v111(x + 1, y + 1, z + 1);
 
-    Vector2 t1(0.1875f, 0.0f);
-    Vector2 t2(0.25f, 0.0f);
-    Vector2 t3(0.25f, 0.0625f);
-    Vector2 t4(0.1875f, 0.0625f);
+    const float ERROR = 0.0001f;
+    Vector2 t1(0.1875f + ERROR, 0.0f + ERROR);
+    Vector2 t2(0.25f - ERROR, 0.0f + ERROR);
+    Vector2 t3(0.25f - ERROR, 0.0625f - ERROR);
+    Vector2 t4(0.1875f + ERROR, 0.0625f - ERROR);
 
     if(isAir(x, y - 1, z)) {
         Vector2 tb(0.125f, 0.0625f);

+ 3 - 1
common/world/HighMap.cpp

@@ -32,12 +32,14 @@ static double grad(int hash, double x, double y) {
     return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
 }
 
-HighMap::HighMap(int height) : height(height) {
+HighMap::HighMap(int size, int height) : size(size), height(height) {
     for(int i = 0; i < 256; i++)
         p[256 + i] = p[i] = permutation[i];
 }
 
 int HighMap::getHeight(int x2, int y2) const {
+    x2 &= size - 1;
+    y2 &= size - 1;
     float x = x2 / 64.0f;
     float y = y2 / 64.0f;
     int X = ((int)x) & 255;

+ 2 - 1
common/world/HighMap.h

@@ -4,10 +4,11 @@
 #include "gaming-core/math/Vector.h"
 
 class HighMap {
+    int size;
     int height;
 
 public:
-    HighMap(int height);
+    HighMap(int size, int height);
 
     int getHeight(int x, int y) const;
 

+ 2 - 2
common/world/World.cpp

@@ -2,9 +2,9 @@
 #include "common/world/HighMap.h"
 #include "gaming-core/utils/Random.h"
 
-World::World(const BlockRegistry& blockRegistry) : blockRegistry(blockRegistry), blocks(9, 7) {
+World::World(const BlockRegistry& blockRegistry) : blockRegistry(blockRegistry), blocks(7, 7) {
     Block stone = blockRegistry.getBlock("stone");
-    HighMap map(blocks.getHeight());
+    HighMap map(blocks.getSize(), blocks.getHeight());
     for(int x = 0; x < blocks.getSize(); x++) {
         for(int z = 0; z < blocks.getSize(); z++) {
             int height = map.getHeight(x, z);

+ 1 - 1
gaming-core

@@ -1 +1 @@
-Subproject commit b090b812bc425e99392fed6850827568b094d537
+Subproject commit c59799aa8b1629818f235a7afc8602124a1fc030