diff --git a/source/client/world/mesh/BlockMesher.cpp b/source/client/world/mesh/BlockMesher.cpp index 0f6a579c..176fb8cd 100644 --- a/source/client/world/mesh/BlockMesher.cpp +++ b/source/client/world/mesh/BlockMesher.cpp @@ -200,15 +200,18 @@ void BlockMesher::addBlockFace(s8f x, s8f y, s8f z, s8f f, ChunkMeshBuildingJob vertices[v].texCoord[0] = gk::qlerpf(blockTexCoords.x, blockTexCoords.x + blockTexCoords.sizeX, U); vertices[v].texCoord[1] = gk::qlerpf(blockTexCoords.y, blockTexCoords.y + blockTexCoords.sizeY, V); + // Lighting-based implementation + bool useAO = Config::ambientOcclusion == 2 && blockState.drawType() != BlockDrawType::Multibox; + if (Config::isSmoothLightingEnabled) - vertices[v].lightValue[0] = getLightForVertex(LightType::Sun, x, y, z, *neighbourOfs[v], normal, job.chunkData); + vertices[v].lightValue[0] = getLightForVertex(LightType::Sun, x, y, z, *neighbourOfs[v], normal, job.chunkData, useAO); else if (blockState.isOpaque()) vertices[v].lightValue[0] = job.chunkData.getSunlight(sx, sy, sz); else vertices[v].lightValue[0] = job.chunkData.getSunlight(x, y, z); if (Config::isSmoothLightingEnabled && !blockState.isLightSource()) - vertices[v].lightValue[1] = getLightForVertex(LightType::Torch, x, y, z, *neighbourOfs[v], normal, job.chunkData); + vertices[v].lightValue[1] = getLightForVertex(LightType::Torch, x, y, z, *neighbourOfs[v], normal, job.chunkData, useAO); else if (blockState.isOpaque()) vertices[v].lightValue[1] = job.chunkData.getTorchlight(sx, sy, sz); else @@ -218,7 +221,7 @@ void BlockMesher::addBlockFace(s8f x, s8f y, s8f z, s8f f, ChunkMeshBuildingJob } auto addVertex = [&](u8 v) { - if (Config::ambientOcclusion != 1 || blockState.isLightSource()) + if (Config::ambientOcclusion != 1 || blockState.isLightSource() || blockState.drawType() == BlockDrawType::Multibox) vertices[v].ambientOcclusion = 4; if (blockState.drawType() == BlockDrawType::Liquid) diff --git a/source/client/world/mesh/LightUtils.cpp b/source/client/world/mesh/LightUtils.cpp index b76871d7..64e86a12 100644 --- a/source/client/world/mesh/LightUtils.cpp +++ b/source/client/world/mesh/LightUtils.cpp @@ -24,7 +24,6 @@ * * ===================================================================================== */ -#include "Config.hpp" #include "LightUtils.hpp" // Based on this article: https://0fps.net/2013/07/03/ambient-occlusion-for-minecraft-like-worlds/ @@ -63,7 +62,7 @@ u8 LightUtils::getAmbientOcclusion(s8f x, s8f y, s8f z, u8 LightUtils::getLightForVertex(LightType lightType, s8f x, s8f y, s8f z, const gk::Vector3 &offset, const gk::Vector3 &normal, - const ChunkData &chunk) + const ChunkData &chunk, bool useAO) { gk::Vector3 minOffset{ (normal.x != 0) ? offset.x : s8f(0), @@ -100,7 +99,7 @@ u8 LightUtils::getLightForVertex(LightType lightType, s8f x, s8f y, s8f z, // If the chunk is initialized, add the light value to the total // But only add dark blocks if AO is set on Smooth Lighting - if (lightValues[i] != -1 && (Config::ambientOcclusion == 2 || lightValues[i] != 0)) { + if (lightValues[i] != -1 && (useAO || lightValues[i] != 0)) { total += (u8)lightValues[i]; ++count; } diff --git a/source/client/world/mesh/LightUtils.hpp b/source/client/world/mesh/LightUtils.hpp index d991e050..6c186f0f 100644 --- a/source/client/world/mesh/LightUtils.hpp +++ b/source/client/world/mesh/LightUtils.hpp @@ -40,7 +40,7 @@ namespace LightUtils { u8 getLightForVertex(LightType lightType, s8f x, s8f y, s8f z, const gk::Vector3 &offset, - const gk::Vector3 &normal, const ChunkData &chunk); + const gk::Vector3 &normal, const ChunkData &chunk, bool useAO); }; #endif // LIGHTUTILS_HPP_