[shrub] Fix bug with gs-prim settings (#2899)

Fix the bug described in
https://github.com/open-goal/jak-project/issues/2882 where some shrubs
are transparent when they shouldn't be. The problem was that we never
carefully looked at the settings in `gs-prim`, which has a bit to
enable/disable alpha blending entirely. Now it should be correct for
both jak 1 and jak 2. To see this change, you'll need to re-extract.

Also adds a setting to disable saving texture .pngs, to speed up
decompilation. I left it on for jak 1 (to avoid confusion for texture
swapping(, but off for jak 2 for now.
This commit is contained in:
water111
2023-08-13 16:06:59 -04:00
committed by GitHub
parent 7abfeb4aa7
commit ac52be1a6c
9 changed files with 41 additions and 16 deletions
+2 -1
View File
@@ -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;
+3
View File
@@ -272,6 +272,9 @@ Config make_config_via_json(nlohmann::json& json) {
config.levels_to_extract = inputs_json.at("levels_to_extract").get<std::vector<std::string>>();
config.levels_extract = json.at("levels_extract").get<bool>();
if (json.contains("save_texture_pngs")) {
config.save_texture_pngs = json.at("save_texture_pngs").get<bool>();
}
if (inputs_json.contains("animated_textures")) {
config.animated_textures =
+1
View File
@@ -165,6 +165,7 @@ struct Config {
std::vector<std::string> levels_to_extract;
bool levels_extract;
bool save_texture_pngs = false;
DecompileHacks hacks;
+2
View File
@@ -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
+2
View File
@@ -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
////////////////////////////
+26 -13
View File
@@ -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<std::string>& animated_textures) {
const std::unordered_set<std::string>& 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++;
+2 -1
View File
@@ -16,5 +16,6 @@ struct TPageResultStats {
TPageResultStats process_tpage(ObjectFileData& data,
TextureDB& texture_db,
const fs::path& output_path,
const std::unordered_set<std::string>& animated_textures);
const std::unordered_set<std::string>& animated_textures,
bool save_pngs);
} // namespace decompiler
@@ -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
+1 -1
View File
@@ -2442,7 +2442,7 @@ void handle_draw_for_strip(tfrag3::TieTree& tree,
std::vector<tfrag3::StripDraw>& category_draws,
const std::vector<std::vector<std::pair<int, int>>>& packed_vert_indices,
DrawMode mode,
u32 idx_in_lev_data,
s32 idx_in_lev_data,
const TieStrip& strip,
const TieInstanceInfo& inst,
const TieInstanceFragInfo& ifrag,