summaryrefslogtreecommitdiffstats
path: root/src/RendererSectionData.cpp
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-12-07 17:53:02 +0100
committerLaG1924 <lag1924@gmail.com>2021-12-07 17:53:02 +0100
commit91afb55a58c4b27d0c746e64305dd1d9ad816d94 (patch)
treecdf8c74b4b0aff8f0df7208b1c48f4b99f951db4 /src/RendererSectionData.cpp
parentFixed GalOgl OglState dangling resource (diff)
downloadAltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.gz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.bz2
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.lz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.xz
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.tar.zst
AltCraft-91afb55a58c4b27d0c746e64305dd1d9ad816d94.zip
Diffstat (limited to 'src/RendererSectionData.cpp')
-rw-r--r--src/RendererSectionData.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp
index 45d242c..94c802d 100644
--- a/src/RendererSectionData.cpp
+++ b/src/RendererSectionData.cpp
@@ -3,6 +3,7 @@
#include <array>
#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/matrix_inverse.hpp>
#include <optick.h>
#include "World.hpp"
@@ -25,6 +26,8 @@ glm::vec2 TransformTextureCoord(glm::vec4 TextureAtlasCoords, glm::vec2 UvCoords
}
void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, const glm::mat4 &transform, bool visibility[FaceDirection::none], BlockLightness light, BlockLightness skyLight) {
+ glm::mat3 normalMat = glm::mat3(glm::inverseTranspose(transform * model.transform));
+
for (const auto &face : model.faces) {
glm::vec3 normal = {};
glm::vec2 lightness;
@@ -58,7 +61,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co
vertexData.positions[2] = transformed * glm::vec4(1, 0, 1, 1);
vertexData.positions[3] = transformed * glm::vec4(1, 0, 0, 1);
- vertexData.normal = model.transform * face.transform * glm::vec4(normal, 1.0f);
+ vertexData.normal = glm::normalize(normalMat * glm::vec4(normal, 1.0f));
vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames);
vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames);