fix custom model blocks lighting

This commit is contained in:
MihailRis 2025-12-18 19:24:12 +03:00
parent ff553b3b1e
commit b73d397643

View file

@ -306,7 +306,6 @@ void BlocksRenderer::blockCustomModel(
Y = orient.axes[1];
Z = orient.axes[2];
}
auto blockSize = block.size;
const auto& model = cache.getModel(block.rt.id, block.getVariantIndex(states.userbits));
for (const auto& mesh : model.meshes) {
@ -344,12 +343,9 @@ void BlocksRenderer::blockCustomModel(
glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f};
if (mesh.shading && ao) {
auto p = vcoord.x * X + vcoord.y * Y +
vcoord.z * Z + r * 0.5f + t * 0.5f + n * 0.5f;
const float eps = 0.01f;
p.x = glm::max(-0.5f * blockSize.x + eps, glm::min(0.5f * blockSize.x - eps, p.x));
p.y = glm::max(-0.5f * blockSize.y + eps, glm::min(0.5f * blockSize.y - eps, p.y));
p.z = glm::max(-0.5f * blockSize.z + eps, glm::min(0.5f * blockSize.z - eps, p.z));
const float eps = 0.05f;
auto p = vcoord.x * X + vcoord.y * Y + vcoord.z * Z +
r * 0.5f + t * 0.5f + n * eps;
p = coord + p;
aoColor = pickSoftLight(p.x, p.y, p.z, glm::ivec3(r), glm::ivec3(t));
}