diff options
| author | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 20:39:59 -0700 |
|---|---|---|
| committer | Nolan Cotter <186326284+NolanCotter@users.noreply.github.com> | 2026-11-22 20:39:59 -0700 |
| commit | fa5f26db8eafd2cc27f627b68c0a5a5949bcf2ff (patch) | |
| tree | fc57e238be829295fc216dff89a6d93e64c16b50 /docs/models.md | |
| parent | 9b693ecd8a2f90799f6c47f8f06cf062feb9820c (diff) | |
| parent | 7b7d73f890f9fbbf5967bbb694390bbc99e33ba6 (diff) | |
Merge origin/main: DXGI device fields coexist with the console-ABI device state
Diffstat (limited to 'docs/models.md')
| -rw-r--r-- | docs/models.md | 120 |
1 files changed, 106 insertions, 14 deletions
diff --git a/docs/models.md b/docs/models.md index 793ac5b0b..bebdfecd6 100644 --- a/docs/models.md +++ b/docs/models.md | |||
| @@ -443,9 +443,22 @@ records. No unhandled layout tag appears: | |||
| 443 | - **Sentinels.** On each surface, 11 entries have every estimate 0 and 10 more have zero speeds with an | 443 | - **Sentinels.** On each surface, 11 entries have every estimate 0 and 10 more have zero speeds with an |
| 444 | infinite time (`inf`). `inf` occurs in 38 road and 99 offroad blocks overall, so a parser must accept `inf` | 444 | infinite time (`inf`). `inf` occurs in 38 road and 99 offroad blocks overall, so a parser must accept `inf` |
| 445 | in these fields (it reads as "never reaches the test speed or distance"). | 445 | in these fields (it reads as "never reaches the test speed or distance"). |
| 446 | 446 | - **`fOverallRating` is a weighted mean of the other four ratings** (measured, confirmed to float noise). Over the | |
| 447 | Not measured here (hypothesis): the rating scale and how `fOverallRating` weights its parts, and whether the | 447 | 504 rating blocks, `fOverallRating` = 0.21 `fSpeedRating` + 0.38 `fHandlingRating` + 0.40 |
| 448 | estimates are precomputed from handling data or measured by simulation. | 448 | `fAccelerationRating` + 0.01 `fBrakesRating`: the four weights sum to 1, so handling and acceleration weigh |
| 449 | about twice speed and brakes is 1%. The residual is at most 7e-5 on the 345 rating blocks whose four parts are | ||
| 450 | all above 10, and differencing a key's road and offroad blocks gives the same 0.2100 / 0.3800 / 0.4000 / | ||
| 451 | 0.0100 on the 139 keys that are above 10 on both surfaces, so the weights do not depend on the surface. | ||
| 452 | - **The same 10 floor is on the overall** (likely). 24 blocks whose four parts run 10.0 to 11.97 carry an | ||
| 453 | `fOverallRating` of exactly 10; and the other 159 rating blocks, which have at least one part at exactly 10, | ||
| 454 | sit up to 4.1 below the weighted mean, as parts raised to 10 from a lower value would, while no block without | ||
| 455 | a part at 10 deviates. | ||
| 456 | - **Scale.** The ratings are continuous floats, not a 0-1 or 0-100 score: 342 to 451 distinct values per field | ||
| 457 | over the 504 blocks, a floor of exactly 10, and `fAccelerationRating` the only field past 1,000 (22 blocks, | ||
| 458 | maximum 1,327). | ||
| 459 | |||
| 460 | Not measured here (hypothesis): whether the estimates are precomputed from handling data or measured by | ||
| 461 | simulation, and what fixes the top of the rating scale. | ||
| 449 | 462 | ||
| 450 | ## Character skeletons | 463 | ## Character skeletons |
| 451 | 464 | ||
| @@ -521,18 +534,90 @@ file names), so the effect is recoverable from them. Measured on a 1.0.2.1 copy, | |||
| 521 | | Materials whose hash is the joaat of a carved effect name | 3,211 (96%), 8 of the 18 hashes | | 534 | | Materials whose hash is the joaat of a carved effect name | 3,211 (96%), 8 of the 18 hashes | |
| 522 | | Materials whose hash is the joaat of a native effect record's name (both SGD5 databases, below) | 3,340 (100%), 18 of the 18 hashes, one record each | | 535 | | Materials whose hash is the joaat of a native effect record's name (both SGD5 databases, below) | 3,340 (100%), 18 of the 18 hashes, one record each | |
| 523 | 536 | ||
| 524 | So a material leads to its effect and that effect's ray-tracing resolve programs. It does **not** lead to the | 537 | So a material leads to its effect. Through the carved compute names it reaches only 8 of the 18 hashes; the |
| 525 | draw (VS/PS/MS) programs from the package alone: | 538 | effect records' own names reach all 18 (@jeremygold02, `tools/sgd5_effects.py` in #3036). The draw (VS/PS/MS) |
| 539 | programs are not reachable through the carved programs' names, order or suffixes: | ||
| 526 | 540 | ||
| 527 | - None of the 23,619 graphics programs (VS/PS/MS) carries an effect name; they are named `<stage>_<technique or entry>_<8 hex>`. | 541 | - None of the 23,619 graphics programs (2,236 VS, 12,101 PS, 9,282 MS; the 195 GS are left out here) carries an |
| 542 | effect name; they are named `<stage>_<technique or entry>_<8 hex>`. | ||
| 528 | - `shaders.rpf` stores programs grouped by kind, not by effect (the 1,004 `RaytracingResolve` programs sit next | 543 | - `shaders.rpf` stores programs grouped by kind, not by effect (the 1,004 `RaytracingResolve` programs sit next |
| 529 | to each other), so position doesn't group an effect's programs either. | 544 | to each other), so position doesn't group an effect's programs either. |
| 530 | - The graphics programs' 8-hex suffix groups them (1,226 suffixes over 23,016 programs, the largest shared by | 545 | - Every one of the 23,619 has an 8-hex suffix. The suffixes group them: there are 1,228 distinct ones, the largest |
| 531 | 1,775) but is not the joaat of the program name, and only 1 of the 896 suffixes on the effect-named CS programs | 546 | shared by 1,806 programs and 53 used once. The suffix is not the joaat of the program name, and only 1 of the |
| 532 | appears on any graphics program. | 547 | 896 suffixes on the effect-named CS programs appears on any graphics program. |
| 548 | |||
| 549 | They are reachable through the **effect records** in `shaders.rpf` (found by @jeremygold02, #2519). All fields | ||
| 550 | are little-endian: | ||
| 551 | |||
| 552 | 1. **The effect record.** It starts with a one-byte name length and the name, including its terminator, then a | ||
| 553 | u32 (below). Six stage lists follow, each a u32 count and that many u32 ordinals. | ||
| 554 | |||
| 555 | The u32 is a size computed from the record's own counted fields (@jeremygold02). Let G be the ordinals in the | ||
| 556 | six lists, T the techniques, P the passes, and W the post-pass word count. Let A and B be the two block | ||
| 557 | lengths after them, E the post-pass entry count, I the payload bytes of the entries whose tag is a length | ||
| 558 | (not `0x80000000`), and S the string-pool length. Lengths don't count their own prefixes. Then, with | ||
| 559 | `x = 4W + A + B`: | ||
| 560 | |||
| 561 | ```text | ||
| 562 | word = 48 + 8(G + T + E) + 32P + I + S + (round_up(x, 8) if E else x) | ||
| 563 | ``` | ||
| 564 | |||
| 565 | This holds for all 932 records of this build (910 + 22, recomputed here). The value never equals the record's | ||
| 566 | serialized length (0 of 932), so the next record is found by the sequential walk, not by this word. What the | ||
| 567 | runtime uses it for is unknown. Groups 3 and 4 are empty here, so their share of it is unmeasured. | ||
| 568 | |||
| 569 | `shaders.rpf` holds **two shader databases** (SGD5), and an ordinal counts within one of them (found by | ||
| 570 | @jeremygold02). Each database stores six program groups, each a u32 count followed by its programs. A program | ||
| 571 | is a u8-length label including its NUL, one tag byte, a u32-length payload, 152 fixed bytes and a u32-length | ||
| 572 | trailer. The u32 after group 5 is the database's effect count. An ordinal is the zero-based position in the | ||
| 573 | group of the effect's own database, so a lookup needs the database, the group and the ordinal. | ||
| 574 | |||
| 575 | | Database (group walk starts at) | 0: VS + MS | 1: PS | 2: GS | 3 | 4 | 5: CS | Effects declared | | ||
| 576 | |---|---:|---:|---:|---:|---:|---:|---:| | ||
| 577 | | `0x10E39` | 11,018 | 10,944 | 195 | 0 | 0 | 2,647 | 910 | | ||
| 578 | | `0x10289C81` | 500 | 1,157 | 0 | 0 | 0 | 42 | 22 | | ||
| 579 | |||
| 580 | The two databases add up to the whole carve: 11,518 VS + MS, 12,101 PS, 195 GS and 2,689 CS. Groups 3 and 4 are | ||
| 581 | empty and their stages are not identified. The first database's programs come first in the archive, so for its | ||
| 582 | effects the ordinal also equals the program's position among the carve index's programs of that group, sorted | ||
| 583 | by `offset`. The three records here are all in the first database: the wiper's 11017 is the last entry of its | ||
| 584 | group 0. | ||
| 533 | 585 | ||
| 534 | The effect → technique → VS/PS table is therefore not in the carved programs' names, order or suffixes; it is | 586 | On the rim and the tire, list 5's three entries are exactly the effect's own `<effect>:RaytracingResolve` |
| 535 | presumably in the executable (RT-5). Until then, a real model is drawn with a chosen pair ([first_light.md](first_light.md)). | 587 | programs, the ones the material hash leads to in the table above. In the second database all 42 group-5 |
| 588 | references resolve to programs that carry their effect's name; resolved against the archive-wide CS list | ||
| 589 | instead, none of them do (@jeremygold02). | ||
| 590 | 2. **The technique table.** A u32 count, then one 4-byte entry per technique: the low 15 bits of its first u16 are | ||
| 591 | the name's offset in a string block, and byte 3 is the pass count. A u32 pass total follows, then 24-byte pass | ||
| 592 | records. Where the table and its string block sit relative to the record is not derived yet: the three | ||
| 593 | tables were located by offset. | ||
| 594 | 3. **The pass records.** The first six bytes of each pass select an entry of each stage list: 0 is unused, | ||
| 595 | otherwise `stage_list[selector - 1]`. | ||
| 596 | |||
| 597 | The group walk and its counts above were reproduced on a 1.0.2.1 copy (the same `shaders.rpf`, SHA-256 | ||
| 598 | `0bc16345…`). So was @jeremygold02's census of both databases' effects with `tools/sgd5_effects.py | ||
| 599 | --list-effects` (#3036, `0029eba7`): 932 effect records with 932 distinct name hashes, 913 of them with a | ||
| 600 | technique table, 25,037 techniques and 28,798 passes. Since `c0439966` the tool also **walks** the records | ||
| 601 | forward from each database's effect count, using only stored lengths: every record's string pool, the next | ||
| 602 | record, and at the end the terminal word and zero padding. Its tests, run against this package | ||
| 603 | (`LEONIDA_GAME_DIR` set, `tests/test_sgd5_effects.py`), pass: the walk and the earlier search agree on every | ||
| 604 | record, technique and pass. The record and pass format below was also checked by hand on three records: | ||
| 605 | |||
| 606 | | Record | Stage list sizes | Techniques | Passes (total = sum of counts) | First pass list 0 / list 1 ordinal | | ||
| 607 | |---|---|---:|---:|---| | ||
| 608 | | windshield wiper mask | 1, 1, 0, 0, 0, 0 | 1 | 1 | 11017 / 10943 | | ||
| 609 | | stock rim | 41, 53, 0, 0, 0, 3 | 106 | 108 | 9143 / 8925 | | ||
| 610 | | stock tire | 41, 53, 0, 0, 0, 3 | 106 | 108 | 9089 / 8835 | | ||
| 611 | |||
| 612 | Two things are still open: | ||
| 613 | |||
| 614 | - **The u32 after an effect's name.** It is reproduced from the record's fields; how the runtime uses it is | ||
| 615 | still unknown. | ||
| 616 | - **Which technique and pass the game draws with.** That is a run-time choice; it is presumably made in the | ||
| 617 | executable (RT-5). | ||
| 618 | |||
| 619 | Until both are settled, a real model is drawn with a chosen pair ([first_light.md](first_light.md)). The effect | ||
| 620 | records already give that choice a pair that can be checked independently. | ||
| 536 | 621 | ||
| 537 | So a material leads to its effect. Through the carved compute names it reaches only 8 of the 18 hashes; the | 622 | So a material leads to its effect. Through the carved compute names it reaches only 8 of the 18 hashes; the |
| 538 | effect records' own names reach all 18 (@jeremygold02, `tools/sgd5_effects.py` in #3036). The draw (VS/PS/MS) | 623 | effect records' own names reach all 18 (@jeremygold02, `tools/sgd5_effects.py` in #3036). The draw (VS/PS/MS) |
| @@ -628,9 +713,16 @@ vehicle models to far-away light recipes. Counts only; no model names. | |||
| 628 | this build the document is an index from model and variant to recipe with the light positions absent, | 713 | this build the document is an index from model and variant to recipe with the light positions absent, |
| 629 | so distant vehicle lights cannot be reconstructed from it. | 714 | so distant vehicle lights cannot be reconstructed from it. |
| 630 | 715 | ||
| 631 | Not measured here (hypothesis): what the secondary tokens name (per-model parts or liveries would fit the | 716 | The sampled `CPaletteIndexedRecipeTintsArray` document reuses 746 of the 780 distinct distant-light |
| 632 | model-name substrings), and where the light positions are generated at runtime (for example from the model's | 717 | secondary tokens in its own `secondaryRecipes` field. Of the 1,668 distant-light rows with at least one |
| 633 | own light bones). | 718 | token, 1,339 match a palette recipe on both vehicle name and the complete token list, ignoring case and |
| 719 | token order. Replacing each vehicle name with the next of the 319 lowercased names in sorted order | ||
| 720 | (wrapping at the end) and keeping its tokens fixed gives 56 matches among the same 1,668 rows. | ||
| 721 | |||
| 722 | In the 34-row `CVehicleBoneOffsetsArray` document, 0 of the 780 distinct tokens match a whole text or | ||
| 723 | attribute value case-insensitively. In the 2,447-row document of the same type, 178 of the 780 match | ||
| 724 | `boneOffsets/Item/name`. These comparisons establish recipe reuse across the light and palette documents. | ||
| 725 | Which physical parts or liveries a token selects, and where the runtime obtains light positions, remain open. | ||
| 634 | 726 | ||
| 635 | ## Skinned GLB export | 727 | ## Skinned GLB export |
| 636 | 728 | ||