Custom models lights fix
This commit is contained in:
parent
72d589d39e
commit
484c2b85cf
@ -153,11 +153,20 @@ void BlocksRenderer::tetragonicFace(const vec3& coord, const vec3& p1,
|
|||||||
const vec3& Y,
|
const vec3& Y,
|
||||||
const vec3& Z,
|
const vec3& Z,
|
||||||
const UVRegion& texreg,
|
const UVRegion& texreg,
|
||||||
const vec4& tint) {
|
bool lights) {
|
||||||
vertex(coord + (p1.x - 0.5f) * X + (p1.y - 0.5f) * Y + (p1.z - 0.5f) * Z, texreg.u1, texreg.v1, tint);
|
glm::vec3 dir = glm::cross(p2 - p1, p3 - p1);
|
||||||
vertex(coord + (p2.x - 0.5f) * X + (p2.y - 0.5f) * Y + (p2.z - 0.5f) * Z, texreg.u2, texreg.v1, tint);
|
glm::vec3 normal = glm::normalize(dir);
|
||||||
vertex(coord + (p3.x - 0.5f) * X + (p3.y - 0.5f) * Y + (p3.z - 0.5f) * Z, texreg.u2, texreg.v2, tint);
|
glm::vec4 tintx(1.0f);
|
||||||
vertex(coord + (p4.x - 0.5f) * X + (p4.y - 0.5f) * Y + (p4.z - 0.5f) * Z, texreg.u1, texreg.v2, tint);
|
if (lights) {
|
||||||
|
float d = glm::dot(normal, SUN_VECTOR);
|
||||||
|
d = 0.7f + d * 0.3f;
|
||||||
|
tintx *= d;
|
||||||
|
tintx *= pickLight(coord);
|
||||||
|
}
|
||||||
|
vertex(coord + (p1.x - 0.5f) * X + (p1.y - 0.5f) * Y + (p1.z - 0.5f) * Z, texreg.u1, texreg.v1, tintx);
|
||||||
|
vertex(coord + (p2.x - 0.5f) * X + (p2.y - 0.5f) * Y + (p2.z - 0.5f) * Z, texreg.u2, texreg.v1, tintx);
|
||||||
|
vertex(coord + (p3.x - 0.5f) * X + (p3.y - 0.5f) * Y + (p3.z - 0.5f) * Z, texreg.u2, texreg.v2, tintx);
|
||||||
|
vertex(coord + (p4.x - 0.5f) * X + (p4.y - 0.5f) * Y + (p4.z - 0.5f) * Z, texreg.u1, texreg.v2, tintx);
|
||||||
index(0, 1, 3, 1, 2, 3);
|
index(0, 1, 3, 1, 2, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +277,7 @@ void BlocksRenderer::blockCustomModel(const ivec3& icoord,
|
|||||||
block->modelExtraPoints[i * 4 + 2],
|
block->modelExtraPoints[i * 4 + 2],
|
||||||
block->modelExtraPoints[i * 4 + 3],
|
block->modelExtraPoints[i * 4 + 3],
|
||||||
X, Y, Z,
|
X, Y, Z,
|
||||||
block->modelUVs[block->modelBoxes.size()*6 + i], vec4(tint));
|
block->modelUVs[block->modelBoxes.size()*6 + i], lights);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ class BlocksRenderer {
|
|||||||
const glm::vec3& Y,
|
const glm::vec3& Y,
|
||||||
const glm::vec3& Z,
|
const glm::vec3& Z,
|
||||||
const UVRegion& texreg,
|
const UVRegion& texreg,
|
||||||
const glm::vec4& tint);
|
bool lights);
|
||||||
|
|
||||||
void blockCube(int x, int y, int z, const UVRegion(&faces)[6], const Block* block, ubyte states, bool lights);
|
void blockCube(int x, int y, int z, const UVRegion(&faces)[6], const Block* block, ubyte states, bool lights);
|
||||||
void blockAABB(const glm::ivec3& coord,
|
void blockAABB(const glm::ivec3& coord,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user