Viewer: the primer's metalness and roughness blended by the material map #362

Manually merged
github merged 2 commits from gh-pr/362/head into gh-pr/362/base 2026-11-26 20:30:32 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-26 06:25 UTC · original
holdmysocks:primer-surface → master · +21 −13 · 2 files · 2 commits · merged 2026-11-26 06:38 UTC

The viewer now uses the game's primer metalness and roughness instead of a fixed midpoint.

What the game does

  • A vehicle-global packs primerPalette into four bytes: metallicLow, metallicHigh, roughnessLow and roughnessHigh. Each value is multiplied by 255 and truncated.
  • The part builder copies those four bytes into every part's primer record.
  • The shader blends metal low/high by the material map's red channel, and rough low/high by its green channel. This is the same blend the base surface uses.

Changes

  • primer_surface returns all four bytes. Metal low/high stay in coat-row columns 32/33. Rough low/high go into the new columns 48/49.
  • The shader mixes them by mat_blend, which defaults to 0.5 when a part has no material map.
  • The test covers a filled primerPalette and an empty one (defaults 0/0/0.6/0.6).

Checks

  • Viewer tests pass.
  • Rancher with primer at full amount, set 1, compared against the #350 render: 12.4% of pixels change, with a mean change of 2.3 levels. Only 0.41% change by more than 8 levels. The primer patches show roughness that varies with the material map; metal stays 0.
**@⁠holdmysocks** on GitHub · 2026-11-26 06:25 UTC · [original](https://github.com/holdmysocks/SixNG/pull/362) `holdmysocks:primer-surface` → `master` · +21 −13 · 2 files · 2 commits · merged 2026-11-26 06:38 UTC The viewer now uses the game's primer metalness and roughness instead of a fixed midpoint. ## What the game does - A vehicle-global packs `primerPalette` into four bytes: metallicLow, metallicHigh, roughnessLow and roughnessHigh. Each value is multiplied by 255 and truncated. - The part builder copies those four bytes into every part's primer record. - The shader blends metal low/high by the material map's red channel, and rough low/high by its green channel. This is the same blend the base surface uses. ## Changes - `primer_surface` returns all four bytes. Metal low/high stay in coat-row columns 32/33. Rough low/high go into the new columns 48/49. - The shader mixes them by `mat_blend`, which defaults to 0.5 when a part has no material map. - The test covers a filled `primerPalette` and an empty one (defaults 0/0/0.6/0.6). ## Checks - Viewer tests pass. - Rancher with primer at full amount, set 1, compared against the #350 render: 12.4% of pixels change, with a mean change of 2.3 levels. Only 0.41% change by more than 8 levels. The primer patches show roughness that varies with the material map; metal stays 0.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:30:30 +00:00
github manually merged commit 6417f9e9cd into gh-pr/362/base 2026-11-26 20:30:32 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.