Vehicles: metalness and palette position from the paint shader's reading #76

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

@⁠holdmysocks on GitHub · 2026-11-23 20:02 UTC · original
holdmysocks:claude/paint-shader → master · +99 −52 · 5 files · 1 commits · merged 2026-11-23 20:18 UTC

Replaces two guesses in the vehicle part colours with what the paint shader does.

Source

The G-buffer pixel shader of standard_vehicle_2lyr was read from its machine code in a separate piece of work outside this repository. No code from that work or from its tools is in this change.

Metalness

  • The shader blends a low / high pair of the part's surface by the red channel of lyr0materialatex, and the roughness pair by its green channel.
  • In the library the pair is 307f162c.f763652d / 09dd33c1, beside roughnessLow / roughnessHigh. It is 0 on plastics, rubber, leather and paint and 0.7 to 1.0 on chrome and bare metal (60 of 99 records are 0, 30 are 0.9 or more).
  • A part takes the middle of its pair. The earlier rule (a bright neutral palette row on a smooth surface) is gone.

Position along a palette row

  • The shader uses the green channel of lyr0diffusetex, a gradient-position map, plus a small detail term. It reads the palette only where the part's own colour is zero.
  • An export now uses the mean green of the layer detail textures the model binds, instead of the middle of the row.

Formats

  • COLOR_0 alpha on part-coloured materials: 254 = primary body paint, otherwise metalness in four steps x 50 + roughness in 50 steps.
  • vehicle_parts.json is format 8; exports are version 6, so the viewer exports vehicles again.
  • Fitted rims and tyres take their surface from the data instead of the stand-in.

Checked

  • hustler (chrome grille and bumper now metal), comet7, bison4 and buffalo6 in the viewer.
  • 140 core tests pass.

Not done

  • The position is one value per model, not per pixel, so grain and stitching in the detail texture do not show.
  • The palette is a 2D array in game; one slice is read.
  • Wear layers, dirt and liveries.
  • The shader reading has gaps (the non-skinned and LOD variants were not read; who fills the per-part buffers is not known), so the link from the library fields to the shader's bytes is by matching meaning and values.
**@⁠holdmysocks** on GitHub · 2026-11-23 20:02 UTC · [original](https://github.com/holdmysocks/SixNG/pull/76) `holdmysocks:claude/paint-shader` → `master` · +99 −52 · 5 files · 1 commits · merged 2026-11-23 20:18 UTC Replaces two guesses in the vehicle part colours with what the paint shader does. ## Source The G-buffer pixel shader of `standard_vehicle_2lyr` was read from its machine code in a separate piece of work outside this repository. No code from that work or from its tools is in this change. ## Metalness - The shader blends a low / high pair of the part's surface by the red channel of `lyr0materialatex`, and the roughness pair by its green channel. - In the library the pair is `307f162c.f763652d` / `09dd33c1`, beside `roughnessLow` / `roughnessHigh`. It is 0 on plastics, rubber, leather and paint and 0.7 to 1.0 on chrome and bare metal (60 of 99 records are 0, 30 are 0.9 or more). - A part takes the middle of its pair. The earlier rule (a bright neutral palette row on a smooth surface) is gone. ## Position along a palette row - The shader uses the green channel of `lyr0diffusetex`, a gradient-position map, plus a small detail term. It reads the palette only where the part's own colour is zero. - An export now uses the mean green of the layer detail textures the model binds, instead of the middle of the row. ## Formats - `COLOR_0` alpha on part-coloured materials: 254 = primary body paint, otherwise metalness in four steps x 50 + roughness in 50 steps. - `vehicle_parts.json` is format 8; exports are version 6, so the viewer exports vehicles again. - Fitted rims and tyres take their surface from the data instead of the stand-in. ## Checked - hustler (chrome grille and bumper now metal), comet7, bison4 and buffalo6 in the viewer. - 140 core tests pass. ## Not done - The position is one value per model, not per pixel, so grain and stitching in the detail texture do not show. - The palette is a 2D array in game; one slice is read. - Wear layers, dirt and liveries. - The shader reading has gaps (the non-skinned and LOD variants were not read; who fills the per-part buffers is not known), so the link from the library fields to the shader's bytes is by matching meaning and values.
The G-buffer pixel shader of standard_vehicle_2lyr was read from its
machine code (in a separate piece of work, outside this repository).
Two things it does were guesses here and are now taken from the data:

- Metalness. The shader blends a low / high pair of the part's surface
  by the red channel of lyr0materialatex (and the roughness pair by its
  green channel). In the library the pair is 307f162c.f763652d /
  09dd33c1, beside roughnessLow / roughnessHigh: 0 on plastics, rubber,
  leather and paint, 0.7 to 1.0 on chrome and bare metal (60 of 99
  records are 0, 30 are 0.9 or more). A part now takes the middle of
  its pair; the earlier rule (a bright neutral palette row on a smooth
  surface) is gone. vehicle_parts.json is format 8.
- Position along a palette row. The shader uses the green channel of
  lyr0diffusetex (a gradient-position map, not a colour) plus a small
  detail term, and reads the palette only where the part's own colour
  is zero. An export now uses the mean green of the layer detail
  textures the model binds instead of the middle of the row.

COLOR_0 alpha on part-coloured materials: 254 = primary body paint,
otherwise metalness in four steps x 50 + roughness in 50 steps. Exports
are version 6, so the viewer exports vehicles again. Fitted rims and
tyres take their surface from the data too instead of the stand-in.

Checked in the viewer on hustler (chrome grille and bumper now metal),
comet7, bison4 and buffalo6. 140 core tests pass.

Not done: the position is one value per model, not per pixel, so
grain and stitching in the detail texture do not show; the palette is
a 2D array in game and one slice is read; the wear layers, dirt and
liveries are not applied. The shader reading itself has gaps (the
non-skinned and LOD variants were not read, and who fills the per-part
buffers the shader reads is not known), so the link from the library
fields to the shader's bytes is by matching meaning and values.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:07:55 +00:00
github manually merged commit 04c827e4a3 into gh-pr/76/base 2026-11-26 20:07:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.