Viewer: the first wear layer's tint blend (W2) and 4th wear channel #401
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/holdmysocks--SixNG!401
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-401"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@holdmysocks on GitHub · 2026-11-26 19:16 UTC · original
holdmysocks:wear-tint-blend→master· +160 −13 · 4 files · 4 commits · merged 2026-11-26 20:40 UTCThe viewer now draws two more parts of the game's paint shader for the first wear layer: the tint-to-palette blend (W2) and the 4th wear channel (D4). Builds on PR 381 (it includes that commit; merge 381 first).
What the game does (read from the shader and the packer)
lerp(tint, palette colour, W2). The tint is the colour of the colour record that the surface names for its second layer (5cffe5e0, the record'scolour, packed sRGB to linear by rva 0x37766a0 into surface record +16). Per channel R, G, B, W2 puts a window on the same levels as the layer's weight. A fourth window covers D4. Each window issat((x - start) / width × 255 / divisor). The R, G and B terms are summed and saturated, then max-ed with the D4 term.a = sat((v0 - s) / max(1e-4, e - s))from preset bytes +0x46..+0x4b and +0x51/52. The start is thena × f(start)and the widtha × f(end) - a × f(start)(one fused multiply-subtract, no floor). Both are ×255 and truncated to the low byte, so a negative width wraps round. The divisors are the raw preset bytes +0x4c/4d/4e/53 (part record +88).f16(v0 × f(+0x21)) × lyr0diffusetex.b, with no level or gamma. Its window (+0x22/+0x23, part record +64 bytes 2 and 3) adds to the layer's weight. A second window feeds W2.lyr0diffusetex.r. Only the base paint's column comes from.g. The viewer used.gfor both.Changes
vehcolour,export): addswear_tintper look, the sRGB colour of each part id's second layer, 6 hex digits per part id, with a note. EXPORT_VERSION goes to 30 and FORMAT to 25, so the viewer re-exports older vehicles.part_wearpacks the W2 windows, the divisors, the D4 scale and the D4 window with the game's arithmetic.Tests
vehcolourtests pass (9), including a new check of thewear_tinttable.part_wearandprimertests pass (2). They include new cases for W2: activation 0.8 giving window 40/81, a reversed window wrapping round to 216, and the divisor byte. They also cover the D4 scale (102) and window (25/51), worked out in f32.Not drawn yet
The edge/bump term (+40), the clear-coat loss (+56 b3), the dust/bleach/scratch mask, and the per-vehicle amounts I[0x220]/I[0x224].