People: fabric baked into garment textures (weave, colour gradient, tint-mask layers) #122

Manually merged
github merged 6 commits from gh-pr/122/head into gh-pr/122/base 2026-11-26 20:11:29 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 04:57 UTC · original
holdmysocks:claude/people-fabric → master · +377 −7 · 6 files · 6 commits · merged 2026-11-24 05:06 UTC

What

The viewer bakes each garment's fabric into its base texture (new crates/sixng-gui/src/fabric.rs), at 2048 texels:

  • per sub-material (all eight; from the materialid texture, or the per-vertex part number), the tiling fabric texture (tilematerialmap green at tilescale / tilerotation over the second UV set) under the three-stop gradient of its colour (matlib::stops);
  • then its tint-mask layers in order, all four: lerp(colour, gradient(tint), mask x opacity x tint alpha). Denim weave and wash, belts and trims, prints (camouflage).

The tiling UV per texel comes from rasterising the mesh through UV0; each texel samples the tile at the mip level of its footprint, so where the weave is finer than a texel the colour converges to the tile's mean. No shader change, so it applies on both renderers.

Also: matlib::Library::load(ws), and the item's preset hash on LookPart / PartFx.

Relation to #117

Agreed with the shader session (and the user: combine): this goes in first; #117 is then cut down to close-up weave detail in the wgpu shader on top of the baked colour. The bake can sample the tile at its mean for materials that get shader detail, to avoid doubling (follow-up).

Verified

  • Renders: the first story character's shorts (denim weave and wash, lighter cuffs, black belt, copper buckle and rivets) and an eight-character batch (camouflage shorts, woven T-shirt and shirts); no panics.
  • Workspace tests pass after merging master (through #118).

Not verified / limits

  • Read from the shader: gradient, layer order and blend. Assumed: UV transform order (scale, rotation, translation), the tile's scale for a layer that stores none, linear texture values.
  • Not applied: colour set B of the layers, layer flags other than invert, the tile normal map, stitches, dirt, sheen.
  • Where two halves of a garment share texture space, the later one's fabric wins.
  • The weave is only as sharp as the baked texture. outfit --look exports do not have the fabric yet.
  • No render after the last master merge; the Metal renderer was not run.
**@⁠holdmysocks** on GitHub · 2026-11-24 04:57 UTC · [original](https://github.com/holdmysocks/SixNG/pull/122) `holdmysocks:claude/people-fabric` → `master` · +377 −7 · 6 files · 6 commits · merged 2026-11-24 05:06 UTC ## What The viewer bakes each garment's fabric into its base texture (new `crates/sixng-gui/src/fabric.rs`), at 2048 texels: - per sub-material (all eight; from the `materialid` texture, or the per-vertex part number), the tiling fabric texture (`tilematerialmap` green at `tilescale` / `tilerotation` over the second UV set) under the three-stop gradient of its colour (`matlib::stops`); - then its tint-mask layers in order, all four: `lerp(colour, gradient(tint), mask x opacity x tint alpha)`. Denim weave and wash, belts and trims, prints (camouflage). The tiling UV per texel comes from rasterising the mesh through UV0; each texel samples the tile at the mip level of its footprint, so where the weave is finer than a texel the colour converges to the tile's mean. No shader change, so it applies on both renderers. Also: `matlib::Library::load(ws)`, and the item's preset hash on `LookPart` / `PartFx`. ## Relation to #117 Agreed with the shader session (and the user: combine): this goes in first; #117 is then cut down to close-up weave detail in the wgpu shader on top of the baked colour. The bake can sample the tile at its mean for materials that get shader detail, to avoid doubling (follow-up). ## Verified - Renders: the first story character's shorts (denim weave and wash, lighter cuffs, black belt, copper buckle and rivets) and an eight-character batch (camouflage shorts, woven T-shirt and shirts); no panics. - Workspace tests pass after merging master (through #118). ## Not verified / limits - Read from the shader: gradient, layer order and blend. Assumed: UV transform order (scale, rotation, translation), the tile's scale for a layer that stores none, linear texture values. - Not applied: colour set B of the layers, layer flags other than invert, the tile normal map, stitches, dirt, sheen. - Where two halves of a garment share texture space, the later one's fabric wins. - The weave is only as sharp as the baked texture. `outfit --look` exports do not have the fabric yet. - No render after the last master merge; the Metal renderer was not run.
An outfit part now carries the base colours of its item's garment preset
(matlib, one per sub-material), and the viewer colours each texel of a
garment with the colour of its sub-material, read from the materialid
texture (sub-material 0 where a garment has none), shaded as before.
Preset colours come before the stored state colour, the tint row and the
colour tag. matlib::Index::load_or_build builds the preset index when it
is missing, so the viewer does not depend on a sixng materials run.
Garments without a materialid texture number their parts per vertex
(raw vertex colour green = 4 x id + 2). The viewer and outfit --look
exports give each vertex its part's garment preset colour, so belts,
soles and laces are coloured apart. outfit --look bakes preset colours
into the base texture, or writes them as COLOR_0 over a shade-only
texture for the per-vertex garments.
The viewer bakes each sub-material's tiling fabric texture under the
three-stop gradient of its colour, then its tint-mask layers, into the
garment's base texture at 2048 texels (new fabric.rs). Sub-materials come
from the materialid texture or the per-vertex part number, the tiling UV
from the second UV set rasterised through the first. Adds
matlib::Library::load and the preset hash on LookPart.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:11:27 +00:00
github manually merged commit a938ae6b81 into gh-pr/122/base 2026-11-26 20:11:29 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.