mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
Merge pull request #980 from MihailRis/fix-custom-model-blocks-no-ao-shading
fix custom model blocks with disabled ambient-occlusion
This commit is contained in:
commit
7bbdf67bce
1 changed files with 22 additions and 12 deletions
|
|
@ -357,10 +357,11 @@ void BlocksRenderer::blockCustomModel(
|
|||
const auto& vcoord = vertex.coord - 0.5f;
|
||||
|
||||
glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
if (shading && ao) {
|
||||
if (shading) {
|
||||
const float eps = 0.05f;
|
||||
auto p = coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z +
|
||||
r * 0.5f + t * 0.5f + n * eps;
|
||||
if (ao) {
|
||||
auto p1 = p + n * eps;
|
||||
auto p2 = p + n * 0.5f;
|
||||
aoColor = pickSoftLight(p1.x, p1.y, p1.z, glm::ivec3(r), glm::ivec3(t));
|
||||
|
|
@ -372,6 +373,15 @@ void BlocksRenderer::blockCustomModel(
|
|||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
aoColor = pickLight(glm::floor(p + 0.5f) + 0.5f);
|
||||
if (!block.lightPassing) {
|
||||
aoColor = glm::max(
|
||||
aoColor,
|
||||
pickLight(glm::floor(p + n + 0.5f) + 0.5f)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->vertex(
|
||||
coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue