From f16c897522b6418c399b5699f8378a25c2e5de4f Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 21 Nov 2021 14:57:57 +0500 Subject: Added normals to faces --- src/RendererSectionData.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 2588fd6..0ac901e 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -26,11 +26,13 @@ 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) { for (const auto &face : model.faces) { + glm::vec3 normal = {}; glm::vec2 lightness; lightness.x = _max(light.face[0], light.face[1], light.face[2], light.face[3], light.face[4], light.face[5]); lightness.y = _max(skyLight.face[0], skyLight.face[1], skyLight.face[2], skyLight.face[3], skyLight.face[4], skyLight.face[5]); if (face.visibility != FaceDirection::none) { FaceDirection direction = face.visibility; + normal = FaceDirectionVector[direction].glm(); Vector directionVec = model.faceDirectionVector[direction]; FaceDirection faceDirection = FaceDirection::none; for (int i = 0; i < FaceDirection::none; i++) { @@ -56,6 +58,8 @@ 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 = normal; + vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames); vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames); vertexData.uvs[2] = TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames); -- cgit v1.2.3 From 3f122e57f118db1229a4bad2c54be624f2f8f19c Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 5 Dec 2021 00:51:39 +0500 Subject: Added SSAO --- src/RendererSectionData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 0ac901e..45d242c 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -58,7 +58,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 = normal; + vertexData.normal = model.transform * face.transform * 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); -- cgit v1.2.3 From 91afb55a58c4b27d0c746e64305dd1d9ad816d94 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Tue, 7 Dec 2021 21:53:02 +0500 Subject: Fixed SSAO normals --- src/RendererSectionData.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/RendererSectionData.cpp') 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 #include +#include #include #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); -- cgit v1.2.3 From 5da2c6799c9064278a4c055e1505880699829cfc Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 12 Dec 2021 01:10:47 +0500 Subject: Optimized face's normals calculation --- src/RendererSectionData.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 94c802d..7e3d285 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -26,16 +26,12 @@ 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 = {}; + for (const auto &face : model.faces) { glm::vec2 lightness; lightness.x = _max(light.face[0], light.face[1], light.face[2], light.face[3], light.face[4], light.face[5]); lightness.y = _max(skyLight.face[0], skyLight.face[1], skyLight.face[2], skyLight.face[3], skyLight.face[4], skyLight.face[5]); if (face.visibility != FaceDirection::none) { FaceDirection direction = face.visibility; - normal = FaceDirectionVector[direction].glm(); Vector directionVec = model.faceDirectionVector[direction]; FaceDirection faceDirection = FaceDirection::none; for (int i = 0; i < FaceDirection::none; i++) { @@ -61,7 +57,8 @@ 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 = glm::normalize(normalMat * glm::vec4(normal, 1.0f)); + glm::vec3 normal = glm::cross(vertexData.positions[1] - vertexData.positions[0], vertexData.positions[3] - vertexData.positions[0]); + vertexData.normal = glm::normalize(normal); vertexData.uvs[0] = TransformTextureCoord(face.texture, glm::vec2(0, 0), face.frames); vertexData.uvs[1] = TransformTextureCoord(face.texture, glm::vec2(1, 0), face.frames); -- cgit v1.2.3 From 3dc7e8aba4a07cc3c0d897b82af5a5951bde9991 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 18 Dec 2021 10:59:06 +0500 Subject: Added AO mask --- src/RendererSectionData.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 7e3d285..c7d922e 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -69,6 +69,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.animations = face.frames; vertexData.colors = face.color; vertexData.lights = lightness; + vertexData.ambientOcclusion = model.ambientOcclusion ? 1.0f : 0.0f; } } -- cgit v1.2.3 From bac80e3514f93055daa4e743fa4f8ba177f77311 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 19 Dec 2021 17:00:13 +0500 Subject: Added per vertex lighting --- src/RendererSectionData.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index c7d922e..979858e 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -65,11 +65,14 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.uvs[2] = TransformTextureCoord(face.texture, glm::vec2(1, 1), face.frames); vertexData.uvs[3] = TransformTextureCoord(face.texture, glm::vec2(0, 1), face.frames); - vertexData.uvLayers = face.layer; - vertexData.animations = face.frames; + vertexData.layerAnimationAo.r = face.layer; + vertexData.layerAnimationAo.g = face.frames; vertexData.colors = face.color; - vertexData.lights = lightness; - vertexData.ambientOcclusion = model.ambientOcclusion ? 1.0f : 0.0f; + vertexData.lights[0] = lightness; + vertexData.lights[1] = lightness; + vertexData.lights[2] = lightness; + vertexData.lights[3] = lightness; + vertexData.layerAnimationAo.b = model.ambientOcclusion ? 1.0f : 0.0f; } } -- cgit v1.2.3 From 749e24c0ca1ea5d1d3166ce52ca98601135e0bcc Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 25 Dec 2021 11:20:36 +0500 Subject: Added smooth lighting --- src/RendererSectionData.cpp | 238 ++++++++++++++++++-------------------------- 1 file changed, 99 insertions(+), 139 deletions(-) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 979858e..b5260f4 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -25,12 +25,44 @@ glm::vec2 TransformTextureCoord(glm::vec4 TextureAtlasCoords, glm::vec2 UvCoords return transformed; } -void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, const glm::mat4 &transform, bool visibility[FaceDirection::none], BlockLightness light, BlockLightness skyLight) { - for (const auto &face : model.faces) { - glm::vec2 lightness; - lightness.x = _max(light.face[0], light.face[1], light.face[2], light.face[3], light.face[4], light.face[5]); - lightness.y = _max(skyLight.face[0], skyLight.face[1], skyLight.face[2], skyLight.face[3], skyLight.face[4], skyLight.face[5]); - if (face.visibility != FaceDirection::none) { +//Maps [0.0, 0.5] range to [0.0, 1.0] +float MapNeg(float x) { + float y = x * 2.0f; + return glm::clamp(y, 0.0f, 1.0f); +} + +//Maps [0.5, 1.0] range to [0.0, 1.0] +float MapPos(float x) { + float y = (x * 2.0f) - 1.0f; + return glm::clamp(y, 0.0f, 1.0f); +} + +float InterpolateBlockLightness(const BlockLightness& light, const glm::vec3 &point) { + float xNeg = MapNeg(point.x); + float xPos = MapPos(point.x); + float xNegLight = glm::mix(light.face[FaceDirection::east], light.self, xNeg); + float xPosLight = glm::mix(light.self, light.face[FaceDirection::west], xPos); + float xLight = (glm::max)(xNegLight, xPosLight); + + float yNeg = MapNeg(point.y); + float yPos = MapPos(point.y); + float yNegLight = glm::mix(light.face[FaceDirection::down], light.self, yNeg); + float yPosLight = glm::mix(light.self, light.face[FaceDirection::up], yPos); + float yLight = (glm::max)(yNegLight, yPosLight); + + float zNeg = MapNeg(point.z); + float zPos = MapPos(point.z); + float zNegLight = glm::mix(light.face[FaceDirection::south], light.self, zNeg); + float zPosLight = glm::mix(light.self, light.face[FaceDirection::north], zPos); + float zLight = (glm::max)(zNegLight, zPosLight); + + return (glm::max)(xLight, (glm::max)(yLight, zLight)); +} + +void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, const glm::mat4& transform, bool visibility[FaceDirection::none], const Vector &pos, const SectionsData §ions) { + glm::vec3 absPos = (sections.data[1][1][1].GetPosition() * 16).glm(); + for (const auto& face : model.faces) { + if (face.visibility != FaceDirection::none) { FaceDirection direction = face.visibility; Vector directionVec = model.faceDirectionVector[direction]; FaceDirection faceDirection = FaceDirection::none; @@ -45,7 +77,6 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co if (visibility[faceDirection]) continue; - lightness = glm::vec2(light.face[faceDirection], skyLight.face[faceDirection]); } data.vertices.emplace_back(); @@ -68,12 +99,37 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.layerAnimationAo.r = face.layer; vertexData.layerAnimationAo.g = face.frames; vertexData.colors = face.color; - vertexData.lights[0] = lightness; - vertexData.lights[1] = lightness; - vertexData.lights[2] = lightness; - vertexData.lights[3] = lightness; - vertexData.layerAnimationAo.b = model.ambientOcclusion ? 1.0f : 0.0f; - } + + bool useSmoothLighting = true; + if (useSmoothLighting) { + for (size_t i = 0; i < 4; i++) { + glm::vec3 baseLightPos = vertexData.positions[i] - absPos; + glm::vec3 lightPos = baseLightPos + normal * 0.5f; + glm::ivec3 basePos = glm::trunc(lightPos); + BlockLightness light = sections.GetLight(Vector(basePos.x, basePos.y, basePos.z)); + BlockLightness skyLight = sections.GetSkyLight(Vector(basePos.x, basePos.y, basePos.z)); + vertexData.lights[i].x = InterpolateBlockLightness(light, lightPos - glm::vec3(basePos)); + vertexData.lights[i].y = InterpolateBlockLightness(skyLight, lightPos - glm::vec3(basePos)); + } + } else { + BlockLightness light = sections.GetLight(pos); + BlockLightness skyLight = sections.GetSkyLight(pos); + glm::vec2 lightness; + + lightness.x = face.visibility != FaceDirection::none ? light.face[face.visibility] : light.self; + lightness.x = (glm::max)(lightness.x, static_cast(light.self)); + + lightness.y = face.visibility != FaceDirection::none ? skyLight.face[face.visibility] : skyLight.self; + lightness.y = (glm::max)(lightness.y, static_cast(skyLight.self)); + + vertexData.lights[0] = lightness; + vertexData.lights[1] = lightness; + vertexData.lights[2] = lightness; + vertexData.lights[3] = lightness; + } + + vertexData.layerAnimationAo.b = model.ambientOcclusion ? 1.0f : 0.0f; + } } BlockFaces *GetInternalBlockModel(const BlockId& id, std::vector> &idModels) { @@ -125,7 +181,7 @@ std::array SetBlockIdData(const SectionsData §ions) { for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { - blockIdData[y * 256 + z * 16 + x] = sections.section.GetBlockId(Vector(x, y, z)); + blockIdData[y * 256 + z * 16 + x] = sections.data[1][1][1].GetBlockId(Vector(x, y, z)); } } } @@ -141,10 +197,10 @@ RendererSectionData ParseSection(const SectionsData §ions) { std::array blockVisibility = GetBlockVisibilityData(sections, blockIdData, idModels); std::string textureName; - data.hash = sections.section.GetHash(); - data.sectionPos = sections.section.GetPosition(); + data.hash = sections.data[1][1][1].GetHash(); + data.sectionPos = sections.data[1][1][1].GetPosition(); - glm::mat4 baseOffset = glm::translate(glm::mat4(1.0), (sections.section.GetPosition() * 16).glm()), transform; + glm::mat4 baseOffset = glm::translate(glm::mat4(1.0), (sections.data[1][1][1].GetPosition() * 16).glm()), transform; for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { @@ -157,11 +213,8 @@ RendererSectionData ParseSection(const SectionsData §ions) { transform = glm::translate(baseOffset, vec.glm()); - BlockLightness light = sections.GetLight(vec); - BlockLightness skyLight = sections.GetSkyLight(vec); - BlockFaces *model = GetInternalBlockModel(block, idModels); - AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], light, skyLight); + AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], vec, sections); } } } @@ -171,127 +224,34 @@ RendererSectionData ParseSection(const SectionsData §ions) { } BlockId SectionsData::GetBlockId(const Vector &pos) const { - if (pos.x < 0) - return east.GetBlockId(Vector(15, pos.y, pos.z)); - - if (pos.x > 15) - return west.GetBlockId(Vector(0, pos.y, pos.z)); - - if (pos.y < 0) - return bottom.GetBlockId(Vector(pos.x, 15, pos.z)); - - if (pos.y > 15) - return top.GetBlockId(Vector(pos.x, 0, pos.z)); - - if (pos.z < 0) - return south.GetBlockId(Vector(pos.x, pos.y, 15)); - - if (pos.z > 15) - return north.GetBlockId(Vector(pos.x, pos.y, 0)); - - return section.GetBlockId(pos); + Vector sectionPos = pos; + return GetSection(sectionPos).GetBlockId(sectionPos); } -BlockLightness SectionsData::GetLight(const Vector &pos) const { - BlockLightness lightness; - static const Vector directions[] = { - Vector(1,0,0), - Vector(-1,0,0), - Vector(0,1,0), - Vector(0,-1,0), - Vector(0,0,1), - Vector(0,0,-1), - }; - - unsigned char self = section.GetBlockLight(pos); - - for (const Vector &dir : directions) { - Vector vec = pos + dir; - unsigned char dirValue = 0; - - if (vec.x < 0 || vec.x > 15 || vec.y < 0 || vec.y > 15 || vec.z < 0 || vec.z > 15) { - if (vec.x < 0) - dirValue = east.GetBlockLight(Vector(15, vec.y, vec.z)); - if (vec.x > 15) - dirValue = west.GetBlockLight(Vector(0, vec.y, vec.z)); - if (vec.y < 0) - dirValue = bottom.GetBlockLight(Vector(vec.x, 15, vec.z)); - if (vec.y > 15) - dirValue = top.GetBlockLight(Vector(vec.x, 0, vec.z)); - if (vec.z < 0) - dirValue = south.GetBlockLight(Vector(vec.x, vec.y, 15)); - if (vec.z > 15) - dirValue = north.GetBlockLight(Vector(vec.x, vec.y, 0)); - } - else - dirValue = section.GetBlockLight(vec); - - dirValue = _max(self, dirValue); - - if (dir == directions[0]) - lightness.face[FaceDirection::east] = dirValue; - if (dir == directions[1]) - lightness.face[FaceDirection::west] = dirValue; - if (dir == directions[2]) - lightness.face[FaceDirection::up] = dirValue; - if (dir == directions[3]) - lightness.face[FaceDirection::down] = dirValue; - if (dir == directions[4]) - lightness.face[FaceDirection::south] = dirValue; - if (dir == directions[5]) - lightness.face[FaceDirection::north] = dirValue; - } - return lightness; +BlockLightness SectionsData::GetLight(const Vector& pos) const { + BlockLightness lightness; + for (size_t i = 0; i <= FaceDirection::none; i++) { + Vector vec = pos + FaceDirectionVector[i]; + uint8_t dirValue = GetSection(vec).GetBlockLight(vec); + + if (i == FaceDirection::none) + lightness.self = dirValue; + else + lightness.face[i] = dirValue; + } + return lightness; } BlockLightness SectionsData::GetSkyLight(const Vector &pos) const { - BlockLightness lightness; - static const Vector directions[] = { - Vector(1,0,0), - Vector(-1,0,0), - Vector(0,1,0), - Vector(0,-1,0), - Vector(0,0,1), - Vector(0,0,-1), - }; - - unsigned char self = section.GetBlockSkyLight(pos); - - for (const Vector &dir : directions) { - Vector vec = pos + dir; - unsigned char dirValue = 0; - - if (vec.x < 0 || vec.x > 15 || vec.y < 0 || vec.y > 15 || vec.z < 0 || vec.z > 15) { - if (vec.x < 0) - dirValue = east.GetBlockSkyLight(Vector(15, vec.y, vec.z)); - if (vec.x > 15) - dirValue = west.GetBlockSkyLight(Vector(0, vec.y, vec.z)); - if (vec.y < 0) - dirValue = bottom.GetBlockSkyLight(Vector(vec.x, 15, vec.z)); - if (vec.y > 15) - dirValue = top.GetBlockSkyLight(Vector(vec.x, 0, vec.z)); - if (vec.z < 0) - dirValue = south.GetBlockSkyLight(Vector(vec.x, vec.y, 15)); - if (vec.z > 15) - dirValue = north.GetBlockSkyLight(Vector(vec.x, vec.y, 0)); - } - else - dirValue = section.GetBlockSkyLight(vec); - - dirValue = _max(self, dirValue); - - if (dir == directions[0]) - lightness.face[FaceDirection::east] = dirValue; - if (dir == directions[1]) - lightness.face[FaceDirection::west] = dirValue; - if (dir == directions[2]) - lightness.face[FaceDirection::up] = dirValue; - if (dir == directions[3]) - lightness.face[FaceDirection::down] = dirValue; - if (dir == directions[4]) - lightness.face[FaceDirection::south] = dirValue; - if (dir == directions[5]) - lightness.face[FaceDirection::north] = dirValue; - } - return lightness; + BlockLightness lightness; + for (size_t i = 0; i <= FaceDirection::none; i++) { + Vector vec = pos + FaceDirectionVector[i]; + uint8_t dirValue = GetSection(vec).GetBlockSkyLight(vec); + + if (i == FaceDirection::none) + lightness.self = dirValue; + else + lightness.face[i] = dirValue; + } + return lightness; } -- cgit v1.2.3 From 9feb51764077093a95a7b98af4b936a242096087 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 25 Dec 2021 11:37:53 +0500 Subject: Added smooth lighting settings parameter --- src/RendererSectionData.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/RendererSectionData.cpp') diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index b5260f4..761dd14 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -59,7 +59,7 @@ float InterpolateBlockLightness(const BlockLightness& light, const glm::vec3 &po return (glm::max)(xLight, (glm::max)(yLight, zLight)); } -void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, const glm::mat4& transform, bool visibility[FaceDirection::none], const Vector &pos, const SectionsData §ions) { +void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, const glm::mat4& transform, bool visibility[FaceDirection::none], const Vector &pos, const SectionsData §ions, bool smoothLighting) { glm::vec3 absPos = (sections.data[1][1][1].GetPosition() * 16).glm(); for (const auto& face : model.faces) { if (face.visibility != FaceDirection::none) { @@ -100,8 +100,7 @@ void AddFacesByBlockModel(RendererSectionData& data, const BlockFaces& model, co vertexData.layerAnimationAo.g = face.frames; vertexData.colors = face.color; - bool useSmoothLighting = true; - if (useSmoothLighting) { + if (smoothLighting) { for (size_t i = 0; i < 4; i++) { glm::vec3 baseLightPos = vertexData.positions[i] - absPos; glm::vec3 lightPos = baseLightPos + normal * 0.5f; @@ -188,7 +187,7 @@ std::array SetBlockIdData(const SectionsData §ions) { return blockIdData; } -RendererSectionData ParseSection(const SectionsData §ions) { +RendererSectionData ParseSection(const SectionsData §ions, bool smoothLighting) { OPTICK_EVENT(); RendererSectionData data; @@ -214,7 +213,7 @@ RendererSectionData ParseSection(const SectionsData §ions) { transform = glm::translate(baseOffset, vec.glm()); BlockFaces *model = GetInternalBlockModel(block, idModels); - AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], vec, sections); + AddFacesByBlockModel(data, *model, transform, blockVisibility[y * 256 + z * 16 + x], vec, sections, smoothLighting); } } } -- cgit v1.2.3