mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix custom model blocks lighting
This commit is contained in:
parent
7424ff3ddf
commit
ff553b3b1e
1 changed files with 7 additions and 1 deletions
|
|
@ -306,6 +306,7 @@ 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) {
|
||||
|
|
@ -343,8 +344,13 @@ void BlocksRenderer::blockCustomModel(
|
|||
|
||||
glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
if (mesh.shading && ao) {
|
||||
auto p = coord + vcoord.x * X + vcoord.y * Y +
|
||||
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));
|
||||
p = coord + p;
|
||||
aoColor = pickSoftLight(p.x, p.y, p.z, glm::ivec3(r), glm::ivec3(t));
|
||||
}
|
||||
this->vertex(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue