Vehicles: part colours from the part sets and the material palette #59

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

@⁠holdmysocks on GitHub · 2026-11-23 17:12 UTC · original
holdmysocks:claude/vehicle-colours → master · +438 −12 · 12 files · 1 commits · merged 2026-11-23 17:20 UTC

Interiors, trim and mechanical parts of vehicles were drawn with a grey stand-in. This reads the game's per-part colours and writes them into the export and the viewer.

What is read

  • Each vertex of the two-layer vehicle materials carries a part id (0-255) in its vertex colour alpha.
  • A part set (f14244fd, its own 0x7a resource in packs.rpf; 338 found) names a colour record and a surface record for each of the 256 ids. 319 vehicle models link to a set through a 64-bit name in their variation sets and one mod element.
  • A library resource in data.rpf holds the records: colour records f1379639 (colour, mode, palette row) and surface records 9e4de959 (roughness range through 307f162c).
  • The material palette texture (slot 19df25d7, 128 x 256, the same on every vehicle) is real data: each row is one material's ramp from dark to bright. Paint rows are black in the file and filled by the game.

Colour byte order

Colours of type 0x15 have red in the low byte. The library's 151 named colours begin with GTA IV's car colour list only when read that way. Configuration body colours and paint lists were read with red and blue swapped; vehicles.json now writes real ARGB plus the stored value (format 4).

Changes

  • New module vehcolour (sets, library, links; cached in <work>/index/vehicle_parts.json).
  • Export: GLB COLOR_0 holds each vertex's colour on a white base; classification.stand_in is parts on those materials. COLOR_0 alpha 254 marks the primary body paint, 0-100 is roughness x 100, 101-201 the same on parts taken as metal.
  • Viewer: the primary paint follows the Car paint colour; parts take their roughness; older cached vehicle exports are exported again.

Checked

  • In the viewer on comet7, buffalo6, ambulance and bison4: seats, dash, carpet, bumpers, body and roof.
  • 137 core tests pass (two new).

Not decoded

  • What picks the column of a palette row (the middle is used).
  • The modifier records a configuration lists (0caef606 in the library, with part id groups 6225734f, channel bindings 501ff112, colour and surface assignments b94308f5). Interior and trim choices per configuration are not applied; every vehicle shows its default table.
  • Metalness. A bright neutral row on a smooth surface is taken as metal, which is an inference.
  • The second layer's colour, colour record modes 4 and 5, rim, tyre and weapon colours.
  • The Metal renderer shows the colours without the paint swap or per-part roughness.
  • No motorcycle or boat was checked.
**@⁠holdmysocks** on GitHub · 2026-11-23 17:12 UTC · [original](https://github.com/holdmysocks/SixNG/pull/59) `holdmysocks:claude/vehicle-colours` → `master` · +438 −12 · 12 files · 1 commits · merged 2026-11-23 17:20 UTC Interiors, trim and mechanical parts of vehicles were drawn with a grey stand-in. This reads the game's per-part colours and writes them into the export and the viewer. ## What is read - Each vertex of the two-layer vehicle materials carries a part id (0-255) in its vertex colour alpha. - A part set (`f14244fd`, its own `0x7a` resource in `packs.rpf`; 338 found) names a colour record and a surface record for each of the 256 ids. 319 vehicle models link to a set through a 64-bit name in their variation sets and one mod element. - A library resource in `data.rpf` holds the records: colour records `f1379639` (colour, mode, palette row) and surface records `9e4de959` (roughness range through `307f162c`). - The material palette texture (slot `19df25d7`, 128 x 256, the same on every vehicle) is real data: each row is one material's ramp from dark to bright. Paint rows are black in the file and filled by the game. ## Colour byte order Colours of type `0x15` have red in the low byte. The library's 151 named colours begin with GTA IV's car colour list only when read that way. Configuration body colours and paint lists were read with red and blue swapped; `vehicles.json` now writes real ARGB plus the stored value (`format` 4). ## Changes - New module `vehcolour` (sets, library, links; cached in `<work>/index/vehicle_parts.json`). - Export: GLB `COLOR_0` holds each vertex's colour on a white base; `classification.stand_in` is `parts` on those materials. `COLOR_0` alpha 254 marks the primary body paint, 0-100 is roughness x 100, 101-201 the same on parts taken as metal. - Viewer: the primary paint follows the Car paint colour; parts take their roughness; older cached vehicle exports are exported again. ## Checked - In the viewer on comet7, buffalo6, ambulance and bison4: seats, dash, carpet, bumpers, body and roof. - 137 core tests pass (two new). ## Not decoded - What picks the column of a palette row (the middle is used). - The modifier records a configuration lists (`0caef606` in the library, with part id groups `6225734f`, channel bindings `501ff112`, colour and surface assignments `b94308f5`). Interior and trim choices per configuration are not applied; every vehicle shows its default table. - Metalness. A bright neutral row on a smooth surface is taken as metal, which is an inference. - The second layer's colour, colour record modes 4 and 5, rim, tyre and weapon colours. - The Metal renderer shows the colours without the paint swap or per-part roughness. - No motorcycle or boat was checked.
The two-layer vehicle materials (body, interior, mechanical parts) were
drawn with one paint colour or a grey stand-in. Each vertex carries a
part id (0-255) in its vertex colour alpha; this reads what gives an id
its colour:

- A part set (f14244fd, its own 0x7a resource in packs.rpf, 338 found):
  two 256-entry tables, a colour record name per part id
  (8b464cf4.2efff0ae[i].4f9f7603) and a surface record name
  (578f6a03.4e3e21e7[i].8576d517). Its name is a 64-bit value carried by
  the vehicle's variation sets (fc1c7000) and one of its mod elements
  (77f2b89e); 319 models link to a set.
- A library (one 0x7a resource in data.rpf): colour records f1379639
  (colour, mode adb52ec3, palette row c8313558) and surface records
  9e4de959, whose 2cc72f7c names a 307f162c record with roughnessLow and
  roughnessHigh.
- The material palette texture (slot 19df25d7, 128 x 256, the same on
  every vehicle) is not a placeholder: a row is one colour record's
  ramp, dark to bright. Rows of fixed materials (mode 3: rubber,
  plastics, leathers, chrome) are stored; paint rows are black in the
  file and filled by the game.

Colours of type 0x15 have red in the low byte: the library's 151 named
colours (4ce375e6) begin with GTA IV's car colour list only when read
that way. Configuration body colours and paint lists were read with red
and blue swapped; vehicles.json now writes them as real ARGB plus the
stored value ("format" 4).

- New module vehcolour: reads the sets, the library and the links,
  cached in <work>/index/vehicle_parts.json.
- Export: meshes of materials that bind the palette get GLB COLOR_0 =
  the colour of each vertex's part id (the middle of the palette row
  for fixed materials, the record's colour for paints) on a white base;
  classification.stand_in "parts" replaces "trim" and car_paint there.
  COLOR_0 alpha 254 marks the primary body paint, 0-100 is the surface's
  mean roughness x 100, 101-201 the same on parts taken as metal.
  model.json gets part_colours and part_colours_version.
- Viewer: the primary paint follows the Car paint colour, parts take
  their roughness; older cached vehicle exports are exported again.

Checked in the viewer on comet7, buffalo6, ambulance and bison4 (seats,
dash, carpet, bumpers, body and roof). 137 core tests pass.

Not decoded: what picks the column of a palette row; the modifier
records a configuration lists (0caef606 in the library with 6225734f
part id groups, 501ff112 channel bindings, b94308f5 colour and surface
assignments), so interior and trim choices per configuration are not
applied and every vehicle shows its default table; metalness (a bright
neutral row on a smooth surface is taken as metal, an inference); the
second layer's colour; colour record modes 4 and 5; rim, tyre and
weapon colours. The Metal renderer shows the colours without the paint
swap or per-part roughness. No motorcycle or boat was checked.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:06:32 +00:00
github manually merged commit 3b50a33457 into gh-pr/59/base 2026-11-26 20:06:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.