Head shape keys: face expression networks as glTF morph targets, viewer Expression panel #438

Manually merged
github merged 15 commits from github-bot/gh-438 into gh-pr/438/base 2026-11-27 03:15:30 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 02:36 UTC · original
holdmysocks:head-morphs-392 → master · +5972 −168 · 35 files · 15 commits · merged 2026-11-27 03:12 UTC

Second half of #392: shape keys on the head meshes.

What the game does

Heads store no morph targets. The game moves a face with a small network per face, run on the GPU. Its inputs are the expression controls; its output is one xyz offset per driven face vertex, added to the vertex after the identity delta.

  • Resources. Two unnamed resources make one network: table-of-contents type 95 (ComputeGraph: op records) and type 114 (ComputeGraphConstants: fp16 weights and index tables).
  • Link to the head. The network is stored under the head drawable's own file name: <head> for LOD0 (5,154 vertices) and <head>_lod1 for LOD1 (1,287 vertices).
  • Ops. The op ids are the executable's op enum: MatMul, Transpose_MatMul, Concat, Slice_Copy, Gather, Place and Place_Add.
  • Linear. There are no activation ops and no biases. So the network is linear, and every control is an exact shape key.
  • Vertex mapping. Stream 8 of a head mesh keeps its bone indices in the low halves, so skinning is unchanged. Its high halves hold the graph vertex of each mesh vertex.

What this adds

  • facegraph.rs:
    • parses a face graph;
    • evaluates its linear map (437 controls × 15,462 outputs in under a second);
    • finds a head's networks through the table-of-contents name ids (Windows x64, like toc);
    • builds morph targets through the stream-8 mapping.
  • Exports. Model and outfit GLB exports of a head carry one glTF morph target per control. They are sparse, named face_000… in extras.targetNames, and import into Blender as shape keys. Lucia's head gets 427 keys and her outfit GLB grows from 3.2 MB to 23.9 MB.
  • Bones. Facial bones stay rigged as before.
  • Viewer.
    • An Expression panel with a slider per control (filter, Reset). It rewrites the mesh's vertices and normals.
    • An --expr face_039=1,… automation flag.
  • Coverage. 147 heads have a named network: story and cutscene characters and both players, with 370–445 controls each.

Checks

  • Unit tests:
    • a synthetic graph through every op the reader runs, including Transpose_MatMul;
    • the stream-8 map;
    • choosing the network that covers the mesh.
  • The Rust evaluator matches a separate Python reference to 4e-9 on Lucia's network.
  • The weight layout, the gather direction and the axis frame were chosen by:
    • mesh smoothness: 0.26 against 0.8–1.8 for the other layouts;
    • left/right mirror pairs of controls.
  • Headless Blender import of Lucia's outfit GLB:
    • one mesh with 427 shape keys;
    • the strongest key (face_039) opens the jaw by 44 mm in the evaluated mesh;
    • renders (EEVEE, GPU) show jaw open, cheek and lip shapes.
  • Viewer on the RTX 4080: --expr face_039=1,face_316=0.6 opens and twists the mouth on Lucia.

Not decoded

  • The controls' real names. No name table was found, and the face setup resources are in no archive. So the keys are named by input index.
  • How facial clips drive the inputs.
  • A second network per character, named like the ped model (294 inputs, 4,675 vertices).
  • Teeth and tongue follow the jaw bone, not the shape keys, so an open-mouth key alone leaves them in place.

Linear: SIX-244

**@⁠holdmysocks** on GitHub · 2026-11-27 02:36 UTC · [original](https://github.com/holdmysocks/SixNG/pull/438) `holdmysocks:head-morphs-392` → `master` · +5972 −168 · 35 files · 15 commits · merged 2026-11-27 03:12 UTC Second half of #392: shape keys on the head meshes. ## What the game does Heads store no morph targets. The game moves a face with a small network per face, run on the GPU. Its inputs are the expression controls; its output is one xyz offset per driven face vertex, added to the vertex after the identity delta. - **Resources.** Two unnamed resources make one network: table-of-contents type 95 (ComputeGraph: op records) and type 114 (ComputeGraphConstants: fp16 weights and index tables). - **Link to the head.** The network is stored under the head drawable's own file name: `<head>` for LOD0 (5,154 vertices) and `<head>_lod1` for LOD1 (1,287 vertices). - **Ops.** The op ids are the executable's op enum: MatMul, Transpose_MatMul, Concat, Slice_Copy, Gather, Place and Place_Add. - **Linear.** There are no activation ops and no biases. So the network is linear, and every control is an exact shape key. - **Vertex mapping.** Stream 8 of a head mesh keeps its bone indices in the low halves, so skinning is unchanged. Its high halves hold the graph vertex of each mesh vertex. ## What this adds - `facegraph.rs`: - parses a face graph; - evaluates its linear map (437 controls × 15,462 outputs in under a second); - finds a head's networks through the table-of-contents name ids (Windows x64, like `toc`); - builds morph targets through the stream-8 mapping. - **Exports.** Model and `outfit` GLB exports of a head carry one glTF morph target per control. They are sparse, named `face_000`… in `extras.targetNames`, and import into Blender as shape keys. Lucia's head gets 427 keys and her outfit GLB grows from 3.2 MB to 23.9 MB. - **Bones.** Facial bones stay rigged as before. - **Viewer.** - An **Expression** panel with a slider per control (filter, Reset). It rewrites the mesh's vertices and normals. - An `--expr face_039=1,…` automation flag. - **Coverage.** 147 heads have a named network: story and cutscene characters and both players, with 370–445 controls each. ## Checks - Unit tests: - a synthetic graph through every op the reader runs, including Transpose_MatMul; - the stream-8 map; - choosing the network that covers the mesh. - The Rust evaluator matches a separate Python reference to 4e-9 on Lucia's network. - The weight layout, the gather direction and the axis frame were chosen by: - mesh smoothness: 0.26 against 0.8–1.8 for the other layouts; - left/right mirror pairs of controls. - Headless Blender import of Lucia's outfit GLB: - one mesh with 427 shape keys; - the strongest key (face_039) opens the jaw by 44 mm in the evaluated mesh; - renders (EEVEE, GPU) show jaw open, cheek and lip shapes. - Viewer on the RTX 4080: `--expr face_039=1,face_316=0.6` opens and twists the mouth on Lucia. ## Not decoded - The controls' real names. No name table was found, and the face setup resources are in no archive. So the keys are named by input index. - How facial clips drive the inputs. - A second network per character, named like the ped model (294 inputs, 4,675 vertices). - Teeth and tongue follow the jaw bone, not the shape keys, so an open-mouth key alone leaves them in place. Linear: SIX-244
Heads store no morph targets: the game moves a face with a small linear
network per face (resource types 95 and 114, stored under the head
drawable's own name). facegraph.rs parses it, evaluates its linear map
and turns it into one morph target per control via the head mesh's
stream-8 mapping. Model and outfit GLB exports of heads carry them as
sparse glTF morph targets (Blender shape keys); the viewer gets an
Expression panel and an --expr automation flag.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:42:26 +00:00
github-bot changed target branch from master to gh-pr/438/base 2026-11-27 03:15:27 +00:00
github manually merged commit 5feab1423c into gh-pr/438/base 2026-11-27 03:15:30 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.