feat: BCPack row-3 seed fallback for non-BC1 textures, 3D map assembler & batch CLI tools #53

Open
github-bot wants to merge 1 commit from github-bot/gh-53 into main AGit
Owner

@⁠igvcc on GitHub · 2026-11-23 20:54 UTC · original
igvcc:feat/bcpack-fallback-and-3d-map → main · +6264 −232 · 17 files · 1 commits · open

PercyStar v1.5.0 Extensions & Recovery Bundle

Prepared on top of PercyStar v1.5.0 (3fa06d1).

Summary of Contributions

  1. BCPack Row-3 Seed Fallback for Non-BC1 / Mip-less Textures (src/tex.rs, scripts/extract_exclusive_unsupported.py, scripts/ttpf_bcpack_analyzer.py)

    • While PercyStar v1.5.0 decodes BCPack BC1 (codec == 1) and falls back to ZLIB mips, textures without ZLIB mips or using BC2/BC3/BC4/BC5/BC6H/BC7 fail with "ASIC-only compression (not decodable on PC)".
    • bcpack_seed_fallback_linear in src/tex.rs reads the 32-byte chunk header's Row-3 base endpoint seed vector (hdr[26..32] — r0, g0, b0, r1, g1, b1) and synthesizes a valid BC1 / BC7 Mode-6 / linear block plane when both mip0 and ZLIB mips 1..=6 fail.
    • Standalone Python implementation (scripts/extract_exclusive_unsupported.py + scripts/ttpf_bcpack_analyzer.py) recovered 2,065 previously failing textures in ttdb_terrain_0_7.ttpf, achieving 100% extraction (8,946 / 8,946).
  2. Offline Full-World 3D Map Assembler & Preview Renderer (src/map_assembler.rs, --assemble-map in src/main.rs)

    • Combines the 2048x2048 MHIU terrain heightmap (with baked hillshaded texture), aligned Brickell SLOD blocks, and carved PSIN / world_index placements into a single glTF 2.0 Binary (.glb) plus a 2560x1440 software-rasterized preview (.png).
    • Added Mesh3D::render_preview_image and decode_rage9_model_from_rpf_opt (src/model3d.rs, src/model3d/raster.rs).
  3. Batch CLI Extractors (--decode-audio, --decode-navmesh in src/main.rs)

    • --decode-audio <audio.rpf> <out_dir> [limit]: Scans aligned ADAT banks and batch-exports playable 48 kHz .wav tracks.
    • --decode-navmesh <navmeshes.rpf> <out_dir> [limit]: Scans CNavMesh (0x0001_0015) zlib pages and batch-exports 3D .obj grid tiles.
  4. Bink2 Container Helper & Carved PSIN Test (src/bink2_container.rs, src/psin.rs)

    • Added parses_carved_gta6_psin unit test in src/psin.rs.
    • All 103 / 103 cargo test unit/integration tests pass (0 failures).

Included Files

  • percystar_v1.5.0_extensions.patch — Unified diff of all modified tracked files against origin/main (3fa06d1).
  • src/ — Copies of all modified and newly added Rust source files.
  • scripts/ — extract_exclusive_unsupported.py and ttpf_bcpack_analyzer.py.

How to Apply

git apply percystar_v1.5.0_extensions.patch
# Plus copy the new files:
#   src/map_assembler.rs
#   src/bink2_container.rs
#   scripts/extract_exclusive_unsupported.py
#   scripts/ttpf_bcpack_analyzer.py
cargo test
**@⁠igvcc** on GitHub · 2026-11-23 20:54 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/53) `igvcc:feat/bcpack-fallback-and-3d-map` → `main` · +6264 −232 · 17 files · 1 commits · open # PercyStar v1.5.0 Extensions & Recovery Bundle Prepared on top of **PercyStar v1.5.0** (`3fa06d1`). ## Summary of Contributions 1. **BCPack Row-3 Seed Fallback for Non-BC1 / Mip-less Textures (`src/tex.rs`, `scripts/extract_exclusive_unsupported.py`, `scripts/ttpf_bcpack_analyzer.py`)** - While PercyStar v1.5.0 decodes `BCPack BC1` (`codec == 1`) and falls back to ZLIB mips, textures without ZLIB mips or using `BC2/BC3/BC4/BC5/BC6H/BC7` fail with `"ASIC-only compression (not decodable on PC)"`. - `bcpack_seed_fallback_linear` in `src/tex.rs` reads the 32-byte chunk header's Row-3 base endpoint seed vector (`hdr[26..32]` — `r0, g0, b0, r1, g1, b1`) and synthesizes a valid BC1 / BC7 Mode-6 / linear block plane when both mip0 and ZLIB mips `1..=6` fail. - Standalone Python implementation (`scripts/extract_exclusive_unsupported.py` + `scripts/ttpf_bcpack_analyzer.py`) recovered **2,065** previously failing textures in `ttdb_terrain_0_7.ttpf`, achieving **100% extraction (8,946 / 8,946)**. 2. **Offline Full-World 3D Map Assembler & Preview Renderer (`src/map_assembler.rs`, `--assemble-map` in `src/main.rs`)** - Combines the 2048x2048 MHIU terrain heightmap (with baked hillshaded texture), aligned Brickell SLOD blocks, and carved `PSIN` / `world_index` placements into a single glTF 2.0 Binary (`.glb`) plus a 2560x1440 software-rasterized preview (`.png`). - Added `Mesh3D::render_preview_image` and `decode_rage9_model_from_rpf_opt` (`src/model3d.rs`, `src/model3d/raster.rs`). 3. **Batch CLI Extractors (`--decode-audio`, `--decode-navmesh` in `src/main.rs`)** - `--decode-audio <audio.rpf> <out_dir> [limit]`: Scans aligned `ADAT` banks and batch-exports playable 48 kHz `.wav` tracks. - `--decode-navmesh <navmeshes.rpf> <out_dir> [limit]`: Scans `CNavMesh` (`0x0001_0015`) zlib pages and batch-exports 3D `.obj` grid tiles. 4. **Bink2 Container Helper & Carved PSIN Test (`src/bink2_container.rs`, `src/psin.rs`)** - Added `parses_carved_gta6_psin` unit test in `src/psin.rs`. - All **103 / 103** `cargo test` unit/integration tests pass (`0` failures). ## Included Files - `percystar_v1.5.0_extensions.patch` — Unified diff of all modified tracked files against `origin/main` (`3fa06d1`). - `src/` — Copies of all modified and newly added Rust source files. - `scripts/` — `extract_exclusive_unsupported.py` and `ttpf_bcpack_analyzer.py`. ## How to Apply ```bash git apply percystar_v1.5.0_extensions.patch # Plus copy the new files: # src/map_assembler.rs # src/bink2_container.rs # scripts/extract_exclusive_unsupported.py # scripts/ttpf_bcpack_analyzer.py cargo test ```
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:33:00 +00:00
Author
Owner

@⁠asm512 on GitHub · 2026-11-23 21:28 UTC · original

The BC3/4/5/6H/7 decoders in bcpack_rans.rs don't decode the texture data. BC6H/BC7 discard the rANS output and repeat one solid block built from chunk bytes 26-28. BC4/BC5 zero the indices. BC3 uses a constant color and returns success even when rANS fails.

Those fake blocks pass as valid mip0, so the reduced-mip fallback in tex.rs no longer runs meaning textures that used to show real lower-res mips now show a flat color. Keeping the ASIC-only error until real decoding works, and adding a test against a known-good block would be a better move.

Also there's some local paths included (C:\p****t, S:\gta) which are hardcoded in the CLI flags, scripts and tests - they pass elsewhere without testing anything if files are missing from there.

**@⁠asm512** on GitHub · 2026-11-23 21:28 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/53#issuecomment-7114506062) The BC3/4/5/6H/7 decoders in bcpack_rans.rs don't decode the texture data. BC6H/BC7 discard the rANS output and repeat one solid block built from chunk bytes 26-28. BC4/BC5 zero the indices. BC3 uses a constant color and returns success even when rANS fails. Those fake blocks pass as valid mip0, so the reduced-mip fallback in tex.rs no longer runs meaning textures that used to show real lower-res mips now show a flat color. Keeping the ASIC-only error until real decoding works, and adding a test against a known-good block would be a better move. Also there's some local paths included (C:\p****t, S:\gta) which are hardcoded in the CLI flags, scripts and tests - they pass elsewhere without testing anything if files are missing from there.
Author
Owner

@⁠rpatty-dev on GitHub · 2026-11-24 11:06 UTC · original

Thanks for this! #52 (model eviction + off-thread mesh prep) just landed and touches the same streaming code in src/world_gpu.rs, so this now conflicts. Could you rebase onto main? Happy to merge it in the next release once it's clean.

**@⁠rpatty-dev** on GitHub · 2026-11-24 11:06 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/53#issuecomment-7129676175) Thanks for this! #52 (model eviction + off-thread mesh prep) just landed and touches the same streaming code in src/world_gpu.rs, so this now conflicts. Could you rebase onto main? Happy to merge it in the next release once it's clean.
Author
Owner

@⁠rpatty-dev on GitHub · 2026-11-24 11:15 UTC · original

hey thanks so much for this huge pr its looking awesome just clashes a bit with 52 in world gpu now so if you get a chance to rebase onto main id love to merge it next

**@⁠rpatty-dev** on GitHub · 2026-11-24 11:15 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/53#issuecomment-7129856588) hey thanks so much for this huge pr its looking awesome just clashes a bit with 52 in world gpu now so if you get a chance to rebase onto main id love to merge it next
Author
Owner

@⁠rpatty-dev on GitHub · 2026-11-25 09:46 UTC · original

Thanks a lot for all the work in this. main has moved on a fair bit since you opened it so it now conflicts. Could you rebase it on the latest main when you get a chance? Happy to take another look then.

**@⁠rpatty-dev** on GitHub · 2026-11-25 09:46 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/53#issuecomment-7158778740) Thanks a lot for all the work in this. main has moved on a fair bit since you opened it so it now conflicts. Could you rebase it on the latest main when you get a chance? Happy to take another look then.
This pull request has changes conflicting with the target branch.
  • Cargo.lock
  • src/main.rs
  • src/world_gpu.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/53/head:github-bot/gh-53'
git switch 'github-bot/gh-53'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-53'
git switch 'github-bot/gh-53'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-53'
git switch 'github-bot/gh-53'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-53'
git switch 'main'
git merge --squash 'github-bot/gh-53'
git switch 'main'
git merge --ff-only 'github-bot/gh-53'
git switch 'main'
git merge 'github-bot/gh-53'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.