fix custom models shading flag & add more properties to vcm

This commit is contained in:
MihailRis
2025-07-13 18:51:53 +03:00
parent 57a9a26c23
commit 3e59b186d3
6 changed files with 40 additions and 16 deletions
+3 -3
View File
@@ -341,7 +341,7 @@ void BlocksRenderer::blockCustomModel(
const auto& vcoord = vertex.coord - 0.5f;
glm::vec4 aoColor {1.0f, 1.0f, 1.0f, 1.0f};
if (ao) {
if (mesh.shading && ao) {
auto p = coord + vcoord.x * X + vcoord.y * Y +
vcoord.z * Z + r * 0.5f + t * 0.5f + n * 0.5f;
aoColor = pickSoftLight(p.x, p.y, p.z, glm::ivec3(r), glm::ivec3(t));
@@ -350,9 +350,9 @@ void BlocksRenderer::blockCustomModel(
coord + vcoord.x * X + vcoord.y * Y + vcoord.z * Z,
vertex.uv.x,
vertex.uv.y,
glm::vec4(d, d, d, d) * aoColor,
mesh.shading ? (glm::vec4(d, d, d, d) * aoColor) : glm::vec4(1, 1, 1, d),
n,
0.0f
mesh.shading ? 0.0f : 1.0
);
indexBuffer[indexCount++] = vertexOffset++;
}
+3 -3
View File
@@ -70,7 +70,7 @@ void ModelBatch::draw(
const auto& vertexData = mesh.vertices.data();
glm::vec4 lights(1, 1, 1, 0);
if (mesh.lighting) {
if (mesh.shading) {
glm::vec3 gpos = matrix * glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
gpos += lightsOffset;
lights = MainBatch::sampleLight(gpos, chunks, backlight);
@@ -81,7 +81,7 @@ void ModelBatch::draw(
const auto vert = vertexData[i * 3 + j];
float d = 1.0f;
auto norm = rotation * vert.normal;
if (mesh.lighting) {
if (mesh.shading) {
d = glm::dot(norm, SUN_VECTOR);
d = 0.8f + d * 0.2f;
}
@@ -91,7 +91,7 @@ void ModelBatch::draw(
lights * d,
tint,
norm,
mesh.lighting ? 0.0f : 1.0f
mesh.shading ? 0.0f : 1.0f
);
}
}
+3 -3
View File
@@ -97,7 +97,7 @@ model::Model ModelsGenerator::fromCustom(
auto model = model::Model();
for (size_t i = 0; i < modelBoxes.size(); i++) {
auto& mesh = model.addMesh("blocks:");
mesh.lighting = lighting;
mesh.shading = lighting;
UVRegion boxtexfaces[6] = {
get_region_for(modelTextures[i * 6 + 5], assets),
get_region_for(modelTextures[i * 6 + 4], assets),
@@ -132,7 +132,7 @@ model::Model ModelsGenerator::fromCustom(
norm = glm::normalize(norm);
auto& mesh = model.addMesh(texture);
mesh.lighting = lighting;
mesh.shading = lighting;
auto reg = get_region_for(texture, assets);
mesh.vertices.push_back({v0, glm::vec2(reg.u1, reg.v1), norm});
@@ -163,7 +163,7 @@ model::Model ModelsGenerator::generate(
return model;
}
for (auto& mesh : model.meshes) {
mesh.lighting = !blockDef.shadeless;
mesh.shading = !blockDef.shadeless;
switch (blockDef.model.type) {
case BlockModelType::AABB: {
glm::vec3 size = blockDef.hitboxes.at(0).size();