diff --git a/decompiler/ObjectFile/ObjectFileDB.cpp b/decompiler/ObjectFile/ObjectFileDB.cpp index 66deffca6..2febc5271 100644 --- a/decompiler/ObjectFile/ObjectFileDB.cpp +++ b/decompiler/ObjectFile/ObjectFileDB.cpp @@ -741,7 +741,8 @@ std::string ObjectFileDB::process_tpages(TextureDB& tex_db, std::string result; for_each_obj([&](ObjectFileData& data) { if (data.name_in_dgo.substr(0, tpage_string.length()) == tpage_string) { - auto statistics = process_tpage(data, tex_db, output_path, cfg.animated_textures); + auto statistics = + process_tpage(data, tex_db, output_path, cfg.animated_textures, cfg.save_texture_pngs); total += statistics.total_textures; success += statistics.successful_textures; total_px += statistics.num_px; diff --git a/decompiler/config.cpp b/decompiler/config.cpp index 8145f69bb..ffc1a2d60 100644 --- a/decompiler/config.cpp +++ b/decompiler/config.cpp @@ -272,6 +272,9 @@ Config make_config_via_json(nlohmann::json& json) { config.levels_to_extract = inputs_json.at("levels_to_extract").get>(); config.levels_extract = json.at("levels_extract").get(); + if (json.contains("save_texture_pngs")) { + config.save_texture_pngs = json.at("save_texture_pngs").get(); + } if (inputs_json.contains("animated_textures")) { config.animated_textures = diff --git a/decompiler/config.h b/decompiler/config.h index 50531367a..f9689bc31 100644 --- a/decompiler/config.h +++ b/decompiler/config.h @@ -165,6 +165,7 @@ struct Config { std::vector levels_to_extract; bool levels_extract; + bool save_texture_pngs = false; DecompileHacks hacks; diff --git a/decompiler/config/jak1/jak1_config.jsonc b/decompiler/config/jak1/jak1_config.jsonc index cf6750aac..6a3a5aafe 100644 --- a/decompiler/config/jak1/jak1_config.jsonc +++ b/decompiler/config/jak1/jak1_config.jsonc @@ -104,6 +104,8 @@ // should we extract collision meshes? // these can be displayed in game, but makes the .fr3 files slightly larger "extract_collision": true, + // save game textures as .png files. + "save_texture_pngs": true, //////////////////////////// // PATCHING OPTIONS diff --git a/decompiler/config/jak2/jak2_config.jsonc b/decompiler/config/jak2/jak2_config.jsonc index 87f76cc7e..ee33e295b 100644 --- a/decompiler/config/jak2/jak2_config.jsonc +++ b/decompiler/config/jak2/jak2_config.jsonc @@ -115,6 +115,8 @@ // these can be displayed in game, but makes the .fr3 files slightly larger "extract_collision": true, + "save_texture_pngs": false, + //////////////////////////// // PATCHING OPTIONS //////////////////////////// diff --git a/decompiler/data/tpage.cpp b/decompiler/data/tpage.cpp index 005e14a57..a1579f602 100644 --- a/decompiler/data/tpage.cpp +++ b/decompiler/data/tpage.cpp @@ -433,7 +433,8 @@ TexturePage read_texture_page(ObjectFileData& data, TPageResultStats process_tpage(ObjectFileData& data, TextureDB& texture_db, const fs::path& output_path, - const std::unordered_set& animated_textures) { + const std::unordered_set& animated_textures, + bool save_pngs) { TPageResultStats stats; auto& words = data.linked_data.words_by_seg.at(0); const auto& level_names = data.dgo_names; @@ -596,8 +597,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; @@ -639,8 +642,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; @@ -664,8 +669,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; @@ -705,8 +712,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; @@ -746,8 +755,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; @@ -771,8 +782,10 @@ TPageResultStats process_tpage(ObjectFileData& data, } // write texture to a PNG. - file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), - tex.w, tex.h); + if (save_pngs) { + file_util::write_rgba_png(texture_dump_dir / fmt::format("{}.png", tex.name), out.data(), + tex.w, tex.h); + } texture_db.add_texture(texture_page.id, tex_id, out, tex.w, tex.h, tex.name, texture_page.name, level_names, tex.num_mips, tex.dest[0]); stats.successful_textures++; diff --git a/decompiler/data/tpage.h b/decompiler/data/tpage.h index d9592f71a..6ee3d6df3 100644 --- a/decompiler/data/tpage.h +++ b/decompiler/data/tpage.h @@ -16,5 +16,6 @@ struct TPageResultStats { TPageResultStats process_tpage(ObjectFileData& data, TextureDB& texture_db, const fs::path& output_path, - const std::unordered_set& animated_textures); + const std::unordered_set& animated_textures, + bool save_pngs); } // namespace decompiler diff --git a/decompiler/level_extractor/extract_shrub.cpp b/decompiler/level_extractor/extract_shrub.cpp index fdb3f95ec..eb86c3371 100644 --- a/decompiler/level_extractor/extract_shrub.cpp +++ b/decompiler/level_extractor/extract_shrub.cpp @@ -155,11 +155,13 @@ DrawSettings adgif_to_draw_mode(const AdGifData& ad, current_mode.set_depth_write_enable(true); // todo, is this actual true current_mode.set_alpha_blend(DrawMode::AlphaBlend::SRC_SRC_SRC_SRC); current_mode.enable_fog(); + current_mode.set_ab(false); if (alpha_tpage_flag) { current_mode.set_alpha_test(DrawMode::AlphaTest::NEVER); current_mode.set_aref(0); current_mode.set_alpha_fail(GsTest::AlphaFail::FB_ONLY); + current_mode.set_ab(true); } // ADGIF 0 diff --git a/decompiler/level_extractor/extract_tie.cpp b/decompiler/level_extractor/extract_tie.cpp index e247cc585..c6db02d09 100644 --- a/decompiler/level_extractor/extract_tie.cpp +++ b/decompiler/level_extractor/extract_tie.cpp @@ -2442,7 +2442,7 @@ void handle_draw_for_strip(tfrag3::TieTree& tree, std::vector& category_draws, const std::vector>>& packed_vert_indices, DrawMode mode, - u32 idx_in_lev_data, + s32 idx_in_lev_data, const TieStrip& strip, const TieInstanceInfo& inst, const TieInstanceFragInfo& ifrag,