Viewer: weapon parts in the colours of their material presets #114

Manually merged
github merged 2 commits from gh-pr/114/head into gh-pr/114/base 2026-11-26 20:10:52 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 04:02 UTC · original
holdmysocks:claude/weapon-colours → master · +88 −15 · 4 files · 2 commits · merged 2026-11-24 04:11 UTC

What this changes

  • Viewer: weapons in colour. When a weapon is assembled from its parts, each part's weapon materials take the base colours of the part's layered-material preset (weapon library, matlib). The sub-material is picked per texel from a materialid texture when the material binds one, else per vertex from the green byte of the raw colour stream (value / 4), applied as a vertex tint. The model info lists the preset used per part (weapon_presets) and a note on what is not applied.
  • Index built on demand also holds the weapon links (Index::add_weapon_files, used by sixng materials and by load_or_build). Before, an index that the viewer built itself had no weapon models in it. This commit was pushed to #110's branch just after it merged, so it is here instead.
  • README: one sentence in the materials row.

What was checked

  • Per-vertex rule on 62 exported parts of three weapons (a rifle, a pistol, a shotgun): 60 hold only values of the form 4k + 2 in that byte, and the sub-materials used line up with the distinct colours of the part's preset (a fibre-optic front sight: dark body plus one green sub-material). 2 parts also hold other values; they still divide by 4. None of the 62 has a materialid texture, so the per-vertex path is the one weapons use.
  • Screenshots (--gpu radeon): the pistol comes out with a black frame, dark brown grips and bare steel barrel and trigger; the rifle near black, as its presets say.
  • cargo test -p sixng-core: passes. cargo check -p sixng-gui and a release build of the viewer: pass.

What is not done / not known

  • The per-vertex rule is inferred from the data (value pattern and colour fit); the vertex shader that passes the id on was not read.
  • Only the base colour is applied: no tile texture, gradient, tint-mask, dirt or wear layers; metalness and roughness stay the gun-metal stand-in.
  • A single weapon part opened on its own, and the glTF export, are not coloured.
  • A model with two presets uses the first; variant presets (finishes per part) are not offered.
**@⁠holdmysocks** on GitHub · 2026-11-24 04:02 UTC · [original](https://github.com/holdmysocks/SixNG/pull/114) `holdmysocks:claude/weapon-colours` → `master` · +88 −15 · 4 files · 2 commits · merged 2026-11-24 04:11 UTC ## What this changes - **Viewer: weapons in colour.** When a weapon is assembled from its parts, each part's `weapon` materials take the base colours of the part's layered-material preset (weapon library, `matlib`). The sub-material is picked per texel from a `materialid` texture when the material binds one, else per vertex from the green byte of the raw colour stream (value / 4), applied as a vertex tint. The model info lists the preset used per part (`weapon_presets`) and a note on what is not applied. - **Index built on demand also holds the weapon links** (`Index::add_weapon_files`, used by `sixng materials` and by `load_or_build`). Before, an index that the viewer built itself had no weapon models in it. This commit was pushed to #110's branch just after it merged, so it is here instead. - README: one sentence in the materials row. ## What was checked - Per-vertex rule on 62 exported parts of three weapons (a rifle, a pistol, a shotgun): 60 hold only values of the form 4k + 2 in that byte, and the sub-materials used line up with the distinct colours of the part's preset (a fibre-optic front sight: dark body plus one green sub-material). 2 parts also hold other values; they still divide by 4. None of the 62 has a `materialid` texture, so the per-vertex path is the one weapons use. - Screenshots (`--gpu radeon`): the pistol comes out with a black frame, dark brown grips and bare steel barrel and trigger; the rifle near black, as its presets say. - `cargo test -p sixng-core`: passes. `cargo check -p sixng-gui` and a release build of the viewer: pass. ## What is not done / not known - The per-vertex rule is inferred from the data (value pattern and colour fit); the vertex shader that passes the id on was not read. - Only the base colour is applied: no tile texture, gradient, tint-mask, dirt or wear layers; metalness and roughness stay the gun-metal stand-in. - A single weapon part opened on its own, and the glTF export, are not coloured. - A model with two presets uses the first; variant presets (finishes per part) are not offered.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:10:50 +00:00
github manually merged commit 854a4cc42c into gh-pr/114/base 2026-11-26 20:10:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.