Viewer: draw stickers placed on a vehicle (custom liveries) #176

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

@⁠holdmysocks on GitHub · 2026-11-24 16:14 UTC · original
holdmysocks:claude/livery-draw → master · +1165 −40 · 11 files · 11 commits · merged 2026-11-24 17:02 UTC

What

Second step of the custom livery editor (SIX-122): the viewer draws stickers that are placed on a vehicle, from a list of placements per vehicle. The editor panel that makes such a list by hand is the next PR; here the list comes from a JSON file.

Drawing (shader.wgsl, render3d.rs)

  • Like the game's two-layer vehicle shader: a sticker lies on the sticker zones it lists and is drawn where the mesh UV, taken through its 2x2 matrix and offset, is between 0 and 1 (u = U*a + V*b + ou, v = U*c + V*d + ov), in the first or the second UV set.
  • A colour mask's red, green and blue are the cover of three colours; other pictures bring their own colours and alpha, times a tint. Each sticker has an opacity.
  • The frame bind group gets three more bindings: the sticker records (a storage buffer), the pictures as layers of one 1024 x 1024 texture array with mips, and a clamping sampler. Models without stickers bind a one-record "none" buffer and a 1 x 1 array. No new material bindings; the part ramp slots are untouched.
  • Limits, both this viewer's: 64 stickers per vehicle and 32 different pictures per vehicle. There is no limit per zone (the game's shader takes three per zone): every pixel walks the vehicle's list, and later stickers lie on top.
  • The shader can also tint a sticker's zones and outline it (for the editor's selection; unused until the next PR).

Placements (new livery.rs)

  • A placement is given in terms a person can set: the model (the vehicle itself or a fitted part such as a box, because zones are numbered per model), the zones, the UV set, the centre in that UV set, width and height in metres, a rotation, mirror, colours, opacity.
  • The shader's six numbers are worked out from those and from how the chosen zones' UVs lie on the model (area-weighted mean of the model-space step per unit of U and V, and the zones' mean normal): the sticker comes out upright as seen from outside and at its metric size whatever way the UV island is turned. On the box truck the same placement numbers work on the left wall and on the right wall, whose UVs are turned 180 degrees.
  • A vehicle's placements are read from <work>/liveries/<vehicle>.json when the vehicle opens. --livery FILE opens another file for scripted runs; --livery-info FILE writes the loaded vehicle's zones (per model: zone, side, area, UV box and metres per UV unit in both UV sets).

Cache: vehicle exports from before PR 162 have no _COLOR1 in their GLB. vehcolour::EXPORT_VERSION goes from 20 to 21, so the viewer exports a vehicle (and its fitted parts) again the first time it is opened.

Checked

  • benson_hi with its box (truckbeds_box_01_hi), five stickers from a hand-written file: a 4:1 picture on the left box wall (zones 169 to 174), a colour mask on the same wall, the picture again on the right wall (177 to 182), and the mask on both cab doors (zones 24 and 32, one of them turned 15 degrees). All five come out upright, on the right panels, at the sizes asked for; the mask takes its three colours. Scripted screenshots from both sides:
    sixng-gui --model "~^benson_hi$" --no-picker --yaw 2.3 --pitch 0.25 --zoom 0.9 --size 1300x800 --exit --livery <file> --screenshot <out.png> (and --yaw -2.3).
  • --livery-info on the same truck: the box's side walls come out as zones 169 to 174 (left) and 177 to 182 (right) at 7.66 to 7.81 m per UV unit in the second UV set, which agrees with the 7.72 m known from SIX-109; the doors as 24 (left) and 32 (right).
  • Four unit tests (cargo test -p sixng-gui livery): a sticker is upright and metric on a wall whether or not its UVs are mirrored, a first placement fits its zone, a ray finds zone and UV, a livery file round-trips. All pass.
  • cargo build --release -p sixng-cli -p sixng-gui passes without warnings.
  • A vehicle without a livery file looks as before (benson compared by eye).

Not decoded / not done

  • No editor yet: placements are written by hand until the next PR. livery.rs carries #![allow(dead_code)] for the picking, fitting and saving parts the editor uses; the next PR removes it.
  • The game's own liveries (brands) are not drawn. The rule from a brand's layout numbers to a place on the panel is still not decoded (SIX-109).
  • Stickers on a part follow that part's zones only; a sticker cannot run from the cab onto the box.
  • Only the first two UV sets reach the viewer's shader, so the game's UV mode 4 (third set) cannot be used.
  • On strongly curved panels the mean UV direction is an approximation, so a large sticker can look slightly sheared there. Flat panels (box walls, doors) are exact.
  • A sticker changes the surface under it to non-metallic at roughness 0.45; the game's own sticker surface values are not read.
  • Pictures are resampled to 1024 x 1024 per layer; a 2048 x 512 picture loses half its horizontal resolution.
  • Not tried on a car in this PR (the next one does). The Metal renderer (macOS, feature metal4-poc) does not draw stickers and was not built here.
  • Screenshots are not attached: they show game assets, which do not go into the repository, and the CLI cannot upload images to a PR. They were handed to the user directly.
**@⁠holdmysocks** on GitHub · 2026-11-24 16:14 UTC · [original](https://github.com/holdmysocks/SixNG/pull/176) `holdmysocks:claude/livery-draw` → `master` · +1165 −40 · 11 files · 11 commits · merged 2026-11-24 17:02 UTC ## What Second step of the custom livery editor (SIX-122): the viewer draws stickers that are placed on a vehicle, from a list of placements per vehicle. The editor panel that makes such a list by hand is the next PR; here the list comes from a JSON file. **Drawing** (`shader.wgsl`, `render3d.rs`) - Like the game's two-layer vehicle shader: a sticker lies on the sticker zones it lists and is drawn where the mesh UV, taken through its 2x2 matrix and offset, is between 0 and 1 (`u = U*a + V*b + ou`, `v = U*c + V*d + ov`), in the first or the second UV set. - A colour mask's red, green and blue are the cover of three colours; other pictures bring their own colours and alpha, times a tint. Each sticker has an opacity. - The frame bind group gets three more bindings: the sticker records (a storage buffer), the pictures as layers of one 1024 x 1024 texture array with mips, and a clamping sampler. Models without stickers bind a one-record "none" buffer and a 1 x 1 array. No new material bindings; the part ramp slots are untouched. - Limits, both this viewer's: **64 stickers per vehicle and 32 different pictures per vehicle.** There is no limit per zone (the game's shader takes three per zone): every pixel walks the vehicle's list, and later stickers lie on top. - The shader can also tint a sticker's zones and outline it (for the editor's selection; unused until the next PR). **Placements** (new `livery.rs`) - A placement is given in terms a person can set: the model (the vehicle itself or a fitted part such as a box, because zones are numbered per model), the zones, the UV set, the centre in that UV set, width and height **in metres**, a rotation, mirror, colours, opacity. - The shader's six numbers are worked out from those and from how the chosen zones' UVs lie on the model (area-weighted mean of the model-space step per unit of U and V, and the zones' mean normal): the sticker comes out upright as seen from outside and at its metric size whatever way the UV island is turned. On the box truck the same placement numbers work on the left wall and on the right wall, whose UVs are turned 180 degrees. - A vehicle's placements are read from `<work>/liveries/<vehicle>.json` when the vehicle opens. `--livery FILE` opens another file for scripted runs; `--livery-info FILE` writes the loaded vehicle's zones (per model: zone, side, area, UV box and metres per UV unit in both UV sets). **Cache**: vehicle exports from before PR 162 have no `_COLOR1` in their GLB. `vehcolour::EXPORT_VERSION` goes from 20 to 21, so the viewer exports a vehicle (and its fitted parts) again the first time it is opened. ## Checked - `benson_hi` with its box (`truckbeds_box_01_hi`), five stickers from a hand-written file: a 4:1 picture on the left box wall (zones 169 to 174), a colour mask on the same wall, the picture again on the right wall (177 to 182), and the mask on both cab doors (zones 24 and 32, one of them turned 15 degrees). All five come out upright, on the right panels, at the sizes asked for; the mask takes its three colours. Scripted screenshots from both sides: `sixng-gui --model "~^benson_hi$" --no-picker --yaw 2.3 --pitch 0.25 --zoom 0.9 --size 1300x800 --exit --livery <file> --screenshot <out.png>` (and `--yaw -2.3`). - `--livery-info` on the same truck: the box's side walls come out as zones 169 to 174 (left) and 177 to 182 (right) at 7.66 to 7.81 m per UV unit in the second UV set, which agrees with the 7.72 m known from SIX-109; the doors as 24 (left) and 32 (right). - Four unit tests (`cargo test -p sixng-gui livery`): a sticker is upright and metric on a wall whether or not its UVs are mirrored, a first placement fits its zone, a ray finds zone and UV, a livery file round-trips. All pass. - `cargo build --release -p sixng-cli -p sixng-gui` passes without warnings. - A vehicle without a livery file looks as before (benson compared by eye). ## Not decoded / not done - No editor yet: placements are written by hand until the next PR. `livery.rs` carries `#![allow(dead_code)]` for the picking, fitting and saving parts the editor uses; the next PR removes it. - The game's own liveries (brands) are not drawn. The rule from a brand's layout numbers to a place on the panel is still not decoded (SIX-109). - Stickers on a part follow that part's zones only; a sticker cannot run from the cab onto the box. - Only the first two UV sets reach the viewer's shader, so the game's UV mode 4 (third set) cannot be used. - On strongly curved panels the mean UV direction is an approximation, so a large sticker can look slightly sheared there. Flat panels (box walls, doors) are exact. - A sticker changes the surface under it to non-metallic at roughness 0.45; the game's own sticker surface values are not read. - Pictures are resampled to 1024 x 1024 per layer; a 2048 x 512 picture loses half its horizontal resolution. - Not tried on a car in this PR (the next one does). The Metal renderer (macOS, feature `metal4-poc`) does not draw stickers and was not built here. - Screenshots are not attached: they show game assets, which do not go into the repository, and the CLI cannot upload images to a PR. They were handed to the user directly.
Mesh stream 12 (RGBA8) was dropped. It is now decoded and written to the GLB as _COLOR1. On vehicle bodies its fourth byte is the sticker zone a livery's layout records list (box side walls, front wall, cab doors).
New core module vehstickers; sixng vehicles also writes <out>/vehicles/liveries.json. Work in progress: the layout reader is not yet checked against the game (the packs index is being rebuilt at version 6).
The layout file's groups are the elements of its root record and its field names are hashed with their capitals. Brands are counted once per vehicle.
# Conflicts:
#	crates/sixng-cli/src/main.rs
#	crates/sixng-core/src/vehstickers.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:15:31 +00:00
github manually merged commit 2398c3161f into gh-pr/176/base 2026-11-26 20:15:33 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.