nx_nxa_groom.nx
buildroot/runtime/nx_nxa_groom.nx
about
nx_nxa_groom.nx -- GENERATE THE GROOM: full-scalp procedural hair strands written into the
asset's HSTR section, replacing the sampled partial cap that left the back of the head bare
(operator-reported 2026-08-26: "the back of the head is shaved").
INFINIGEN-2 PRINCIPLE, APPLIED (operator standing order: those principles for everything):
hair is GENERATED from parameters and the mesh's own measured geometry -- no groom asset, no
donor, no hand-placed strand. The industry's own groom pipelines (XGen, Ornatrix, Houdini)
are procedural for the same reason: a scalp map plus guide growth beats any sampled cap.
METHOD (every number derived or parameterized, never tasted):
1. Axes derived from vertex extents (the nx_nxa_dyna derivation, same tree of assumptions).
2. HEAD TOP = highest vertex; HEAD CENTER = centroid of verts in the top head band (the
band spans from crown down by a face-height fraction derived from stature).
3. ROOTS: every scalp vertex above the EAR LINE (head centre height) whose radial direction
is not into the face cone, deterministically thinned to <= GRO_MAX_STRANDS with a seeded
hash (Infinigen principle: seeded, reproducible diversity).
4. GROWTH: 8 points per strand (the HSTR contract, NXHCH_W=24 words). Point i steps
seg_len along a direction that starts RADIAL (off the scalp) and blends toward GRAVITY
(down the stature axis) as the strand extends -- long hair hangs, crown hair lifts then
falls, back hair drapes the nape. Length = stature * length_permil / 1000.
5. Writes HSTR via the proven section-replace machinery (nx_nxa_dyna pattern): input never
modified, an existing HSTR is REPLACED, re-runs identical.
usage: nx_nxa_groom <in.nxa> <out.nxa> [length_permil=280] [strands=1400] [seed=7]
exit 0 OK | 2 usage | 3 bad-nxa | 1 io
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_nxa.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 30 | const GR_HDR: i64 = 32 |
| 31 | const GR_TOCE: i64 = 32 |
| 32 | const GR_MAXSEC: i64 = 64 |
| 33 | const GR_MODE: i64 = 0x1a4 |
| 34 | const GR_PTS: i64 = 8 // points per strand == NXHCH_N(7 segments) + 1: the page contract |
| 35 | const GR_WORDS: i64 = 24 // GR_PTS * 3 coords == NXHCH_W: the page contract |
| 36 | const GR_DEF_LEN_PERMIL: i64 = 150 // default hair length as permil of stature: mid-back on a |
| 39 | const GR_DEF_STRANDS: i64 = 4800 // lock granularity for digital-twin density: ~25 follicles per lock against the ~120k human scalp (follicle-count citation to mirror; the RATIO is the parameter) // page samples down to its 900 guides (step floor), so anything |
| 41 | const GR_DEF_SEED: i64 = 7 |
| 45 | const GR_HEADBAND_PERMIL: i64 = 60 |
| 48 | const GR_FACE_PERMIL: i64 = 350 |
| 52 | const GR_SWEEP_Q10: i64 = 700 |
| 55 | const GR_GRAVITY_RAMP_Q10: i64 = 520 |
| 59 | const GR_NAPE_PERMIL: i64 = 45 |
| 61 | const GR_LAYER_Q10: i64 = 300 |
| 64 | const GR_WAVE_STEP_Q10: i64 = 640 |
| 65 | const GR_WAVE_AMP_PERMIL: i64 = 80 |
| 66 | const GR_Q10: i64 = 1024 |
| 72 | const GR_COMB_BACK_Q10: i64 = 358 |
| 73 | const GR_COMB_LIFT_Q10: i64 = 154 |
| 74 | const GR_SYN_SALT_A: i64 = 77 |
| 75 | const GR_SYN_SALT_B: i64 = 177 |
| 76 | const GR_SYN_SALT_M: i64 = 277 |
functions
| 78 | func gr_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 79 | func gr_err(s: *u8) -> i64 { sys_write(2, s, gr_slen(s)); return 0 } |
| 80 | func gr_out(s: *u8) -> i64 { sys_write(1, s, gr_slen(s)); return 0 } |
| 81 | func gr_num(v: i64) -> i64 |
| 94 | func gr_rd64(b: *u8, off: i64) -> i64 called by 1: main |
| 100 | func gr_wr64(b: *u8, off: i64, v: i64) -> i64 called by 1: main |
| 106 | func gr_tageq(b: *u8, off: i64, t: *u8) -> i64 called by 1: main |
| 111 | func gr_isqrt(n: i64) -> i64 called by 1: main |
| 118 | func gr_atoi(s: *u8) -> i64 called by 1: main |
| 125 | func gr_hash(a: i64, b: i64) -> i64 called by 1: main |
| 133 | func main(argc: i64, argv: *i64) -> i64 |