Materials: tint-mask layers of a preset's sub-materials #115

Manually merged
github merged 3 commits from gh-pr/115/head into gh-pr/115/base 2026-11-26 20:10:57 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 04:13 UTC · original
holdmysocks:claude/tint-mask-layers → master · +178 −20 · 5 files · 3 commits · merged 2026-11-24 04:20 UTC

Stacked on #114 (its commits show here until it merges).

What this adds

  • matlib::Library::layers(preset, sub): the tint-mask layers of a sub-material, each with its mask texture (tintmaskmap[L]), tint (tintmasktint[L], and [4 + L] for the second colour set), opacity, flag word with the invert bit, and the mask's UV scale, rotation and translation. Values are the preset's for the sub-material, else its base material's. Only layers with a mask texture and a non-zero opacity are returned.
  • sixng materials --preset <hex> prints them as tint_mask_layers.
  • One more parameter name: tintmasktranslation (b3643800).
  • The module notes describe how the layers are composed.

Where the composition comes from

Read from the clothing pixel shader (PS_DeferredPedTexturedNC, the layer loop after the base gradient) and matched to the block builder's stores:

m = invert ? 1 - mask.r : mask.r          // invert = bit 2 of tintmaskflags[L]
t = m * tintmaskopacity[L] * tint.alpha
colour = lerp(colour, gradient(tintmasktint[L], g), t)     // L = 0..3 in order

The four masks are sampled on the tiling UV input (the one the tile texture uses), each through its own 2x3 transform; the builder fills four mask texture indices, four transforms, four opacities and flag words and 2 x 4 expanded colour triples per sub-material.

What was checked

  • cargo test -p sixng-core: 148 passed (the matlib test now covers preset-over-base fallback, the invert bit and the opacity filter).
  • Game data: 2,529 of 13,071 clothing presets set at least one active layer themselves and 5,943 of 7,994 base materials carry mask textures, so most garments have layers. On one tan garment preset the layers come out as darker brown weave tints at tilings of 150 to 700, in keeping with the base colour.
  • tintmaskflags values in the data: 8 (2,640), 0 (1,148), 12 (650) and rarer ones; only bit 2 is interpreted.

What is not done / not known

  • Nothing renders these layers yet: the viewer and the export still use the base colour only. Applying them needs the tile and mask textures sampled at their tilings in the renderer.
  • Which parameter is which was matched by shape (four entries per sub-material for the per-layer ones, eight for the pairs) and by name, not by tracing every store of the builder; the opacity and flag offsets and the colour offsets were traced.
  • The other flag bits, the fifth tintmaskmap entry, the roughness / metallic / height / emissive side of a layer, and the pattern, stitch, dirt and sheen layers.
**@⁠holdmysocks** on GitHub · 2026-11-24 04:13 UTC · [original](https://github.com/holdmysocks/SixNG/pull/115) `holdmysocks:claude/tint-mask-layers` → `master` · +178 −20 · 5 files · 3 commits · merged 2026-11-24 04:20 UTC Stacked on #114 (its commits show here until it merges). ## What this adds - `matlib::Library::layers(preset, sub)`: the tint-mask layers of a sub-material, each with its mask texture (`tintmaskmap[L]`), tint (`tintmasktint[L]`, and `[4 + L]` for the second colour set), opacity, flag word with the invert bit, and the mask's UV scale, rotation and translation. Values are the preset's for the sub-material, else its base material's. Only layers with a mask texture and a non-zero opacity are returned. - `sixng materials --preset <hex>` prints them as `tint_mask_layers`. - One more parameter name: `tintmasktranslation` (b3643800). - The module notes describe how the layers are composed. ## Where the composition comes from Read from the clothing pixel shader (`PS_DeferredPedTexturedNC`, the layer loop after the base gradient) and matched to the block builder's stores: ``` m = invert ? 1 - mask.r : mask.r // invert = bit 2 of tintmaskflags[L] t = m * tintmaskopacity[L] * tint.alpha colour = lerp(colour, gradient(tintmasktint[L], g), t) // L = 0..3 in order ``` The four masks are sampled on the tiling UV input (the one the tile texture uses), each through its own 2x3 transform; the builder fills four mask texture indices, four transforms, four opacities and flag words and 2 x 4 expanded colour triples per sub-material. ## What was checked - `cargo test -p sixng-core`: 148 passed (the matlib test now covers preset-over-base fallback, the invert bit and the opacity filter). - Game data: 2,529 of 13,071 clothing presets set at least one active layer themselves and 5,943 of 7,994 base materials carry mask textures, so most garments have layers. On one tan garment preset the layers come out as darker brown weave tints at tilings of 150 to 700, in keeping with the base colour. - `tintmaskflags` values in the data: 8 (2,640), 0 (1,148), 12 (650) and rarer ones; only bit 2 is interpreted. ## What is not done / not known - Nothing renders these layers yet: the viewer and the export still use the base colour only. Applying them needs the tile and mask textures sampled at their tilings in the renderer. - Which parameter is which was matched by shape (four entries per sub-material for the per-layer ones, eight for the pairs) and by name, not by tracing every store of the builder; the opacity and flag offsets and the colour offsets were traced. - The other flag bits, the fifth `tintmaskmap` entry, the roughness / metallic / height / emissive side of a layer, and the pattern, stitch, dirt and sheen layers.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:10:54 +00:00
github manually merged commit 24bf424531 into gh-pr/115/base 2026-11-26 20:10:57 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.