diff options
| author | Davide <davidec98@live.it> | 2026-11-22 18:25:54 +0100 |
|---|---|---|
| committer | Davide <davidec98@live.it> | 2026-11-22 18:49:29 +0100 |
| commit | e804d20ff55812dde8640526462f8eb596cd86ba (patch) | |
| tree | 9dbc3c352d7b42f7ea10b34d33f87559f261d261 /docs | |
| parent | e6ab90d6d4a7a56fdf8dc9215afb52fc868316e9 (diff) | |
tools/bvh_match.py: find the drawable geometry a dehydrated BLAS was built from
Reads the leaf signature (triangles per geometry index, a leaf that holds two primitives counting
as two), keeps every (drawable, model) of an `rpf9dump models` manifest whose per-geometry triangle
counts contain it as an ordered subsequence, and checks the survivors with
tools/bvh_geometry_check.py from the model's exported OBJ and the 3x4 at +0x50 of the instance
descriptor. The geometries of the two shaders the BVH leaves out are filtered with --skip-shaders
(those name hashes are game data, so the rule is off unless the user passes them); a drawable whose
shader indices the manifest cannot resolve keeps every geometry and the checks decide.
All the BVH logic stays in Python: the C# side is only the model decoding and the export.
Measured on the ten BLAS of the sample pack against one 1 GiB window of levels.rpf: 1,228 models
exported, 1 to 374 candidates per BLAS from the signature, and exactly one consistent candidate
for each of the ten. The tool prints no drawable names unless --names is given.
The two tools that came with #2205 and #2428 lacked the stdout errors="replace" guard every CLI
tool needs (tests/test_tool_stdout_encoding.py), so this also adds it there; without it that test
fails for both.
Tests are synthetic (tests/test_bvh_match.py, 14 cases): the right geometry is found and verified,
a wrong one, a wrong shader rule and a missing transform are not, geometries are matched inside one
model, and a manifest without per-geometry counts is an input error.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/bvh.md | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/bvh.md b/docs/bvh.md index 0c26f5721..0539c17e1 100644 --- a/docs/bvh.md +++ b/docs/bvh.md | |||
| @@ -328,6 +328,28 @@ python -I tools/bvh_geometry_check.py <dehydrated.bin> --geom <vertices.f32>[,<i | |||
| 328 | python -I tests/test_bvh_geometry_check.py | 328 | python -I tests/test_bvh_geometry_check.py |
| 329 | ``` | 329 | ``` |
| 330 | 330 | ||
| 331 | `tools/bvh_match.py` finds the drawable geometry a dehydrated BLAS was built from, on top of `rpf9dump`'s model | ||
| 332 | export rather than a second decoder. It reads the leaf signature (triangles per geometry index, a leaf that holds two | ||
| 333 | primitives counting as two), keeps every (drawable, model) of a `rpf9dump models` manifest whose per-geometry triangle | ||
| 334 | counts contain that signature as an ordered subsequence, and checks the survivors with | ||
| 335 | `tools/bvh_geometry_check.py` from the model's exported OBJ and the 3x4 at `+0x50` of the instance descriptor. The | ||
| 336 | geometries of the two shaders the BVH leaves out are filtered with `--skip-shaders`: those name hashes are game data, | ||
| 337 | as §4a says, so the rule is off unless the user passes them. A geometry whose shader index the manifest cannot resolve | ||
| 338 | keeps its place and the checks decide. Measured on the ten BLAS of the sample pack, against one 1 GiB window of | ||
| 339 | `levels.rpf`: 1,228 models exported, 1 to 374 candidates from the signature per BLAS, and exactly one consistent | ||
| 340 | candidate each. | ||
| 341 | |||
| 342 | `rpf9dump models` and `rpf9dump textures` take `--start`/`--length` to export a window of a file. A window need not be a | ||
| 343 | valid archive - a slice of `levels.rpf` cut at an offset has no `9FPR` header - because both modes read every resource | ||
| 344 | from its own compression blocks; a sub-range is never written to the index cache, which describes a whole file. | ||
| 345 | |||
| 346 | ```powershell | ||
| 347 | dotnet build tools/rpf9dump/rpf9dump.csproj -c Release | ||
| 348 | dotnet tools/rpf9dump/bin/Release/net8.0/rpf9dump.dll models <levels.rpf> <out> --start 3221225472 --length 1073741824 | ||
| 349 | python -I tools/bvh_match.py <dehydrated.bin> <out>/levels/models/manifest.json --descriptor <instance208.bin> [--skip-shaders H,H] | ||
| 350 | python -I tests/test_bvh_match.py | ||
| 351 | ``` | ||
| 352 | |||
| 331 | ## 7a. Building runtime BVHs: `tools/xdxr_bvh.py` | 353 | ## 7a. Building runtime BVHs: `tools/xdxr_bvh.py` |
| 332 | 354 | ||
| 333 | The Vulkan layer has to write acceleration structures in this runtime layout, because the game's traversal shaders | 355 | The Vulkan layer has to write acceleration structures in this runtime layout, because the game's traversal shaders |