Vehicles: tyres, lamp lenses, reflectors and lamps get their own classes #22

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

@⁠holdmysocks on GitHub · 2026-11-23 01:32 UTC · original
holdmysocks:claude/vehicle-materials → master · +134 −16 · 10 files · 1 commits · merged 2026-11-23 01:38 UTC

What was wrong

Opening a car in the model viewer showed tyres with red and black rings, flat dark headlights and taillights, and body-coloured lamp housings. None of it was a texture decode fault; the materials were classified wrongly.

  • Tyres. diffusetex on standard_vehicle_2lyr_tyre_inst is the engine-default white, so the exporter fell back to the material's only sRGB texture, slot 19df25d7. That is a 128x256 palette of colour bands shared by the two-layer vehicle shaders, not a colour map.
  • Lamp lenses. standard_vehicle_alpha was forced opaque, so the lens covers hid the lamps behind a flat olive panel. Their colour texture is one constant colour with the opacity in alpha.
  • Reflectors. standard_vehicle_2lyr_reflector was classed as car paint.
  • Lamps. The standard_vehicle_emissive* shaders were classed opaque, and the viewer lit emissive materials from the first colour slot rather than emissivetex.

What changed

  • Slot 19df25d7 is never a base colour (role palette).
  • Tyres get a dark rubber stand-in, reflectors a chrome one. classification.stand_in ("rubber", "chrome" or null) names it; the viewer takes the metallic and roughness factors from the GLB.
  • standard_vehicle_alpha is glass, blended by the colour texture's alpha.
  • standard_vehicle_emissive* is emissive. A shader with its own emissivetex lights from that map, in the GLB (emissiveTexture) and in the viewer. An emissive material with no texture no longer keeps emissiveFactor in the GLB.
  • Viewer: mirrored instances (right-hand wheels) had inverted normals because their triangles wind the other way. The vertex shader now passes the mirror sign.
  • Viewer: cached vehicle exports from before this change are exported again when opened (matched by shader hash; no cache version bump).

Checked

  • cargo test -p sixng-core: 79 pass, including a new vehicle_classes test.
  • baller2_hi rendered in the rebuilt viewer from the front and the rear: dark tyres on both sides, see-through glass and lenses, lit lamps.

Not checked, not changed

  • Only baller2 was rendered. Other vehicles and the map views were not.
  • The emissive-by-name rule covers vehicle shaders only, so map materials keep their classes. Map materials already classed emissive now light from emissivetex when they have one.
  • The Metal renderer ignores the stand-in factors (not built or run here).
  • Every standard_vehicle_2lyr material still takes the body colour, interior and trim included. That needs the palette lookup, which is not decoded.
  • Existing vehicle thumbnails are not regenerated.
**@⁠holdmysocks** on GitHub · 2026-11-23 01:32 UTC · [original](https://github.com/holdmysocks/SixNG/pull/22) `holdmysocks:claude/vehicle-materials` → `master` · +134 −16 · 10 files · 1 commits · merged 2026-11-23 01:38 UTC ## What was wrong Opening a car in the model viewer showed tyres with red and black rings, flat dark headlights and taillights, and body-coloured lamp housings. None of it was a texture decode fault; the materials were classified wrongly. - **Tyres.** `diffusetex` on `standard_vehicle_2lyr_tyre_inst` is the engine-default white, so the exporter fell back to the material's only sRGB texture, slot `19df25d7`. That is a 128x256 palette of colour bands shared by the two-layer vehicle shaders, not a colour map. - **Lamp lenses.** `standard_vehicle_alpha` was forced opaque, so the lens covers hid the lamps behind a flat olive panel. Their colour texture is one constant colour with the opacity in alpha. - **Reflectors.** `standard_vehicle_2lyr_reflector` was classed as car paint. - **Lamps.** The `standard_vehicle_emissive*` shaders were classed opaque, and the viewer lit emissive materials from the first colour slot rather than `emissivetex`. ## What changed - Slot `19df25d7` is never a base colour (role `palette`). - Tyres get a dark rubber stand-in, reflectors a chrome one. `classification.stand_in` (`"rubber"`, `"chrome"` or null) names it; the viewer takes the metallic and roughness factors from the GLB. - `standard_vehicle_alpha` is `glass`, blended by the colour texture's alpha. - `standard_vehicle_emissive*` is `emissive`. A shader with its own `emissivetex` lights from that map, in the GLB (`emissiveTexture`) and in the viewer. An emissive material with no texture no longer keeps `emissiveFactor` in the GLB. - Viewer: mirrored instances (right-hand wheels) had inverted normals because their triangles wind the other way. The vertex shader now passes the mirror sign. - Viewer: cached vehicle exports from before this change are exported again when opened (matched by shader hash; no cache version bump). ## Checked - `cargo test -p sixng-core`: 79 pass, including a new `vehicle_classes` test. - `baller2_hi` rendered in the rebuilt viewer from the front and the rear: dark tyres on both sides, see-through glass and lenses, lit lamps. ## Not checked, not changed - Only `baller2` was rendered. Other vehicles and the map views were not. - The emissive-by-name rule covers vehicle shaders only, so map materials keep their classes. Map materials already classed emissive now light from `emissivetex` when they have one. - The Metal renderer ignores the stand-in factors (not built or run here). - Every `standard_vehicle_2lyr` material still takes the body colour, interior and trim included. That needs the palette lookup, which is not decoded. - Existing vehicle thumbnails are not regenerated.
Tyres rendered with red and black rings: their diffusetex is the
engine-default white, so the exporter fell back to the only sRGB texture
of the material, slot 19df25d7. That is a 128x256 palette of colour
bands shared by the two-layer vehicle shaders, not a colour map. It is
now never a base colour, and the tyre shader
(standard_vehicle_2lyr_tyre_inst) gets a dark rubber stand-in.

Lamp lenses (standard_vehicle_alpha) were forced opaque and hid the
lamps behind a flat olive panel; they are glass now, blended by the
colour texture's alpha. Lamp reflectors (standard_vehicle_2lyr_reflector)
were painted with the body colour; they are chrome. The
standard_vehicle_emissive* shaders are emissive, and a shader with its
own emissivetex lights from that map in the GLB and in the viewer. An
emissive material with no texture no longer glows flat white in the GLB.

classification.stand_in ("rubber", "chrome" or null) names the stand-in
surface; the viewer takes its metallic and roughness factors from the GLB.

Viewer: mirrored instances (right-hand wheels) had inverted normals,
because their triangles wind the other way; the vertex shader passes the
mirror sign. Cached vehicle exports from before this change are exported
again when opened.

Not changed: every standard_vehicle_2lyr material still takes the body
colour (interior, trim), since the palette lookup is not decoded. The
Metal renderer ignores the stand-in factors.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:03:36 +00:00
github manually merged commit 6dac5f3057 into gh-pr/22/base 2026-11-26 20:03:38 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.