fix: 'shadeless' block property ignored if custom model is used

This commit is contained in:
MihailRis 2025-12-18 20:32:26 +03:00
parent 1de669092c
commit 78062e2197

View file

@ -309,6 +309,7 @@ void BlocksRenderer::blockCustomModel(
overflow = true; overflow = true;
return; return;
} }
bool shading = mesh.shading && !block.shadeless;
for (int triangle = 0; triangle < mesh.vertices.size() / 3; triangle++) { for (int triangle = 0; triangle < mesh.vertices.size() / 3; triangle++) {
auto r = mesh.vertices[triangle * 3 + (triangle % 2) * 2].coord - auto r = mesh.vertices[triangle * 3 + (triangle % 2) * 2].coord -
mesh.vertices[triangle * 3 + 1].coord; mesh.vertices[triangle * 3 + 1].coord;
@ -338,7 +339,7 @@ void BlocksRenderer::blockCustomModel(
const auto& vcoord = vertex.coord - 0.5f; const auto& vcoord = vertex.coord - 0.5f;
glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f}; glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f};
if (mesh.shading && ao) { if (shading && ao) {
const float eps = 0.05f; const float eps = 0.05f;
auto p = coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z + auto p = coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z +
r * 0.5f + t * 0.5f + n * eps; r * 0.5f + t * 0.5f + n * eps;
@ -358,9 +359,9 @@ void BlocksRenderer::blockCustomModel(
coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z, coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z,
vertex.uv.x, vertex.uv.x,
vertex.uv.y, vertex.uv.y,
mesh.shading ? (glm::vec4(d, d, d, d) * aoColor) : glm::vec4(1, 1, 1, d), shading ? (glm::vec4(d, d, d, d) * aoColor) : glm::vec4(1, 1, 1, d),
n, n,
mesh.shading ? 0.0f : 1.0 shading ? 0.0f : 1.0
); );
indexBuffer[indexCount++] = vertexOffset++; indexBuffer[indexCount++] = vertexOffset++;
} }