Viewer: fabric weave per pixel for a garment's main sub-material #128

Manually merged
github merged 1 commit from gh-pr/128/head into gh-pr/128/base 2026-11-26 20:11:56 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 05:53 UTC · original
holdmysocks:claude/fabric-detail → master · +131 −19 · 9 files · 1 commits · merged 2026-11-24 06:05 UTC

Replaces the draft #117, rebuilt on master after #122 (the fabric bake). Linear: SIX-43.

What this changes

  • Close-up weave in the wgpu shader. For an opaque garment, the bake now leaves the weave of the garment's main sub-material (the one with a tile that covers most texels) to the shader: those texels are baked at the tile's mean grey value and marked in the base texture's alpha; the shader samples the tile per pixel on the second UV set and scales the colour by the gradient's brightness at that grey value relative to the mean. The tile's mips bring it back to the mean with distance, so nothing changes at normal viewing distance.
  • What stays baked: every other sub-material, cutout garments, all tint-mask layers, and everything on the Metal renderer (it only gets detail: None in its two material constructors).
  • fabric::bake takes a detail flag and returns the main sub-material; Tex::mean, Tex::rgba, Fabric::detail are new. Material uniform +1 vector, material bind group +1 texture. glb::merge shifts the detail image index like the other image indices.
  • SIXNG_NO_FABRIC_DETAIL=1 turns the shader weave off (the bake then does everything, as before).
  • README: the fabric paragraph.

What was checked

  • Lead character's first outfit, --gpu radeon, with and without the switch: at very close range the denim twill is crisp per pixel instead of blurred; the mean colour of the same screen region differs by at most 1 level of 255 at both distances (78.6 / 102.6 / 130.4 against 79.0 / 103.4 / 131.5 close up; 93.5 / 103.7 / 120.1 against 93.4 / 103.5 / 119.9 at normal distance). The pale hems, a different sub-material, keep their baked weave.
  • A first build showed no weave and a wrong colour: merged outfit parts kept an unshifted detail image index. Fixed in glb::merge; the screenshots above are from after the fix.
  • cargo test -p sixng-core passes; release build of the viewer passes.

What is not done / not known

  • The Metal renderer is not compiled here and gets no shader weave.
  • The brightness curve is exact for the dark half of the gradient and a gentle approximation for the light half (the game also desaturates there).
  • One detail tile per material: on a garment of several fabrics only the main one is sharp close up.
  • The tile's normal map is still not drawn.
**@⁠holdmysocks** on GitHub · 2026-11-24 05:53 UTC · [original](https://github.com/holdmysocks/SixNG/pull/128) `holdmysocks:claude/fabric-detail` → `master` · +131 −19 · 9 files · 1 commits · merged 2026-11-24 06:05 UTC Replaces the draft #117, rebuilt on master after #122 (the fabric bake). Linear: SIX-43. ## What this changes - **Close-up weave in the wgpu shader.** For an opaque garment, the bake now leaves the weave of the garment's main sub-material (the one with a tile that covers most texels) to the shader: those texels are baked at the tile's mean grey value and marked in the base texture's alpha; the shader samples the tile per pixel on the second UV set and scales the colour by the gradient's brightness at that grey value relative to the mean. The tile's mips bring it back to the mean with distance, so nothing changes at normal viewing distance. - **What stays baked:** every other sub-material, cutout garments, all tint-mask layers, and everything on the Metal renderer (it only gets `detail: None` in its two material constructors). - `fabric::bake` takes a `detail` flag and returns the main sub-material; `Tex::mean`, `Tex::rgba`, `Fabric::detail` are new. Material uniform +1 vector, material bind group +1 texture. `glb::merge` shifts the detail image index like the other image indices. - `SIXNG_NO_FABRIC_DETAIL=1` turns the shader weave off (the bake then does everything, as before). - README: the fabric paragraph. ## What was checked - Lead character's first outfit, `--gpu radeon`, with and without the switch: at very close range the denim twill is crisp per pixel instead of blurred; the mean colour of the same screen region differs by at most 1 level of 255 at both distances (78.6 / 102.6 / 130.4 against 79.0 / 103.4 / 131.5 close up; 93.5 / 103.7 / 120.1 against 93.4 / 103.5 / 119.9 at normal distance). The pale hems, a different sub-material, keep their baked weave. - A first build showed no weave and a wrong colour: merged outfit parts kept an unshifted detail image index. Fixed in `glb::merge`; the screenshots above are from after the fix. - `cargo test -p sixng-core` passes; release build of the viewer passes. ## What is not done / not known - **The Metal renderer is not compiled here** and gets no shader weave. - The brightness curve is exact for the dark half of the gradient and a gentle approximation for the light half (the game also desaturates there). - One detail tile per material: on a garment of several fabrics only the main one is sharp close up. - The tile's normal map is still not drawn.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:11:54 +00:00
github manually merged commit 6ccdf22832 into gh-pr/128/base 2026-11-26 20:11:56 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.