From 74666c9b90f05973bf31db83c7aa8269ccea4cd8 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 24 Sep 2024 14:46:55 +0900 Subject: [PATCH] 3d: Ignore alpha map if same as color map In Rance Quest (e.g. mapF_ew01), some materials use the same image for both color map and alpha map. In that case, the alpha channel of the color map can be used, so ignore the alpha map. --- src/3d/model.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/3d/model.c b/src/3d/model.c index a437f43..04e1495 100644 --- a/src/3d/model.c +++ b/src/3d/model.c @@ -107,8 +107,13 @@ static bool init_material(struct material *material, const struct pol_material * if (m->textures[SPECULAR_MAP]) material->specular_map = load_texture(aar, path, m->textures[SPECULAR_MAP], NULL); - if (m->textures[ALPHA_MAP]) - material->alpha_map = load_texture(aar, path, m->textures[ALPHA_MAP], NULL); + if (m->textures[ALPHA_MAP]) { + if (has_alpha && !strcmp(m->textures[COLOR_MAP], m->textures[ALPHA_MAP])) { + // Do nothing; the alpha channel of the color map is used. + } else { + material->alpha_map = load_texture(aar, path, m->textures[ALPHA_MAP], NULL); + } + } if (m->textures[LIGHT_MAP]) material->light_map = load_texture(aar, path, m->textures[LIGHT_MAP], NULL); if (m->textures[NORMAL_MAP])