Viewer: vehicle wear by the game's control terms and rust windows #301

Manually merged
github merged 2 commits from gh-pr/301/head into gh-pr/301/base 2026-11-26 20:25:45 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 18:31 UTC · original
holdmysocks:wear-windows → master · +99 −34 · 2 files · 2 commits · merged 2026-11-25 19:11 UTC

What

The game code that packs a wear preset into the vehicle paint shader's 100-byte part record (rva 0x37766a0) was read. The viewer now draws the first wear layer the way that code and the shader do.

  • Wear amount v0: the middle of the preset's age record's wear range (4e71efc8, b5fcdec9, age +0x0c / +0x10). The game takes a per-vehicle value inside that range. The age range's minWear / maxWear, which #292 used, are not read on this path. They stay only as a fallback for presets whose age is a range record.
  • Per mask channel A / B / C: scale = v0 x controlIntensity x sat((v0 - start) / (end - start)). The activation start and end are the two unnamed bytes after each intensity.
  • Windows: the rust window on the scaled mask channel, from rustStart / rustEnd, B and C. The three windows are summed, as in the shader.
  • Viewer storage: these nine bytes per part go into columns 16 to 24 of the part's coat row. With wear from the configuration on, the shader uses them on the R, G and B channels of the game's wear mask. The manual slider keeps the old threshold rule.

Checked

  • The layout of the 88-byte preset struct was cross-checked: each u8 member i sits at +0x1f + (i - 8). The joaat of controlIntensityA/B/C, rustStart/End, rustStartB/EndB and rustStartC/EndC matches the member hash at exactly the offsets the packer reads.
  • The packer's strides were checked in the disassembly: imul 0x64 (part record) and imul 0xe4 (three 76-byte surface records). So was the v0 fma from age +0x0c / +0x10.
  • New unit test part_wear_from_the_configuration (scale, start, width); workspace tests pass.
  • Renders of rancher configurations, in a private work folder:
    • level 1: clean;
    • level 3: clean (its body ladder's level 3 entry names a preset that is not in the library);
    • level 4: worn patches and rust across body, roll bar and bumpers.

Not decoded / not done

  • The game multiplies each channel's scale by a per-part random sample from the preset's colour ranges. The builder of those samples was not found. It also multiplies by vertex colours. The viewer takes both as 1.
  • The per-vehicle pick within the age record's range (instance +0x1d4) is not traced; the middle is used.
  • Second wear layer (primer, +8/+12/+72/+76/+80/+84), edges (+40), bleach, scratches and dust are not drawn yet; their packing is in the notes.
  • Mask tiling stays 5x; the game's tiling comes from the same colour-range samples.
**@⁠holdmysocks** on GitHub · 2026-11-25 18:31 UTC · [original](https://github.com/holdmysocks/SixNG/pull/301) `holdmysocks:wear-windows` → `master` · +99 −34 · 2 files · 2 commits · merged 2026-11-25 19:11 UTC ## What The game code that packs a wear preset into the vehicle paint shader's 100-byte part record (rva 0x37766a0) was read. The viewer now draws the first wear layer the way that code and the shader do. - **Wear amount v0:** the middle of the preset's age record's wear range (`4e71efc8`, `b5fcdec9`, age +0x0c / +0x10). The game takes a per-vehicle value inside that range. The age range's `minWear` / `maxWear`, which #292 used, are not read on this path. They stay only as a fallback for presets whose age is a range record. - **Per mask channel A / B / C:** scale = v0 x `controlIntensity` x sat((v0 - start) / (end - start)). The activation start and end are the two unnamed bytes after each intensity. - **Windows:** the rust window on the scaled mask channel, from `rustStart` / `rustEnd`, `B` and `C`. The three windows are summed, as in the shader. - **Viewer storage:** these nine bytes per part go into columns 16 to 24 of the part's coat row. With wear from the configuration on, the shader uses them on the R, G and B channels of the game's wear mask. The manual slider keeps the old threshold rule. ## Checked - The layout of the 88-byte preset struct was cross-checked: each u8 member i sits at +0x1f + (i - 8). The joaat of controlIntensityA/B/C, rustStart/End, rustStartB/EndB and rustStartC/EndC matches the member hash at exactly the offsets the packer reads. - The packer's strides were checked in the disassembly: `imul 0x64` (part record) and `imul 0xe4` (three 76-byte surface records). So was the v0 fma from age +0x0c / +0x10. - New unit test `part_wear_from_the_configuration` (scale, start, width); workspace tests pass. - Renders of rancher configurations, in a private work folder: - level 1: clean; - level 3: clean (its body ladder's level 3 entry names a preset that is not in the library); - level 4: worn patches and rust across body, roll bar and bumpers. ## Not decoded / not done - The game multiplies each channel's scale by a per-part random sample from the preset's colour ranges. The builder of those samples was not found. It also multiplies by vertex colours. The viewer takes both as 1. - The per-vehicle pick within the age record's range (instance +0x1d4) is not traced; the middle is used. - Second wear layer (primer, +8/+12/+72/+76/+80/+84), edges (+40), bleach, scratches and dust are not drawn yet; their packing is in the notes. - Mask tiling stays 5x; the game's tiling comes from the same colour-range samples.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:25:43 +00:00
github manually merged commit 364880b51a into gh-pr/301/base 2026-11-26 20:25:45 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.