Viewer: clear coat and flakes from the vehicle's coat record (SIX-202) #260

Manually merged
github merged 11 commits from gh-pr/260/head into gh-pr/260/base 2026-11-26 20:22:22 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 12:01 UTC · original
holdmysocks:claude/viewer-clear-coat → master · +76 −9 · 4 files · 11 commits · merged 2026-11-25 12:40 UTC

Part 2 of SIX-202. Builds on PR 256 (the export panic fix), which is included here until it merges.

What

  • The viewer's paint finish "as stored" now uses the coat record of the vehicle's body paint (exported by PR 253):
    • a clear layer over the paint, with the coat's clear coat intensity and roughness;
    • the base coat roughness from the coat when the coat overrides it;
    • flakes: the base highlight is scattered per small cell by the coat's flake orientation, with the cell size from the flake size. Far away, where cells are smaller than a pixel, the scatter turns into extra roughness.
  • The coat follows the selected look (configuration). Other paint finishes and models without a coat are unchanged.

Checked

  • Build and workspace tests pass (291).
  • Before / after pictures of three vehicles with a switch that turned the coat off (switch removed again):
    • a coat with clear coat roughness 0.4 and base roughness 0.5 turns from glossy to satin;
    • two gloss / metallic coats (clear coat roughness 0) differ only slightly: a somewhat sharper highlight.
  • The final build gives a picture identical to the "after" picture.

Not decoded / not done

  • How the game's shaders use these values is not decoded. The layer model here is a standard clear coat, not the game's.
  • The unit of flake size is unknown; the cell size is a guess. Flake coverage is only used as on / off.
  • Film (IOR, thickness), sheen and anisotropy are not drawn.
  • Only the body paint's coat is used, not the coats of other parts.
  • The stored paint metalness is 0 for the vehicles checked, also for "metallic" coats, so metallic paints do not look metallic yet.
  • The Metal 4 renderer is untouched.
  • Not compared with the game.
**@⁠holdmysocks** on GitHub · 2026-11-25 12:01 UTC · [original](https://github.com/holdmysocks/SixNG/pull/260) `holdmysocks:claude/viewer-clear-coat` → `master` · +76 −9 · 4 files · 11 commits · merged 2026-11-25 12:40 UTC Part 2 of SIX-202. Builds on PR 256 (the export panic fix), which is included here until it merges. ## What - The viewer's paint finish "as stored" now uses the coat record of the vehicle's body paint (exported by PR 253): - a clear layer over the paint, with the coat's clear coat intensity and roughness; - the base coat roughness from the coat when the coat overrides it; - flakes: the base highlight is scattered per small cell by the coat's flake orientation, with the cell size from the flake size. Far away, where cells are smaller than a pixel, the scatter turns into extra roughness. - The coat follows the selected look (configuration). Other paint finishes and models without a coat are unchanged. ## Checked - Build and workspace tests pass (291). - Before / after pictures of three vehicles with a switch that turned the coat off (switch removed again): - a coat with clear coat roughness 0.4 and base roughness 0.5 turns from glossy to satin; - two gloss / metallic coats (clear coat roughness 0) differ only slightly: a somewhat sharper highlight. - The final build gives a picture identical to the "after" picture. ## Not decoded / not done - How the game's shaders use these values is not decoded. The layer model here is a standard clear coat, not the game's. - The unit of flake size is unknown; the cell size is a guess. Flake coverage is only used as on / off. - Film (IOR, thickness), sheen and anisotropy are not drawn. - Only the body paint's coat is used, not the coats of other parts. - The stored paint metalness is 0 for the vehicles checked, also for "metallic" coats, so metallic paints do not look metallic yet. - The Metal 4 renderer is untouched. - 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:22:20 +00:00
github manually merged commit 3e012b3371 into gh-pr/260/base 2026-11-26 20:22:22 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.