From 724bbcdfdd5166ae07099bacc82d66973583bc37 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 20 May 2025 15:05:51 +0900 Subject: [PATCH] 3d: Disable light mapping for meshes without light_uv --- src/3d/3d_internal.h | 1 + src/3d/parser.c | 1 + src/3d/renderer.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/3d/3d_internal.h b/src/3d/3d_internal.h index a7c1677..4175210 100644 --- a/src/3d/3d_internal.h +++ b/src/3d/3d_internal.h @@ -438,6 +438,7 @@ enum mesh_flags { MESH_NO_EDGE = 1 << 6, MESH_NO_HEIGHT_DETECTION = 1 << 7, MESH_ALPHA = 1 << 8, + MESH_HAS_LIGHT_UV = 1 << 9, }; struct pol_mesh { diff --git a/src/3d/parser.c b/src/3d/parser.c index cec10a4..207c9f7 100644 --- a/src/3d/parser.c +++ b/src/3d/parser.c @@ -218,6 +218,7 @@ static struct pol_mesh *parse_mesh(struct buffer *r, const struct pol *pol) mesh->nr_light_uvs = buffer_read_int32(r); if (mesh->nr_light_uvs > 0) { + mesh->flags |= MESH_HAS_LIGHT_UV; mesh->light_uvs = xcalloc(mesh->nr_light_uvs, sizeof(vec2)); for (uint32_t i = 0; i < mesh->nr_light_uvs; i++) { mesh->light_uvs[i][0] = buffer_read_float(r); diff --git a/src/3d/renderer.c b/src/3d/renderer.c index 750d9ad..78b053c 100644 --- a/src/3d/renderer.c +++ b/src/3d/renderer.c @@ -401,7 +401,7 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d glUniform1i(r->diffuse_type, DIFFUSE_ENV_MAP); } else if (mesh->flags & MESH_NOLIGHTING) { glUniform1i(r->diffuse_type, DIFFUSE_EMISSIVE); - } else if (material->light_map && inst->plugin->light_map_mode) { + } else if (material->light_map && mesh->flags & MESH_HAS_LIGHT_UV && inst->plugin->light_map_mode) { glUniform1i(r->diffuse_type, DIFFUSE_LIGHT_MAP); glActiveTexture(GL_TEXTURE0 + LIGHT_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, material->light_map);