Vehicles: part colours per pixel from the material palette #137

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

@⁠holdmysocks on GitHub · 2026-11-24 11:58 UTC · original
holdmysocks:claude/palette-per-pixel → master · +127 −8 · 9 files · 1 commits · merged 2026-11-24 12:07 UTC

What

A vehicle part without a colour of its own reads a row of the material palette. Until now the whole part got one colour: the row at the mean green of the model's layer detail textures. The game picks the column per pixel from the green channel of the material's layer detail texture (lyr0diffusetex). The viewer now does the same.

  • Export: writes the material palette beside the model as vehicle_palette.png (128 columns, its 8 slices one below the other, 256 rows each). model.json part_colours gets rows (per look, the palette row of each part id: 256 x 4 hex digits, ffff = the part has a colour of its own) and palette. Part colours version 19, so the viewer exports vehicle models again once.
  • Viewer: a part material loads its layer detail texture. For the look shown, the viewer builds an image with one row per part id (the palette row, or the part's own colour) and the shader reads it at the detail texture's green. COLOR_0 and looks are unchanged, so other readers of the export see what they saw before.
  • No new texture binding: part materials have no fabric tile and no emissive map, so the column map goes in the tile slot and the rows in the emissive slot (tile.w = 2 marks it).

Measured

  • The palette is the same image in the three vehicles compared (ambulance, benson, comet7).
  • 141 rows are in use by the part sets. In 140 of them the colour changes by more than 48 of 255 along the row (median 97).
  • The layer detail texture checked has green 120 on average, spread 12, range 8 to 197.

Checked

  • Renders of 16 trucks and pickups against the renders from before the change, same camera. The mule's wooden flatbed deck now shows grain along its planks (1,385 pixels differ by more than 12 of 255). The tow truck and iota change in a few hundred pixels. The rebel is the same within 11 of 255. Nothing changed colour as a whole.
  • cargo test -p sixng-core vehcolour passes.

Not decoded / not done

  • The effect is small at a normal viewing distance: on most parts the column moves only a little around the mean.
  • That the detail texture is sampled on the first UV set without a tiling factor is taken from the result (the grain follows the planks), not from the shader.
  • Vehicles without configurations have no rows and keep one colour per part. Wheels keep one colour per part.
  • The blue channel of the same texture looks like an edge wear mask. It is not used.
  • The Metal renderer is unchanged.
**@⁠holdmysocks** on GitHub · 2026-11-24 11:58 UTC · [original](https://github.com/holdmysocks/SixNG/pull/137) `holdmysocks:claude/palette-per-pixel` → `master` · +127 −8 · 9 files · 1 commits · merged 2026-11-24 12:07 UTC ## What A vehicle part without a colour of its own reads a row of the material palette. Until now the whole part got one colour: the row at the mean green of the model's layer detail textures. The game picks the column per pixel from the green channel of the material's layer detail texture (`lyr0diffusetex`). The viewer now does the same. - Export: writes the material palette beside the model as `vehicle_palette.png` (128 columns, its 8 slices one below the other, 256 rows each). `model.json` `part_colours` gets `rows` (per look, the palette row of each part id: 256 x 4 hex digits, `ffff` = the part has a colour of its own) and `palette`. Part colours version 19, so the viewer exports vehicle models again once. - Viewer: a part material loads its layer detail texture. For the look shown, the viewer builds an image with one row per part id (the palette row, or the part's own colour) and the shader reads it at the detail texture's green. COLOR_0 and `looks` are unchanged, so other readers of the export see what they saw before. - No new texture binding: part materials have no fabric tile and no emissive map, so the column map goes in the tile slot and the rows in the emissive slot (`tile.w` = 2 marks it). ## Measured - The palette is the same image in the three vehicles compared (ambulance, benson, comet7). - 141 rows are in use by the part sets. In 140 of them the colour changes by more than 48 of 255 along the row (median 97). - The layer detail texture checked has green 120 on average, spread 12, range 8 to 197. ## Checked - Renders of 16 trucks and pickups against the renders from before the change, same camera. The mule's wooden flatbed deck now shows grain along its planks (1,385 pixels differ by more than 12 of 255). The tow truck and iota change in a few hundred pixels. The rebel is the same within 11 of 255. Nothing changed colour as a whole. - `cargo test -p sixng-core vehcolour` passes. ## Not decoded / not done - The effect is small at a normal viewing distance: on most parts the column moves only a little around the mean. - That the detail texture is sampled on the first UV set without a tiling factor is taken from the result (the grain follows the planks), not from the shader. - Vehicles without configurations have no `rows` and keep one colour per part. Wheels keep one colour per part. - The blue channel of the same texture looks like an edge wear mask. It is not used. - The Metal renderer is unchanged.
A part without a colour of its own reads a row of the material palette at the column the green channel of the layer detail texture gives per pixel. The export writes the palette (vehicle_palette.png) and the palette row of each part id per look (part_colours.rows, version 19); the viewer builds an image with one row per part id for the look shown and reads it per pixel. COLOR_0 and looks keep the row at the texture's mean green.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:12:36 +00:00
github manually merged commit 50d41ea6ad into gh-pr/137/base 2026-11-26 20:12:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.