Viewer: draw the game's own vehicle liveries #423

Manually merged
github merged 2 commits from github-bot/gh-423 into gh-pr/423/base 2026-11-27 02:26:47 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-26 23:23 UTC · original
holdmysocks:game-liveries → master · +297 −21 · 9 files · 2 commits · merged 2026-11-27 02:12 UTC

The viewer can now put on the game's own vehicle liveries ("brands", such as the dairy livery of the Benson box truck). Each sticker is placed with the transform the game computes from its livery layout.

What the game does (read from the packer and the paint shader)

  • Livery layer record (64 bytes, written by the packer at rva 0x37766a0):

    • Byte 0 = the layout's UV mode.
    • +4 = f16 (ou, ov), +8 = f16 (a, b), +0xc = f16 (c, d).
    • +0x14 to +0x1c = the three mask colours; +0x24/+0x28 = textures; +0x30 = mask flag.
  • Transform. The shader draws the sticker where u = a·U + b·V + ou and v = c·U + d·V + ov both lie in 0..1. The packer builds it in three steps:

    • translate by the layout's position;
    • rotate about (0.5, 0.5) by its rotation;
    • scale about (0.5, 0.5) by its size divided by lerp(scale_lo, 1, r).

    The rotation also moves by turn·(2r' − 1) degrees. Here r and r' are per-vehicle random draws; the viewer uses 0.5 for both. The size's first field (9d2ff2b1) is U's size; the earlier export had the two the other way round.

  • UV set. UV mode k (1..4) reads the mesh's UV set k − 1 (shader 00d78–00dcc). Across all brands:

    UV mode Stickers
    3 14,871
    2 1,030
    4 690
    1 414

    So most stickers use the third UV set.

  • Zones. A layout names sticker zones only. On a vehicle built from parts, those zones can lie on a fitted part (the Benson's box is truckbeds_box_01_hi) rather than on the body.

Changes

  • Export (vehstickers):
    • Each placed sticker gets uv (the game transform), plus scale_lo, turn and mask.
    • The size order is fixed.
    • liveries() returns the brands per vehicle.
    • liveries.json goes to format 3, with an updated note.
  • Viewer:
    • Meshes carry their third and fourth UV sets (as half floats, in vertex attribute 15).
    • The sticker shader can read any of the four UV sets.
    • A new "Game livery" menu in the livery panel lists the vehicle's brands. Picking one places its stickers on the model that holds their zones.
    • A game-placed sticker can be switched to hand placement.
    • New command-line option --livery-brand NAME for scripted renders.

Tests

  • Core: the vehstickers tests pass (2), including a new one for the transform.
  • Viewer: the livery, glb and shader validation tests pass (12).
  • Render: Benson with BENSON_BRAND_BAUMHARDERDAIRY.
    • The "BAUMHARDER DAIRY" banner shows on the box side and a "B" logo on each rear door, all the right way round.
    • The cab-door logo (on the body itself) also shows.
    • Before this change, nothing was drawn.

Not done

  • Some brands name zones that no vertex of the vehicle or its parts carries, so they draw nothing:

    • Buffalo gang liveries name zones 93–99.
    • The Rhode police brand names 252 and 253.

    A remap may exist; it is not traced.

  • The random scale and turn are taken at their middle values.

  • The brand's fourth colour (other_colour) is not used. It may be the paint under the livery.

  • The Metal renderer does not pass the new UV sets, so game stickers in sets 2 and 3 do not show there.

**@⁠holdmysocks** on GitHub · 2026-11-26 23:23 UTC · [original](https://github.com/holdmysocks/SixNG/pull/423) `holdmysocks:game-liveries` → `master` · +297 −21 · 9 files · 2 commits · merged 2026-11-27 02:12 UTC The viewer can now put on the game's own vehicle liveries ("brands", such as the dairy livery of the Benson box truck). Each sticker is placed with the transform the game computes from its livery layout. ## What the game does (read from the packer and the paint shader) - **Livery layer record** (64 bytes, written by the packer at rva 0x37766a0): - Byte 0 = the layout's UV mode. - +4 = f16 (ou, ov), +8 = f16 (a, b), +0xc = f16 (c, d). - +0x14 to +0x1c = the three mask colours; +0x24/+0x28 = textures; +0x30 = mask flag. - **Transform.** The shader draws the sticker where `u = a·U + b·V + ou` and `v = c·U + d·V + ov` both lie in 0..1. The packer builds it in three steps: - translate by the layout's position; - rotate about (0.5, 0.5) by its rotation; - scale about (0.5, 0.5) by its size divided by `lerp(scale_lo, 1, r)`. The rotation also moves by `turn·(2r' − 1)` degrees. Here `r` and `r'` are per-vehicle random draws; the viewer uses 0.5 for both. The size's first field (`9d2ff2b1`) is U's size; the earlier export had the two the other way round. - **UV set.** UV mode k (1..4) reads the mesh's UV set k − 1 (shader 00d78–00dcc). Across all brands: | UV mode | Stickers | |---|---| | 3 | 14,871 | | 2 | 1,030 | | 4 | 690 | | 1 | 414 | So most stickers use the third UV set. - **Zones.** A layout names sticker zones only. On a vehicle built from parts, those zones can lie on a fitted part (the Benson's box is `truckbeds_box_01_hi`) rather than on the body. ## Changes - Export (`vehstickers`): - Each placed sticker gets `uv` (the game transform), plus `scale_lo`, `turn` and `mask`. - The size order is fixed. - `liveries()` returns the brands per vehicle. - liveries.json goes to format 3, with an updated note. - Viewer: - Meshes carry their third and fourth UV sets (as half floats, in vertex attribute 15). - The sticker shader can read any of the four UV sets. - A new "Game livery" menu in the livery panel lists the vehicle's brands. Picking one places its stickers on the model that holds their zones. - A game-placed sticker can be switched to hand placement. - New command-line option `--livery-brand NAME` for scripted renders. ## Tests - Core: the `vehstickers` tests pass (2), including a new one for the transform. - Viewer: the `livery`, `glb` and shader validation tests pass (12). - Render: Benson with `BENSON_BRAND_BAUMHARDERDAIRY`. - The "BAUMHARDER DAIRY" banner shows on the box side and a "B" logo on each rear door, all the right way round. - The cab-door logo (on the body itself) also shows. - Before this change, nothing was drawn. ## Not done - Some brands name zones that no vertex of the vehicle or its parts carries, so they draw nothing: - Buffalo gang liveries name zones 93–99. - The Rhode police brand names 252 and 253. A remap may exist; it is not traced. - The random scale and turn are taken at their middle values. - The brand's fourth colour (`other_colour`) is not used. It may be the paint under the livery. - The Metal renderer does not pass the new UV sets, so game stickers in sets 2 and 3 do not show there.
Decode how a livery layout becomes the paint shader's sticker transform
(translate, rotate and scale about the middle; the size fields' order;
the random scale and turn), and which UV set its UV mode picks (k - 1).
The viewer loads the third and fourth UV sets, lists a vehicle's game
liveries and places a brand's stickers on the model that holds their
zones.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:39:44 +00:00
github-bot changed target branch from master to gh-pr/423/base 2026-11-27 02:26:45 +00:00
github manually merged commit 65eb5a77c3 into gh-pr/423/base 2026-11-27 02:26:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.