Vehicles: palette rows from their own slice, surface blend from the material map #85

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

@⁠holdmysocks on GitHub · 2026-11-23 22:20 UTC · original
holdmysocks:claude/palette-slices → master · +94 −46 · 2 files · 1 commits · merged 2026-11-23 22:31 UTC

Applies the shader session's vehicle paint findings (its write-up sections 3, 5, 6, 8) to the export, so the viewer shows them.

What

  • Palette slice. The palette in slot 19df25d7 is an array of 8 slices of 128 x 256. A colour record's page (adb52ec3, until now read as a "mode": 1 = paint, 3 = fixed material) is the slice its row (c8313558) belongs to. The export decodes all slices and reads a part's row from the slice of its page. Until now rows were read from slice 0, which holds different ramps (and runs dark to bright where slices 1, 2, 3, 5 run bright to dark).
  • Tint first. The shader reads the palette only where the part's tint is zero. So a part with a colour of its own shows that colour on any page (14 page-3 records have one), and a part without one reads its row on any page (290 page-1 records have a row and no colour; they came out black before).
  • Metalness and roughness. metalLow / metalHigh / roughnessLow / roughnessHigh of the surface's range record were already read; the blend between low and high is now the mean red / green of the model's lyr0materialatex textures instead of the midpoint.
  • part_colours_version 7, so the viewer exports vehicles again on first open.

Checked

  • Unit test covers: row read from the page's slice and not slice 0, tint wins over the row, a colourless page-1 part reads slice 1, the material map picks between low and high.
  • comet7's 39 distinct part looks: every page-3 row is a sensible material ramp in slice 3 (rubber and plastics 25 to 100 of 255, alloys 100 to 205).
  • Re-rendered comet7, buffalo6, sultan, bison, blista2 and ambulance and compared with the renders from before: dark plastics and rubber are a little lighter (a tyre is about 48/255 where it was 31/255), some trims and bumpers are brighter. Nothing went black or magenta. There is no in-game reference to say the new renders are closer; the reading of the data is what is confirmed.
  • cargo test -p sixng-core -p sixng-gui: 156 passed.

Not decoded / not done

  • One palette column per model (the mean green of lyr0diffusetex), not one per pixel, and the same value for the fitted wheels. With rows now running bright to dark this matters more than before.
  • A surface names two range records (2cc72f7c, 174770cc); which applies where is not known. The first is used.
  • The lyr0materialatex textures look like normal maps by their means (about 0.45, 0.55, 0.9), so the blend stays close to the midpoint; that it is the texture the shader blends by rests on the slot name.
  • Wear layers (a record's second and third picks, mostly page 5), albedoSelection / albedoPage (slices 0, 4, 5), and what the game writes into the near-black rows at run time.
  • The Metal renderer path is unchanged and untested.
**@⁠holdmysocks** on GitHub · 2026-11-23 22:20 UTC · [original](https://github.com/holdmysocks/SixNG/pull/85) `holdmysocks:claude/palette-slices` → `master` · +94 −46 · 2 files · 1 commits · merged 2026-11-23 22:31 UTC Applies the shader session's vehicle paint findings (its write-up sections 3, 5, 6, 8) to the export, so the viewer shows them. ## What - **Palette slice.** The palette in slot `19df25d7` is an array of 8 slices of 128 x 256. A colour record's page (`adb52ec3`, until now read as a "mode": 1 = paint, 3 = fixed material) is the slice its row (`c8313558`) belongs to. The export decodes all slices and reads a part's row from the slice of its page. Until now rows were read from slice 0, which holds different ramps (and runs dark to bright where slices 1, 2, 3, 5 run bright to dark). - **Tint first.** The shader reads the palette only where the part's tint is zero. So a part with a colour of its own shows that colour on any page (14 page-3 records have one), and a part without one reads its row on any page (290 page-1 records have a row and no colour; they came out black before). - **Metalness and roughness.** `metalLow` / `metalHigh` / `roughnessLow` / `roughnessHigh` of the surface's range record were already read; the blend between low and high is now the mean red / green of the model's `lyr0materialatex` textures instead of the midpoint. - `part_colours_version` 7, so the viewer exports vehicles again on first open. ## Checked - Unit test covers: row read from the page's slice and not slice 0, tint wins over the row, a colourless page-1 part reads slice 1, the material map picks between low and high. - comet7's 39 distinct part looks: every page-3 row is a sensible material ramp in slice 3 (rubber and plastics 25 to 100 of 255, alloys 100 to 205). - Re-rendered comet7, buffalo6, sultan, bison, blista2 and ambulance and compared with the renders from before: dark plastics and rubber are a little lighter (a tyre is about 48/255 where it was 31/255), some trims and bumpers are brighter. Nothing went black or magenta. There is no in-game reference to say the new renders are closer; the reading of the data is what is confirmed. - `cargo test -p sixng-core -p sixng-gui`: 156 passed. ## Not decoded / not done - One palette column per model (the mean green of `lyr0diffusetex`), not one per pixel, and the same value for the fitted wheels. With rows now running bright to dark this matters more than before. - A surface names two range records (`2cc72f7c`, `174770cc`); which applies where is not known. The first is used. - The `lyr0materialatex` textures look like normal maps by their means (about 0.45, 0.55, 0.9), so the blend stays close to the midpoint; that it is the texture the shader blends by rests on the slot name. - Wear layers (a record's second and third picks, mostly page 5), `albedoSelection` / `albedoPage` (slices 0, 4, 5), and what the game writes into the near-black rows at run time. - The Metal renderer path is unchanged and untested.
The vehicle palette is an array of 8 slices of 128 x 256; a colour
record's page (adb52ec3, read so far as a "mode") is the slice its row
(c8313558) belongs to. The export now decodes every slice and reads a
part's row from the slice of its page. A part with a colour of its own
shows that colour whatever its page (the shader reads the palette only
where the tint is zero), and a part without one reads its row on any
page, where before only "mode 3" rows were read, from slice 0.

Metalness and roughness sit between a surface's metalLow / metalHigh and
roughnessLow / roughnessHigh by the red and green of lyr0materialatex:
the export uses that texture's mean over the model instead of the
midpoint.

part_colours_version 7: the viewer exports older vehicles again.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:08:40 +00:00
github manually merged commit 83cd2126c4 into gh-pr/85/base 2026-11-26 20:08:41 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.