Viewer: vehicle metalness and roughness per pixel from the material map (SIX-207) #272

Manually merged
github merged 14 commits from gh-pr/272/head into gh-pr/272/base 2026-11-26 20:23:27 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 13:20 UTC · original
holdmysocks:claude/vehicle-material-map → master · +138 −15 · 5 files · 14 commits · merged 2026-11-25 14:02 UTC

SIX-207.

What

  • Export: part_colours.surfaces in a vehicle's model.json gives each part id's metalness low / high and roughness low / high, per look. EXPORT_VERSION 25 -> 26, so cached vehicles re-export.
  • Viewer: where a vehicle material has a decoded material map, part pixels take metalness from the map's red channel and roughness from its green channel, between the part's low and high. Before, one mean value per model was used.
  • The body paint keeps its finish and coat; the map is not applied to painted pixels.
  • No new texture slot: the map was already bound for its occlusion channel, and the part ramp image grows from 512 to 768 rows to carry the surfaces.

Checked

  • Build and workspace tests pass (301; one new viewer test, one extended).
  • Fresh exports (cache deleted first) of five vehicles: two cars, a pickup, a truck, a motorbike. No panic, model.json has the new data.
  • Before / after difference pictures: the change follows the map (weld seams, ribs, panel lines) and painted panels do not change.
  • The wear layer still works after the row change.

Not decoded / not done

  • The effect is small. Changed pixels move by about 3 to 6 levels of 255. On car exteriors under 1.5 % of pixels change; undersides, engine bays, the truck and the motorbike up to 10 %.
  • Many body, interior and reflector materials name a material map that the texture index does not hold, so they keep the mean. Whether those maps exist elsewhere in the install is not known.
  • That the game's blend is plain linear with no further constant is taken from the existing note on the paint shader; the shader was not re-read.
  • The wear (second) layer still uses the mean.
  • The GLB is unchanged; only model.json gained data.
  • The Metal 4 renderer is untouched and was not compiled.
  • Not compared with the game.
**@⁠holdmysocks** on GitHub · 2026-11-25 13:20 UTC · [original](https://github.com/holdmysocks/SixNG/pull/272) `holdmysocks:claude/vehicle-material-map` → `master` · +138 −15 · 5 files · 14 commits · merged 2026-11-25 14:02 UTC SIX-207. ## What - Export: `part_colours.surfaces` in a vehicle's model.json gives each part id's metalness low / high and roughness low / high, per look. `EXPORT_VERSION` 25 -> 26, so cached vehicles re-export. - Viewer: where a vehicle material has a decoded material map, part pixels take metalness from the map's red channel and roughness from its green channel, between the part's low and high. Before, one mean value per model was used. - The body paint keeps its finish and coat; the map is not applied to painted pixels. - No new texture slot: the map was already bound for its occlusion channel, and the part ramp image grows from 512 to 768 rows to carry the surfaces. ## Checked - Build and workspace tests pass (301; one new viewer test, one extended). - Fresh exports (cache deleted first) of five vehicles: two cars, a pickup, a truck, a motorbike. No panic, model.json has the new data. - Before / after difference pictures: the change follows the map (weld seams, ribs, panel lines) and painted panels do not change. - The wear layer still works after the row change. ## Not decoded / not done - The effect is small. Changed pixels move by about 3 to 6 levels of 255. On car exteriors under 1.5 % of pixels change; undersides, engine bays, the truck and the motorbike up to 10 %. - Many body, interior and reflector materials name a material map that the texture index does not hold, so they keep the mean. Whether those maps exist elsewhere in the install is not known. - That the game's blend is plain linear with no further constant is taken from the existing note on the paint shader; the shader was not re-read. - The wear (second) layer still uses the mean. - The GLB is unchanged; only model.json gained data. - The Metal 4 renderer is untouched and was not compiled. - Not compared with the game.
The library's coat records (struct 2b84f07e: clear coat, flakes, film,
sheen, anisotropy) are read; a part set's paintHash and a configuration's
paint type parts give each part id its coat. model.json gets
part_colours.coat (records, per look, body paint). vehicle_parts.json
format 21, part colours export version 25.
Glossy surfaces had only a two-colour sky gradient to reflect, and models
floated over the grid.

- shader: `environment(d, blur)` replaces the gradient for reflections: sky
  from horizon to zenith, a glow around the sun, a sharp horizon and a
  ground of asphalt lit by the sun and the sky (never brighter than the
  horizon sky). The horizon, the gradient and the glow widen with the
  roughness of the reflecting surface. `sky(d)`, the background, adds the
  sun's disc; reflections leave it to the direct specular term.
- shader: `ambient(n)`: as before for surfaces that face up or sideways;
  surfaces that face down take the light the ground sends back.
- renderer: `Renderer3D::ground`, a soft shadow on the ground under the
  model: two blurred rounded boxes from the model's bounds (one under it,
  a wider one pushed away from the sun). Not a shadow map. Shaded mode
  only, drawn after the opaque surfaces.
- model view: sets the shadow for models up to 40 m, and puts the ground
  (grid and shadow) under the tyres of a vehicle on its wheels; the grid
  used to sit at the body's lowest point and cut through the wheels.

No change to the frame uniforms or the paint and specular code.
The part reference modifier (51aab7c1) was read by the field names type
and data; data is not a built-in name, so without the name dictionary no
reference was followed and 1,202 configurations got other part colours.
The part_colours.coat block indexed a JSON map by key, which panics when the key is missing: shared library parts and models without a body paint coat have none of the four. Read them with get.
The paint finish 'as stored' now draws a second, clear layer over the
paint with the coat's intensity and roughness, takes the base coat
roughness from the coat when it overrides it, and scatters the base
highlight with the coat's flake orientation and size.

Film, sheen and anisotropy are not drawn.
A vehicle part's metalness and roughness lie between the low and the high
of its surface record, by the red and green of the material's
lyr0materialatex. Export and viewer used one blend per model (the map's
mean, packed in the vertex colour alpha).

Export: model.json part_colours.surfaces lists each part id's low and high
per look (and per part patch). part_colours_version 26.

Viewer: the part ramp image gets 256 more rows with those values and is
bound on every part material; where a material has its material map, the
shader blends per pixel. Materials without the map, the body paint (paint
finish and coat) and the wear layer are as before.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:23:25 +00:00
github manually merged commit 36fac528e2 into gh-pr/272/base 2026-11-26 20:23:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.