diff options
| author | Aslan2142 <jan.trencansky@protonmail.com> | 2026-12-01 16:13:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-12-01 16:13:46 +0100 |
| commit | 2ad32c8fc8ead2b942fa8ee24c9c9ec93f355244 (patch) | |
| tree | c98fcf7ece44e2246bc738729af0a3220733de9c /docs/models.md | |
| parent | 67176dd52609e9a6eaecd2adb2c423a09789c76f (diff) | |
| parent | 12e612449ed1616ab2249eae3a8d0404a58d9edb (diff) | |
Merge pull request #250 from ProjectLeonida/old-pr/9984
docs(models): remove duplicate material effect section (lines 653-737)
Diffstat (limited to 'docs/models.md')
| -rw-r--r-- | docs/models.md | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/docs/models.md b/docs/models.md index ba1cd5433..aa0bbe0d3 100644 --- a/docs/models.md +++ b/docs/models.md | |||
| @@ -650,91 +650,6 @@ Two things are still open: | |||
| 650 | Until both are settled, a real model is drawn with a chosen pair ([first_light.md](first_light.md)). The effect | 650 | Until both are settled, a real model is drawn with a chosen pair ([first_light.md](first_light.md)). The effect |
| 651 | records already give that choice a pair that can be checked independently. | 651 | records already give that choice a pair that can be checked independently. |
| 652 | 652 | ||
| 653 | So a material leads to its effect. Through the carved compute names it reaches only 8 of the 18 hashes; the | ||
| 654 | effect records' own names reach all 18 (@jeremygold02, `tools/sgd5_effects.py` in #3036). The draw (VS/PS/MS) | ||
| 655 | programs are not reachable through the carved programs' names, order or suffixes: | ||
| 656 | |||
| 657 | - 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 | ||
| 658 | effect name; they are named `<stage>_<technique or entry>_<8 hex>`. | ||
| 659 | - `shaders.rpf` stores programs grouped by kind, not by effect (the 1,004 `RaytracingResolve` programs sit next | ||
| 660 | to each other), so position doesn't group an effect's programs either. | ||
| 661 | - Every one of the 23,619 has an 8-hex suffix. The suffixes group them: there are 1,228 distinct ones, the largest | ||
| 662 | shared by 1,806 programs and 53 used once. The suffix is not the joaat of the program name, and only 1 of the | ||
| 663 | 896 suffixes on the effect-named CS programs appears on any graphics program. | ||
| 664 | |||
| 665 | They are reachable through the **effect records** in `shaders.rpf` (found by @jeremygold02, #2519). All fields | ||
| 666 | are little-endian: | ||
| 667 | |||
| 668 | 1. **The effect record.** It starts with a one-byte name length and the name, including its terminator, then a | ||
| 669 | u32 (below). Six stage lists follow, each a u32 count and that many u32 ordinals. | ||
| 670 | |||
| 671 | The u32 is a size computed from the record's own counted fields (@jeremygold02). Let G be the ordinals in the | ||
| 672 | six lists, T the techniques, P the passes, and W the post-pass word count. Let A and B be the two block | ||
| 673 | lengths after them, E the post-pass entry count, I the payload bytes of the entries whose tag is a length | ||
| 674 | (not `0x80000000`), and S the string-pool length. Lengths don't count their own prefixes. Then, with | ||
| 675 | `x = 4W + A + B`: | ||
| 676 | |||
| 677 | ```text | ||
| 678 | word = 48 + 8(G + T + E) + 32P + I + S + (round_up(x, 8) if E else x) | ||
| 679 | ``` | ||
| 680 | |||
| 681 | This holds for all 932 records of this build (910 + 22, recomputed here). The value never equals the record's | ||
| 682 | serialized length (0 of 932), so the next record is found by the sequential walk, not by this word. What the | ||
| 683 | runtime uses it for is unknown. Groups 3 and 4 are empty here, so their share of it is unmeasured. | ||
| 684 | |||
| 685 | `shaders.rpf` holds **two shader databases** (SGD5), and an ordinal counts within one of them (found by | ||
| 686 | @jeremygold02). Each database stores six program groups, each a u32 count followed by its programs. A program | ||
| 687 | is a u8-length label including its NUL, one tag byte, a u32-length payload, 152 fixed bytes and a u32-length | ||
| 688 | trailer. The u32 after group 5 is the database's effect count. An ordinal is the zero-based position in the | ||
| 689 | group of the effect's own database, so a lookup needs the database, the group and the ordinal. | ||
| 690 | |||
| 691 | | Database (group walk starts at) | 0: VS + MS | 1: PS | 2: GS | 3 | 4 | 5: CS | Effects declared | | ||
| 692 | |---|---:|---:|---:|---:|---:|---:|---:| | ||
| 693 | | `0x10E39` | 11,018 | 10,944 | 195 | 0 | 0 | 2,647 | 910 | | ||
| 694 | | `0x10289C81` | 500 | 1,157 | 0 | 0 | 0 | 42 | 22 | | ||
| 695 | |||
| 696 | 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 | ||
| 697 | empty and their stages are not identified. The first database's programs come first in the archive, so for its | ||
| 698 | effects the ordinal also equals the program's position among the carve index's programs of that group, sorted | ||
| 699 | by `offset`. The three records here are all in the first database: the wiper's 11017 is the last entry of its | ||
| 700 | group 0. | ||
| 701 | |||
| 702 | On the rim and the tire, list 5's three entries are exactly the effect's own `<effect>:RaytracingResolve` | ||
| 703 | programs, the ones the material hash leads to in the table above. In the second database all 42 group-5 | ||
| 704 | references resolve to programs that carry their effect's name; resolved against the archive-wide CS list | ||
| 705 | instead, none of them do (@jeremygold02). | ||
| 706 | 2. **The technique table.** A u32 count, then one 4-byte entry per technique: the low 15 bits of its first u16 are | ||
| 707 | the name's offset in a string block, and byte 3 is the pass count. A u32 pass total follows, then 24-byte pass | ||
| 708 | records. Where the table and its string block sit relative to the record is not derived yet: the three | ||
| 709 | tables were located by offset. | ||
| 710 | 3. **The pass records.** The first six bytes of each pass select an entry of each stage list: 0 is unused, | ||
| 711 | otherwise `stage_list[selector - 1]`. | ||
| 712 | |||
| 713 | The group walk and its counts above were reproduced on a 1.0.2.1 copy (the same `shaders.rpf`, SHA-256 | ||
| 714 | `0bc16345…`). So was @jeremygold02's census of both databases' effects with `tools/sgd5_effects.py | ||
| 715 | --list-effects` (#3036, `0029eba7`): 932 effect records with 932 distinct name hashes, 913 of them with a | ||
| 716 | technique table, 25,037 techniques and 28,798 passes. Since `c0439966` the tool also **walks** the records | ||
| 717 | forward from each database's effect count, using only stored lengths: every record's string pool, the next | ||
| 718 | record, and at the end the terminal word and zero padding. Its tests, run against this package | ||
| 719 | (`LEONIDA_GAME_DIR` set, `tests/test_sgd5_effects.py`), pass: the walk and the earlier search agree on every | ||
| 720 | record, technique and pass. The record and pass format below was also checked by hand on three records: | ||
| 721 | |||
| 722 | | Record | Stage list sizes | Techniques | Passes (total = sum of counts) | First pass list 0 / list 1 ordinal | | ||
| 723 | |---|---|---:|---:|---| | ||
| 724 | | windshield wiper mask | 1, 1, 0, 0, 0, 0 | 1 | 1 | 11017 / 10943 | | ||
| 725 | | stock rim | 41, 53, 0, 0, 0, 3 | 106 | 108 | 9143 / 8925 | | ||
| 726 | | stock tire | 41, 53, 0, 0, 0, 3 | 106 | 108 | 9089 / 8835 | | ||
| 727 | |||
| 728 | Two things are still open: | ||
| 729 | |||
| 730 | - **The u32 after an effect's name.** It is reproduced from the record's fields; how the runtime uses it is | ||
| 731 | still unknown. | ||
| 732 | - **Which technique and pass the game draws with.** That is a run-time choice; it is presumably made in the | ||
| 733 | executable (RT-5). | ||
| 734 | |||
| 735 | Until both are settled, a real model is drawn with a chosen pair ([first_light.md](first_light.md)). The effect | ||
| 736 | records already give that choice a pair that can be checked independently. | ||
| 737 | |||
| 738 | ## Vehicle distant-light recipes | 653 | ## Vehicle distant-light recipes |
| 739 | 654 | ||
| 740 | `common.rpf` has one `CVehicleDistantLightData` XML document (see [gamedata.md](gamedata.md)) that ties | 655 | `common.rpf` has one `CVehicleDistantLightData` XML document (see [gamedata.md](gamedata.md)) that ties |