Browse Source

corrected coordinate space of height and layer

Kajetan Johannes Hammerle 3 years ago
parent
commit
00bf17719d
1 changed files with 7 additions and 7 deletions
  1. 7 7
      Game.cpp

+ 7 - 7
Game.cpp

@@ -30,9 +30,10 @@ void Game::render(float lag) {
     GL::setViewport(64, 64);
     noiceShader.use();
     noiceBuffer.bindAndClear();
-    noiceShader.setFloat("height", oldHeight * 0.5);
+    float step = 1.0f / 31.5f;
+    noiceShader.setFloat("height", oldHeight * step);
     for(int i = 0; i < 64; i++) {
-        noiceShader.setFloat("layer", i * (1.0f / 63.0f));
+        noiceShader.setFloat("layer", i * step - 1.0f);
         noiceBuffer.bindLayer(i);
         rectangleBuffer.draw(6);
     }
@@ -41,13 +42,12 @@ void Game::render(float lag) {
     shader.use();
     GL::bindMainFramebuffer();
     GL::clear();
-    Vector3 interPos = Utils::interpolate(oldPosition, position, lag);
     shader.setMatrix("proj", frustum.updateProjection().getValues());
 
     Matrix m;
-    m.translate(interPos);
+    m.translate(Utils::interpolate(oldPosition, position, lag));
     m.translateZ(-32.0f);
-    m.translateY(-32.0f + (height - oldHeight) * lag);
+    m.translateY(-32.0f + (oldHeight - height) * lag);
     m.translateX(-32.0f);
     shader.setMatrix("view", m.getValues());
 
@@ -63,10 +63,10 @@ void Game::tick() {
     oldHeight = height;
     oldPosition = position;
     if(up.isDown()) {
-        height -= 1.0f;
+        height -= 1.0;
     }
     if(down.isDown()) {
-        height += 1.0f;
+        height += 1.0;
     }
     const float speed = 2.5f;
     if(left.isDown()) {