From 45a793d6475b4d5b7c59e9c18492aa45767e2236 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 4 Oct 2024 22:50:37 +0300 Subject: [PATCH] fix: entity shading is incorrect when it is upper than max height --- src/graphics/render/ModelBatch.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/render/ModelBatch.cpp b/src/graphics/render/ModelBatch.cpp index 1b97ad69..f3c8e098 100644 --- a/src/graphics/render/ModelBatch.cpp +++ b/src/graphics/render/ModelBatch.cpp @@ -70,7 +70,11 @@ void ModelBatch::draw(const model::Mesh& mesh, const glm::mat4& matrix, const glm::mat3& rotation, glm::vec3 tint, const texture_names_map* varTextures) { glm::vec3 gpos = matrix * glm::vec4(0.0f, 0.0f, 0.0f, 1.0f); - light_t light = chunks->getLight(floor(gpos.x), floor(gpos.y), floor(gpos.z)); + light_t light = chunks->getLight( + std::floor(gpos.x), + std::floor(std::min(CHUNK_H-1.0f, gpos.y)), + std::floor(gpos.z)); + glm::vec4 lights ( Lightmap::extract(light, 0) / 15.0f, Lightmap::extract(light, 1) / 15.0f,