From eac11b5b93cf965f547ff84912944489b2356760 Mon Sep 17 00:00:00 2001 From: water111 <48171810+water111@users.noreply.github.com> Date: Sat, 19 Oct 2024 11:21:30 -0400 Subject: [PATCH] [jak3] Fix target marker texture (#3721) Fixes https://github.com/open-goal/jak-project/issues/3720. The texture page and texture name appear multiple times with different IDs, meaning that we insert the texture with the wrong ID. Fixed by using IDs for common_tpage textures. Since this common_tpage feature is only used for minimap stuff, I don't think it can mess up texture animations. ![image](https://github.com/user-attachments/assets/0d5d45e9-b69a-48b5-86c9-b9c597f0872e) Co-authored-by: water111 --- decompiler/level_extractor/extract_level.cpp | 9 +++++++-- game/graphics/opengl_renderer/OpenGLRenderer.cpp | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/decompiler/level_extractor/extract_level.cpp b/decompiler/level_extractor/extract_level.cpp index e77ef5d62..4aa68323a 100644 --- a/decompiler/level_extractor/extract_level.cpp +++ b/decompiler/level_extractor/extract_level.cpp @@ -279,20 +279,25 @@ void extract_common(const ObjectFileDB& db, extract_art_groups_from_level(db, tex_db, {}, "ARTSPOOL", tfrag_level, art_group_data); std::set textures_we_have; + std::set textures_we_have_id; // put _all_ index textures in common. for (const auto& [id, tex] : tex_db.index_textures_by_combo_id) { tfrag_level.index_textures.push_back(tex); } + // remember which textures we already added. + // textures with the same name or the same ID always have the same data. for (const auto& t : tfrag_level.textures) { textures_we_have.insert(t.debug_name); + textures_we_have_id.insert(t.combo_id); } + // for common textures, add if the ID isn't there - common textures are looked up by ID. for (const auto& [id, normal_texture] : tex_db.textures) { - if (config.common_tpages.count(normal_texture.page) && - !textures_we_have.count(normal_texture.name)) { + if (config.common_tpages.count(normal_texture.page) && !textures_we_have_id.count(id)) { textures_we_have.insert(normal_texture.name); + textures_we_have_id.insert(id); tfrag_level.textures.push_back( make_texture(id, normal_texture, tex_db.tpage_names.at(normal_texture.page), true)); } diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 4718177cd..377b72b17 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -366,10 +366,8 @@ void OpenGLRenderer::init_bucket_renderers_jak3() { BucketId::DEBUG_NO_ZBUF1, m_texture_animator, true); // 578 init_bucket_renderer("tex-hud-hud-alpha", BucketCategory::TEX, - BucketId::TEX_HUD_HUD_ALPHA, m_texture_animator); - - init_bucket_renderer("tex-hud-hud-alpha", BucketCategory::TEX, - BucketId::TEX_HUD_HUD_ALPHA, m_texture_animator); + BucketId::TEX_HUD_HUD_ALPHA, m_texture_animator, + true); init_bucket_renderer("hud-draw-hud-alpha", BucketCategory::OTHER, BucketId::HUD_DRAW_HUD_ALPHA, 0x8000); init_bucket_renderer("tex-hud-pris2", BucketCategory::TEX,