Commit Graph

7 Commits

Author SHA1 Message Date
a80bb68f75 calibrated_texture: crop NPOT mips to the DDS grid (CALIBRATED-TEXTURE-NPOT-DDS)
LocalDecoder.dds wrote every block of a mip's stored grid under a DDS
header. For NPOT chains the stored grid is wider or taller than the DDS
mip: 17x13 BC1 stores its 8x6 mip 1 as 3x2 blocks where DDS holds 2x2,
so the payload was 208 bytes instead of 192 and a DDS reader saw every
later mip shifted. ASSET-568 switched the compact branch to the stored
grid to get the offsets right but dropped the crop. The mode-1 array
branch kept the DDS grid instead, and addresses() takes its tile pitch
from that grid, so a 513x520 BC7 array read mip 1 rows 64 and on from the
wrong tile.

Read each mip on its stored grid (which also gives the tile pitch) and
keep only the DDS rows and columns, as ttpf_mips._visible_rows does for
the regular export. Both cases now give the same bytes as
ttpf_mips.texture_dds.

Tested: new test_dds_npot_mips_are_cropped_to_the_dds_grid (fails before
the fix in both cases, passes after).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 12:28:44 +01:00
f8650dc5aa calibrated_texture: atomic no-clobber export with MoveFileExW and cleanup (CALIBRATED-TEXTURE-NO-CLOBBER) 2026-11-24 14:03:59 +05:30
d3d031e402 calibrated_texture: use the measured compact layout for DDS mips (ASSET-568) (#6901)
Squash-merged after diff review of PR #6901 - ASSET-568: calibrated_texture DDS mips follow the measured compact layout
2026-11-23 09:48:12 -06:00
df8f2d27ce fix(tools): address calibrated texture arrays by source mip
Mode-1 arrays store tiles for every slice of a mip together. A fixed per-slice stride can read a different subresource into the DDS.
2026-11-22 18:02:17 +01:00
2d44fc8082 Tools: put the script's own directory on sys.path in the two that need it
`python -I` implies `-P`, so the directory of the script is not `sys.path[0]` and a tool that imports the module
next to it dies before `main()`:

    python -I tools/calibrated_texture.py --help
    ModuleNotFoundError: No module named 'bcpack'

`calibrated_texture.py` imports `bcpack`, `bcpack_tables` and `ttpf_mips` and added nothing; `ttpf_assets.py`
imports `bcpack`, `file_mode`, `ttpf_mips` and `calibrated_texture` and added nothing either, so the build's
texture stage tools could only be run through `make_game.py`, never directly as CONTRIBUTING.md documents.

Insert `os.path.dirname(os.path.abspath(__file__))` before the sibling imports, the pattern already used by
`tools/anim_clips.py`. `tests/test_tool_startup.py` derives the affected set from the sources and runs
`python -I <tool> --help` for all of them, so a new tool with a sibling import is covered without editing the
test; without the two fixes it fails exactly on those two tools.

A sweep of `python -I tools/*.py --help` over all 110 tools found no other case.
2026-11-22 16:38:03 +02:00
23fe0a0c3a Complete BCPack DDS entries during the normal assets export 2026-11-22 16:04:49 +08:00
0a288c3cd0 textures: support locally calibrated BCPack DDS exports 2026-11-22 15:33:40 +08:00