Hair: damp the strand style pass near the head, body and garments #311

Manually merged
github merged 78 commits from gh-pr/311/head into gh-pr/311/base 2026-11-26 20:26:25 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-25 20:36 UTC · original
holdmysocks:claude/people-style-damping → master · +104 −11 · 2 files · 78 commits · merged 2026-11-25 20:52 UTC

Follow-up to #304: the strand style pass now damps its offsets near the character, the way the game's style pass does.

  • Style::apply takes a per-point weight instead of one strength. The offset length is 0.8 mm + k(|o| - 0.8 mm), with k = min(1 - round(3d)/3, strength) and d = sat(1 - dist/falloff) to the nearest collider.
  • groom::Colliders: the game builds capsules, spheres and boxes on the CPU around the head, shoulders and hats. Those aren't stored with the groom, so the character's own surface points stand in for them: head, body and garments, not hats (they press the hair themselves) and not hair. They sit in a 3 cm grid, and the falloff is 3 cm (not read).
  • Groom::coat_with(share, colliders). coat(share) is unchanged.
  • The viewer builds the colliders with the look, next to the hat shell, and its strand rebuild key includes them.

The pass stays off by default, behind SIXNG_STYLE=<strength>. Renders against the game frames show that the damping holds strands down near the scalp. Even so, at full strength the pass throws strands across the face. With the axes swapped they fan out sideways, and at 0.3 a few strays remain. So the records' frame, or what they are added to, is not settled yet.

Tests: sixng-core 296, sixng-gui 45, sixng-cli 1 pass. The style test now also covers the damping.

**@⁠holdmysocks** on GitHub · 2026-11-25 20:36 UTC · [original](https://github.com/holdmysocks/SixNG/pull/311) `holdmysocks:claude/people-style-damping` → `master` · +104 −11 · 2 files · 78 commits · merged 2026-11-25 20:52 UTC Follow-up to #304: the strand style pass now damps its offsets near the character, the way the game's style pass does. - `Style::apply` takes a per-point weight instead of one strength. The offset length is 0.8 mm + k(|o| - 0.8 mm), with k = min(1 - round(3d)/3, strength) and d = sat(1 - dist/falloff) to the nearest collider. - `groom::Colliders`: the game builds capsules, spheres and boxes on the CPU around the head, shoulders and hats. Those aren't stored with the groom, so the character's own surface points stand in for them: head, body and garments, not hats (they press the hair themselves) and not hair. They sit in a 3 cm grid, and the falloff is 3 cm (not read). - `Groom::coat_with(share, colliders)`. `coat(share)` is unchanged. - The viewer builds the colliders with the look, next to the hat shell, and its strand rebuild key includes them. The pass stays off by default, behind `SIXNG_STYLE=<strength>`. Renders against the game frames show that the damping holds strands down near the scalp. Even so, at full strength the pass throws strands across the face. With the axes swapped they fan out sideways, and at 0.3 a few strays remain. So the records' frame, or what they are added to, is not settled yet. Tests: sixng-core 296, sixng-gui 45, sixng-cli 1 pass. The style test now also covers the damping.
Lookup tables stored as R16F / RG16F / RGBA16F / R32F hold values outside 0..1, which the PNG export clamps and quantises to 8 bits. --float also writes <hash>_m<mip>.f32: little-endian 32-bit floats, every slice of the mip in order, channels interleaved; the JSON result gives width, height, slices and channels.
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.
# Conflicts:
#	crates/sixng-cli/src/main.rs
Not for merge: the lobe shapes are published fits, not the game's tables,
and the colours it is fed are the raw preset colours, which come out
near-black. Waiting for the game's combining formula and the ramp bake.
Not for merge. hairlight loads the four lookup tables with their real
values; the renderer binds them; the mesh shader has the game's light
sum as transcribed from the compiled program (hair_game). With the raw
preset colours and stand-in material values the result is too dark:
waiting for the ramp bake and a check of the transcription.
hairtone: ParamRamp (four numbers and four Bezier curves of the game's
ramp files) and the curve evaluation. Coat ribbons can carry the ramp's
values per vertex; the hair shader takes g0, the unlit-side fill and the
profile scale from them. A research switch gives the strands shown one
ramp of a parsed ramp file, until those files are read from the game.
hairtone: ColourRamp (four stops and a curve) and the game's bake of it.
A research switch gives a character's hair the four ramps of a colour
set of a parsed ramp file, one per strand variant; the atlas colour is
read as gamma-encoded.
Reads each hair item's own layer (mask texture, opacity number) from the
appearance library and paints it into the head's colour texture. The
colour is a stand-in from the hair colour; the game's colour source and
the layer's other numbers and detail textures are not traced.
With the parsed hair LOD presets given, a character's hair pieces draw the
first round(count x share) strands, share from the game's count rule at the
eye-to-piece distance (presets with ThicknessCurveVersion 2 only). A second
research switch widens the strands by 1 / share at one distance, to test
whether the reduced count comes with wider strands.
SIXNG_SHOT_FRAMES=<n> steps the strand dither pattern per frame and saves
the mean of n frames, as the game's per-frame dither is averaged over time.
SIXNG_SHADOWS=1 draws the opaque surfaces and the strands into one depth
map from the sun and lights surfaces and strands through it. A stand-in
for the game's shadow maps: its cascades, bias and filter are not read.
Density from the mask between the layer's two bounds, broken up by the
hex-tiled detail texture turned by the direction map; colour from the
two-colour preset of the item's preset set, slot by slot. Replaces the
gradient stand-in. The strand count rule takes the mean width of the
set's first ramp.
The share now depends on the view's field of view and height, hair pieces
past their cutoff distance are not drawn, and an animal's fur follows the
rule of the version-1 presets. The research widening switch is removed.
Of the strands a piece draws, the first power-of-two share by GILodScale
enters the shadow map as flat ribbons with a random facing per strand,
each widened so the summed width stays. A shadow map of these ribbons
stands in for tracing rays against them. SIXNG_SHADOWS=map keeps the
cascade pass's rule.
An outfit's colour items (tag b28c2b3f: item category, colour set) give
every strand piece of that category its colour set, before the colour the
hair item itself names. Read from the wardrobe data and checked against
game pictures of one character.
With sun shadows on, the scene is drawn depth-only from the eye before the
main pass. Strands lit by the hair program scale their ambient by the
game's openness (16 weighted depth taps around the pixel) times the ramp
profile. Opaque surfaces get a horizon-style occlusion of ambient light,
the viewer's own stand-in for the game's screen-space occlusion.
Two perpendicular slices, two depth taps per side at j^2 R + 1.3 and
(1 + j)^2 R + 1.3 pixels, horizons blended to the tangent plane by the
depth difference in pixel units, the usual horizon integral. Replaces the
viewer's own stand-in. How the game mixes the result into its indirect
light is not read; the viewer scales ambient light by it.
The game's standard lighting uses the horizon pass on reflections, never on
diffuse ambient and never on hair. The viewer scales specular ambient by the
plain visibility (the game's cone test has constants that are not read).
The game's hair program adds its reflection buffer scaled by an environment
Fresnel factor that carries the openness (0.3 + 1.4 o), and keeps 1 - that
factor on the diffuse ambient. The viewer uses its sky along the reflection
about the tube normal and a published fit for the environment table.
strength = max(0, 1 - 2 x roughness): none from roughness 0.5 upward, so
skin reflections are no longer darkened by it.
The game's hair program samples the table at roughness 0.5 + 0.5 (1 - g0).
- Hair ambient: o = sqrt(profile / 15 x openness), as the game's hair
  program has it (an output modifier was missing from the earlier read).
- The hair reflection ambient reads the game's environment table,
  recomputed from its definition at 16 x 16 texel centres, in place of a
  published fit (within 0.01 of the game's sample values).
- Horizon occlusion taps at (j/2)^2 R + 1.3 and ((1 + j)/2)^2 R + 1.3 px.
- Research switch SIXNG_HAIR_GROOMS=slot:offset+offset draws chosen
  strand pieces for a slot.
# Conflicts:
#	crates/sixng-core/src/groom.rs
#	crates/sixng-core/src/pedlook.rs
#	crates/sixng-core/src/wardrobe.rs
#	crates/sixng-gui/src/model_view.rs
#	crates/sixng-gui/src/render3d.rs
#	crates/sixng-gui/src/shader.wgsl
# Conflicts:
#	crates/sixng-gui/src/render3d.rs
#	crates/sixng-gui/src/shader.wgsl
The hair research shadow map moves to frame bindings 19-21 and its items
are renamed sun_map, so master's cascades keep their names and bindings
12-14. The device asks for up to 32 sampled textures per stage: the mesh
shaders now read 17.
Pieces with clump type 1 (system +0x12D) grow one strand per thread: the
thread picks a guide by hash, starts at the guide's root offset by the
clump radius in the root triangle's UV frame (A1 gives the triangle), and
is walked toward the guide's own curve plus the pulled offset. Mode 2 is
unchanged and now shares the member walk.
The game's final gather looks hair up with the strand tangent in place of
the normal, through a plain Lambert lobe. The hair ambient now uses the
viewer's diffuse ambient (sky and ground bounce, or the HDR sky's ambient
cube) around the tangent instead of a sky gradient at the root normal.
# Conflicts:
#	crates/sixng-gui/src/model_view.rs
# Conflicts:
#	crates/sixng-gui/src/shader.wgsl
The game's tiled hair G-buffer resolve takes the position u across the
strand's tube from interleaved gradient noise at the pixel, offset per
frame by 5.58824 (frame & 63), not from the pixel's place in the drawn
ribbon; its temporal anti-aliasing averages that over the tube. Taking
the raster position left a dark half on every 2-pixel ribbon, which read
as fine lines over the hair; with the noise and the shot's accumulation
frames the hair reads smooth.
# Conflicts:
#	crates/sixng-gui/src/render3d.rs
The style records' offsets now take a per-point weight, as the game's
style pass does: d = sat(1 - dist / falloff) to the nearest collider,
rounded to thirds, k = min(1 - round(3d)/3, strength). The character's
own surface points (head, body and garments; not hats or hair) stand in
for the game's CPU-built capsules, spheres and boxes.

The pass stays behind SIXNG_STYLE: even damped it throws strands across
the face at full strength, so the records' frame is not settled yet.
# Conflicts:
#	crates/sixng-core/src/groom.rs
#	crates/sixng-gui/src/model_view.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:26:24 +00:00
github manually merged commit f049693862 into gh-pr/311/base 2026-11-26 20:26:25 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.