Materials: decode the layered-material libraries (clothing and weapon colours) #107

Manually merged
github merged 1 commit from gh-pr/107/head into gh-pr/107/base 2026-11-26 20:10:20 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 02:49 UTC · original
holdmysocks:claude/material-library → master · +379 −5 · 6 files · 1 commits · merged 2026-11-24 02:56 UTC

What this adds

  • sixng-core::matlib: decoder for the layered-material libraries, the two PSO files of data.rpf with root struct 8419ab01. It reads the base-material map (42fa4d39 -> 6cc4c278) and the layered-preset map (fd540657 -> 756aef9c): per record the float, texture, colour and int parameter lists (name hash, index, sub-material, value) and a preset's 8 base-material names.
  • sixng materials [data] [--preset <hex>]... [-o <dir>]: builds <work>/index/material_presets.json (per preset the four entries of colour parameter f574261b for each of the 8 sub-materials, plus weapon component and variant name hash -> preset from the weapon family files of packs.rpf). --preset prints a preset in full with its base materials and the three gradient stops per colour; -o writes the whole libraries as JSON.
  • ped-variations: each item gets preset (its GarmentPreset, first along the parent chain), and each variation preset_colours (per drawable: preset and the 8 sub-material base colours) when the index exists.
  • matlib::stops: the three linear-RGB gradient stops the game derives from one colour (0.1 x value; the colour; saturation x 0.55 at value x 0.55 + 0.45).
  • README row and usage line.

What was checked

  • Counts on the game data: 7,994 base materials and 13,071 presets in the clothing file, 556 and 2,635 in the weapon file; 10 s for both.
  • Weapon links: 1,005 of 1,006 component presets and 1,299 of 1,300 variant presets resolve in the libraries.
  • Lead character's wardrobe resource: 1,292 of 2,393 listed items carry a preset, and all of those with a drawable get colours.
  • Colour byte order (red in the low byte) against the items' own colour tags, two wardrobe resources: of 85 items tagged blue, navy, brown, red, orange or yellow with a non-neutral preset colour, 83 agree and 2 do not.
  • The colour rule and the stop formula were read from the game's block builder (entry 0 blended towards entry 1 by a per-part byte, sRGB to linear, then the three stops).
  • cargo test -p sixng-core: 148 passed. Three new unit tests (preset to base fallback and index, stops, weapon links).

What is not decoded or not done

  • The export and the viewer do not apply these colours yet; this PR only provides the data.
  • Parameter names: all hashes. Only the colour parameter is interpreted.
  • Defaults of parameters a record leaves out (a run-time table in the game).
  • The source of the per-part byte that blends colour entry 0 towards entry 1; the index stores both.
  • What an item's Tint0..2 do when it has a preset.
  • The other two maps of the root (951cf6e3, 2d71e4f7).
  • Which of the tiling-texture indices (d2b598e5[0..4]) is the fabric greyscale.
  • Weapon component and variant keys are name hashes; they are not matched to drawable names here.
  • wardrobe::item_chain still also follows e13ebaf8 as a possible parent id, as before; left unchanged.
  • The GUI crate was not built locally.
**@⁠holdmysocks** on GitHub · 2026-11-24 02:49 UTC · [original](https://github.com/holdmysocks/SixNG/pull/107) `holdmysocks:claude/material-library` → `master` · +379 −5 · 6 files · 1 commits · merged 2026-11-24 02:56 UTC ## What this adds - `sixng-core::matlib`: decoder for the layered-material libraries, the two PSO files of data.rpf with root struct `8419ab01`. It reads the base-material map (`42fa4d39` -> `6cc4c278`) and the layered-preset map (`fd540657` -> `756aef9c`): per record the float, texture, colour and int parameter lists (name hash, index, sub-material, value) and a preset's 8 base-material names. - `sixng materials [data] [--preset <hex>]... [-o <dir>]`: builds `<work>/index/material_presets.json` (per preset the four entries of colour parameter `f574261b` for each of the 8 sub-materials, plus weapon component and variant name hash -> preset from the weapon family files of packs.rpf). `--preset` prints a preset in full with its base materials and the three gradient stops per colour; `-o` writes the whole libraries as JSON. - `ped-variations`: each item gets `preset` (its `GarmentPreset`, first along the parent chain), and each variation `preset_colours` (per drawable: preset and the 8 sub-material base colours) when the index exists. - `matlib::stops`: the three linear-RGB gradient stops the game derives from one colour (0.1 x value; the colour; saturation x 0.55 at value x 0.55 + 0.45). - README row and usage line. ## What was checked - Counts on the game data: 7,994 base materials and 13,071 presets in the clothing file, 556 and 2,635 in the weapon file; 10 s for both. - Weapon links: 1,005 of 1,006 component presets and 1,299 of 1,300 variant presets resolve in the libraries. - Lead character's wardrobe resource: 1,292 of 2,393 listed items carry a preset, and all of those with a drawable get colours. - Colour byte order (red in the low byte) against the items' own colour tags, two wardrobe resources: of 85 items tagged blue, navy, brown, red, orange or yellow with a non-neutral preset colour, 83 agree and 2 do not. - The colour rule and the stop formula were read from the game's block builder (entry 0 blended towards entry 1 by a per-part byte, sRGB to linear, then the three stops). - `cargo test -p sixng-core`: 148 passed. Three new unit tests (preset to base fallback and index, stops, weapon links). ## What is not decoded or not done - The export and the viewer do not apply these colours yet; this PR only provides the data. - Parameter names: all hashes. Only the colour parameter is interpreted. - Defaults of parameters a record leaves out (a run-time table in the game). - The source of the per-part byte that blends colour entry 0 towards entry 1; the index stores both. - What an item's `Tint0..2` do when it has a preset. - The other two maps of the root (`951cf6e3`, `2d71e4f7`). - Which of the tiling-texture indices (`d2b598e5[0..4]`) is the fabric greyscale. - Weapon component and variant keys are name hashes; they are not matched to drawable names here. - `wardrobe::item_chain` still also follows `e13ebaf8` as a possible parent id, as before; left unchanged. - The GUI crate was not built locally.
The clothing and weapon shaders bind no colour texture; a material's up to
8 sub-materials take their colour from a layered preset in two PSO files of
data.rpf (root struct 8419ab01). New module matlib and command
`sixng materials`: reads base materials and presets, writes
<work>/index/material_presets.json, prints presets in full with --preset.
ped-variations gives each item its preset (GarmentPreset) and, when the
index exists, the sub-material colours per drawable.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:10:18 +00:00
github manually merged commit 936b5c0e25 into gh-pr/107/base 2026-11-26 20:10:20 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.