Hair: grow strands the way the game's generation program does #212

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

@⁠holdmysocks on GitHub · 2026-11-24 21:31 UTC · original
holdmysocks:claude/people-hair-strands → master · +248 −44 · 3 files · 1 commits · merged 2026-11-24 22:01 UTC

What

SixNG grew full hair and fur by putting each root triangle's stored count of strands at random points and blending the three guides. The game's strand generation program does it differently. Its simplest variant was read from the compiled code and checked with an interpreter (triangle, seed and root weights bit for bit; length and positions to the output's precision).

Changes

  • New hairgen module with the program's arithmetic: hashed choice of a root triangle weighted by the triangle's density byte (up to four attempts), seed and barycentric weights of the root, three per-strand random draws, strand length and a 2-bit variant.
  • Groom::coat uses it. Strands are placed by the game's hashes, cut at their own length (the blend of the guides' lengths, varied per strand, so tips are uneven) and carry their variant (Coat::variants).
  • groom reads three more things: the per-guide threshold bytes of the variant pick, the groom's seed and its length variation.

Findings

  • The first of a triangle's four count bytes is a density weight under rejection sampling, not a strand count. The other three are not read by this variant.
  • The variant is what the strand shader uses to choose among four colour ramps.
  • This variant has no clumping, curl or noise.

Not covered (stated in the module)

  • The number of strands and the scale of the density byte are run-time values. The stored-count estimate is kept as the budget, and the densest triangle always takes a strand.
  • Cull groups, the length texture, skinning and the twist value.
  • The other variants of the program (about 90, by feature bits), where clumping and curl would be.

Verified

  • cargo test --release --workspace passes (3 new tests with values from the checked reference).
  • One character and one animal rendered in the viewer on the RTX 4080: both draw as before; the visible change is small (uneven tips, different strand positions).

Linear: SIX-152.

**@⁠holdmysocks** on GitHub · 2026-11-24 21:31 UTC · [original](https://github.com/holdmysocks/SixNG/pull/212) `holdmysocks:claude/people-hair-strands` → `master` · +248 −44 · 3 files · 1 commits · merged 2026-11-24 22:01 UTC ## What SixNG grew full hair and fur by putting each root triangle's stored count of strands at random points and blending the three guides. The game's strand generation program does it differently. Its simplest variant was read from the compiled code and checked with an interpreter (triangle, seed and root weights bit for bit; length and positions to the output's precision). ## Changes - New `hairgen` module with the program's arithmetic: hashed choice of a root triangle weighted by the triangle's density byte (up to four attempts), seed and barycentric weights of the root, three per-strand random draws, strand length and a 2-bit variant. - `Groom::coat` uses it. Strands are placed by the game's hashes, cut at their own length (the blend of the guides' lengths, varied per strand, so tips are uneven) and carry their variant (`Coat::variants`). - `groom` reads three more things: the per-guide threshold bytes of the variant pick, the groom's seed and its length variation. ## Findings - The first of a triangle's four count bytes is a density weight under rejection sampling, not a strand count. The other three are not read by this variant. - The variant is what the strand shader uses to choose among four colour ramps. - This variant has no clumping, curl or noise. ## Not covered (stated in the module) - The number of strands and the scale of the density byte are run-time values. The stored-count estimate is kept as the budget, and the densest triangle always takes a strand. - Cull groups, the length texture, skinning and the twist value. - The other variants of the program (about 90, by feature bits), where clumping and curl would be. ## Verified - `cargo test --release --workspace` passes (3 new tests with values from the checked reference). - One character and one animal rendered in the viewer on the RTX 4080: both draw as before; the visible change is small (uneven tips, different strand positions). Linear: SIX-152.
The game's strand generation compute program (smh_gen_1) was read from
the compiled code and checked with an interpreter. New module hairgen
has its arithmetic: the hashed choice of a root triangle weighted by the
triangle's density byte, the seed and barycentric weights of the root,
the per-strand draws, the strand length and the 2-bit variant.

Groom::coat uses it: strands are placed by the game's hashes, cut at
their own length (the blend of the guides' lengths, varied per strand)
and carry their variant. The first of a triangle's four count bytes is a
density weight under rejection sampling, not a strand count.

groom also reads the per-guide threshold bytes of the variant pick, the
groom's seed and its length variation.

Not covered: the strand count and density scale (run-time values), cull
groups, the length texture, and the other variants of the program, where
clumping and curl would be.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:18:34 +00:00
github manually merged commit 92f09d6c46 into gh-pr/212/base 2026-11-26 20:18:36 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.