code wiki / (root) / nx_cast_shader_lbs_candidate_t181.nx

nx_cast_shader_lbs_candidate_t181.nx

buildroot/runtime/nx_cast_shader_lbs_candidate_t181.nx

137387 B1208 linesdepth 4pulls 4 transitivereach 2 importersview sourcekind librarytopic cast
docsdependenciesstructsconstsfunctions

about

nx_cast_shader_src.nx -- THE CHARACTER CAST VERTEX STAGE, WRITTEN ONCE (gameengine S12c, 2026-09-05). The cast vertex shader that nx_game_page_emit ships as the hand-written GLSL literal MVS (extracted to the board as buildroot/knowledge/compare/cast_mvs_hand.glsl, 2,485 raw / 2,521 expanded / 3,097 canonical tokens) is transcribed here SLICE BY SLICE as shader-IR builder calls, so that BOTH dialects are emitted from one source: GLSL for the WebGL2 door (proven against the hand text by nx_glsl_tokdiff -- an emitted slice is accepted when its canonical token stream is a PREFIX of the hand's up to main's closing brace, slice_prefix=1, and the whole stage when the verdict reads IDENTICAL) and WGSL for the WebGPU door (the S12 cast pipeline). The vocabulary is nx_world_shader_src's ws_* shorthands over nx_shader_ir; nothing here re-implements a builder. RULES THAT KEEP THE CANONICAL FORM REACHABLE: a negative literal is sir_neg over the positive literal ((-999.0), never a "-999.0" literal); every literal is spelled with the hand's own digits, canonically (0.5 not .5, 0.930 not 0.93 -- the ruler canonicalises spelling, never value); a compound assignment is x=(x op (y)); left-associative chains are built left-nested exactly as the grammar parses them; the hand's grouping parentheses are simply the tree's shape. The f32 uniform arrays the hand declares (uOF uGB uGT uGN, float[12]) are declared EXACTLY as the hand does -- the uniform-space stride rule is a WGSL-dialect fact and belongs in the WGSL backend's lowering (S12c-2b), never in this source. SLICES (each measured, journaled on gameengine.plan under GE59): 1 declarations + hsh + the instance/lock prologue (through vII=ii;) -- MEASURED 602/3097 canonical, slice_prefix 2 dual-quaternion skinning off the joint table, garment displacement, the PASS-1 face cut, the y-up rotation and world placement (through vec3 wp=...;) 3 soft-body fields (hb2, sbo over the DYNA anchors, hair wind, dress inheritance, the body branch), wp+=sbo 4 garment degeneration, the cast-shadow projection, vW, the clip transform (gl_Position) license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 1 imports · 1 importers

nx_world_shader_src.nx nx_cast_shader_lbs_candidate_t nx_wgsl_cast_lbs_t181.nx

imports: nx_world_shader_src.nx

imported by: nx_wgsl_cast_lbs_t181.nx

structs

none

consts

none

functions

24func cs_i(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_I32) }
25func cs_fl(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_F32) }
26func cs_v3(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V3F) }
27func cs_v4(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V4F) }
28func cs_f32(m: *i64, e: i64) -> i64 { return sir_cast(m, e, T_F32) }
29func cs_i32(m: *i64, e: i64) -> i64 { return sir_cast(m, e, T_I32) }
31func cs_negf(m: *i64, s: *u8) -> i64 { return sir_neg(m, ws_f(m, s), T_F32) }
33func cs_idx(m: *i64, arr: *u8, ety: i64, i: i64) -> i64 { return sir_index(m, sir_ident(m, arr, ety), i, ety) }
35func cs_ih(m: *i64, sel: *u8) -> i64 { return ws_sw(m, cs_idx(m, "uIH" as *u8, T_V4F, cs_i(m, "ii" as *u8)), sel, T_F32) }
37func cs_sx3(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V3F, sel, T_F32) }
38func cs_sx4(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V4F, sel, T_F32) }
39func cs_xyz(m: *i64, n: *u8) -> i64 { return ws_sx(m, n, T_V4F, "xyz" as *u8, T_V3F) }
40func cs_hsh(m: *i64, e: i64) -> i64 { return ws_c1(m, "hsh" as *u8, e, T_F32) }
called by 1: shsrc_cast_main
41func cs_fadd(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_F32) }
42func cs_fsub(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "-" as *u8, a, b, T_F32) }
43func cs_fmul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_F32) }
44func cs_fdiv(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "/" as *u8, a, b, T_F32) }
45func cs_iadd(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_I32) }
46func cs_isub(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "-" as *u8, a, b, T_I32) }
called by 1: shsrc_cast_main
47func cs_imul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_I32) }
48func cs_idiv(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "/" as *u8, a, b, T_I32) }
called by 1: shsrc_cast_main
49func cs_v3add(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_V3F) }
50func cs_v3sub(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "-" as *u8, a, b, T_V3F) }
51func cs_v3mul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_V3F) }
52func cs_v4add(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_V4F) }
53func cs_v4mul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_V4F) }
54func cs_cross(m: *i64, a: i64, b: i64) -> i64 { return ws_c2(m, "cross" as *u8, a, b, T_V3F) }
55func cs_dot(m: *i64, a: i64, b: i64) -> i64 { return ws_c2(m, "dot" as *u8, a, b, T_F32) }
56func cs_ss(m: *i64, a: i64, b: i64, c: i64) -> i64 { return ws_c3(m, "smoothstep" as *u8, a, b, c, T_F32) }
58func cs_ssl(m: *i64, a: *u8, b: *u8, n: *u8) -> i64 { return cs_ss(m, ws_f(m, a), ws_f(m, b), cs_fl(m, n)) }
61func shsrc_cast_decls(m: *i64) -> i64
called by 1: shsrc_cast_vs
85func shsrc_cast_fn_hsh(m: *i64) -> i64
called by 1: shsrc_cast_vs calls 2: cs_fmulcs_fl
95func cs_jt(m: *i64, sel: *u8, row: *u8) -> i64
100func cs_sign(m: *i64, f: i64, name: *u8, rn: *u8) -> i64
called by 1: cs_slice2 calls 3: cs_dotcs_v4cs_negf
105func cs_blend(m: *i64, q0: *u8, q1: *u8, q2: *u8, q3: *u8) -> i64
113func cs_rot(m: *i64, n: *u8) -> i64
118func cs_yaw(m: *i64, n: *u8) -> i64
124func cs_yup(m: *i64, n: *u8) -> i64
called by 2: cs_slice2cs_lbs_slice calls 1: cs_sx3
131func cs_face_relief(m: *i64, f: i64) -> i64
157func cs_slice2(m: *i64, f: i64) -> i64
228func cs_lbs_column(m:*i64,row:*u8)->i64
235func cs_lbs_slice(m:*i64,f:i64)->i64
265func cs_skin_dispatch(m:*i64,f:i64)->i64
277func cs_sb(m: *i64, k: *u8) -> i64
283func cs_fall(m: *i64, dn: *u8, k: *u8) -> i64
288func cs_dnon(m: *i64, dn: *u8) -> i64 { return ws_cmp(m, ">" as *u8, cs_sx4(m, dn, "w" as *u8), ws_f(m, "0.5" as *u8)) }
called by 3: cs_dnaddcs_thighcs_slice3 calls 1: cs_sx4
290func cs_front(m: *i64) -> i64
called by 1: cs_slice3 calls 4: cs_fsubcs_sscs_negfcs_sx3
294func cs_dnadd(m: *i64, dn: *u8, k: *u8) -> i64
298func cs_thigh(m: *i64, w: *u8) -> i64
305func cs_slice3(m: *i64, f: i64) -> i64
354func cs_ypm(m: *i64, sel: *u8) -> i64 { return cs_sx4(m, "uYPM" as *u8, sel) }
called by 1: cs_slice4 calls 1: cs_sx4
355func cs_res(m: *i64, sel: *u8) -> i64 { return ws_sx(m, "uResM" as *u8, T_V2F, sel, T_F32) }
called by 1: cs_slice4
357func cs_ieq(m: *i64, n: *u8, k: *u8) -> i64 { return ws_cmp(m, "==" as *u8, cs_i(m, n), ws_i(m, k)) }
359func cs_skirt(m: *i64, n: *u8) -> i64
called by 1: cs_slice4 calls 1: cs_ieq
363func cs_gid(m: *i64, arr: *u8) -> i64 { return cs_i32(m, cs_fadd(m, cs_idx(m, arr, T_F32, cs_i(m, "ii" as *u8)), ws_f(m, "0.5" as *u8))) }
called by 1: cs_slice4 calls 4: cs_i32cs_faddcs_idxcs_i
365func cs_degen(m: *i64) -> i64 { return ws_v3(m, ws_f(m, "0.0" as *u8), cs_negf(m, "999.0" as *u8), ws_f(m, "0.0" as *u8)) }
called by 1: cs_slice4 calls 1: cs_negf
368func cs_slice4(m: *i64, f: i64) -> i64
415func shsrc_cast_main(m: *i64) -> i64
469func shsrc_cast_vs(m: *i64) -> i64
484func cs_u(m: *i64, s: *u8) -> i64 { return sir_lit_u(m, s) }
485func cs_v3i(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V3I) }
486func cs_sxi3(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V3I, sel, T_I32) }
487func cs_u32(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_U32) }
488func cs_icmp(m: *i64, op: *u8, n: *u8, k: *u8) -> i64 { return ws_cmp(m, op, cs_i(m, n), ws_i(m, k)) }
489func cs_floor3(m: *i64, e: i64) -> i64 { return ws_c1(m, "floor" as *u8, e, T_V3F) }
492func shsrc_cast_fs_decls(m: *i64) -> i64
called by 1: shsrc_cast_fs
517func shsrc_cast_fs_vxm(m: *i64) -> i64
called by 1: shsrc_cast_fs calls 2: cs_sxi3cs_u
532func shsrc_cast_fs_vmarch(m: *i64) -> i64
565func cs_fs_slice2(m: *i64, f: i64) -> i64
610func cs_gm(m: *i64, k: *u8) -> i64 { return cs_icmp(m, "==" as *u8, "uGM" as *u8, k) }
called by 1: cs_fs_slice3 calls 1: cs_icmp
612func cs_v3l(m: *i64, s: *u8) -> i64 { return ws_v1(m, T_V3F, ws_f(m, s)) }
614func cs_fog(m: *i64, n: *u8) -> i64
619func cs_grade(m: *i64, n: *u8) -> i64
625func cs_sunL(m: *i64, n: *u8, els: i64) -> i64
630func cs_sun0(m: *i64) -> i64 { return ws_c1(m, "normalize" as *u8, ws_v3f(m, "2400.0" as *u8, "2500.0" as *u8, "1400.0" as *u8), T_V3F) }
635func cs_sunvis_decl(m: *i64, sv: *u8) -> i64 { return sir_var(m, sv, T_F32, ws_f(m, "1.0" as *u8)) }
636func cs_sunvis_if(m: *i64, sv: *u8, t: *u8, L: *u8) -> i64
643func cs_sunvis(m: *i64, sv: *u8, t: *u8, L: *u8) -> i64 { return ws_q2(m, cs_sunvis_decl(m, sv), cs_sunvis_if(m, sv, t, L)) }
645func cs_sinfr(m: *i64, e: i64, k: *u8) -> i64 { return ws_c1(m, "sin" as *u8, cs_fmul(m, ws_c1(m, "fract" as *u8, e, T_F32), ws_f(m, k)), T_F32) }
called by 1: cs_fs_slice3 calls 1: cs_fmul
647func cs_kq(m: *i64, sel: *u8) -> i64 { return ws_sx(m, "kq" as *u8, T_V2F, sel, T_F32) }
called by 1: cs_fs_slice3
652func cs_fs_slice3(m: *i64, f: i64) -> i64
710func cs_b(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_BOOL) }
called by 1: cs_fs_slice4
712func cs_pm(m: *i64, n: *u8, bit: *u8) -> i64 { return sir_var(m, n, T_BOOL, ws_cmp(m, "==" as *u8, ws_bin(m, "&" as *u8, cs_i(m, "uGMH" as *u8), ws_i(m, bit), T_I32), ws_i(m, "0" as *u8))) }
called by 1: cs_fs_slice4 calls 1: cs_i
714func cs_h(m: *i64, op: *u8, lit: *u8) -> i64 { return ws_cmp(m, op, cs_fl(m, "h" as *u8), ws_f(m, lit)) }
716func cs_hnip(m: *i64) -> i64 { return ws_cmp(m, "<" as *u8, cs_fl(m, "h" as *u8), cs_fadd(m, cs_fl(m, "uNIP" as *u8), ws_f(m, "0.055" as *u8))) }
718func cs_axb(m: *i64) -> i64 { return ws_cmp(m, "<" as *u8, cs_fl(m, "axb" as *u8), ws_f(m, "15000.0" as *u8)) }
called by 1: cs_fs_slice4 calls 1: cs_fl
720func cs_g3(m: *i64, arr: *u8) -> i64 { return cs_idx(m, arr, T_V3F, cs_i(m, "vII" as *u8)) }
721func cs_gf(m: *i64, arr: *u8) -> i64 { return cs_idx(m, arr, T_F32, cs_i(m, "vII" as *u8)) }
723func cs_vby(m: *i64, op: *u8, e: i64) -> i64 { return ws_cmp(m, op, cs_sx3(m, "vB" as *u8, "y" as *u8), e) }
called by 2: cs_fs_slice4cs_fs_slice5 calls 1: cs_sx3
725func cs_auth0(m: *i64) -> i64 { return cs_icmp(m, "==" as *u8, "uAuth" as *u8, "0" as *u8) }
727func cs_and3(m: *i64, a: i64, b: i64, c: i64) -> i64 { return ws_and(m, ws_and(m, a, b), c) }
728func cs_and4(m: *i64, a: i64, b: i64, c: i64, d: i64) -> i64 { return ws_and(m, cs_and3(m, a, b, c), d) }
called by 2: cs_fs_slice4cs_fs_slice5 calls 1: cs_and3
730func cs_nipband(m: *i64) -> i64 { return ws_cmp(m, "<" as *u8, ws_c1(m, "abs" as *u8, cs_fsub(m, cs_fl(m, "h" as *u8), cs_fl(m, "uNIP" as *u8)), T_F32), ws_f(m, "0.055" as *u8)) }
called by 1: cs_fs_slice4 calls 2: cs_fsubcs_fl
735func cs_fs_slice4(m: *i64, f: i64) -> i64
815func cs_hh(m: *i64, k: *u8) -> i64 { return cs_fmul(m, ws_f(m, k), cs_fl(m, "HH9" as *u8)) }
called by 2: cs_hhfcs_fs_slice5 calls 2: cs_fmulcs_fl
816func cs_hhf(m: *i64, k: *u8) -> i64 { return cs_fmul(m, cs_hh(m, k), cs_fl(m, "fs9" as *u8)) }
called by 1: cs_fs_slice5 calls 3: cs_fmulcs_hhcs_fl
818func cs_erk(m: *i64, k: *u8) -> i64 { return cs_fmul(m, cs_fl(m, "er9" as *u8), ws_f(m, k)) }
called by 2: cs_fs_eyecs_fs_slice5 calls 2: cs_fmulcs_fl
819func cs_ker(m: *i64, k: *u8) -> i64 { return cs_fmul(m, ws_f(m, k), cs_fl(m, "er9" as *u8)) }
called by 2: cs_fs_eyecs_fs_slice5 calls 2: cs_fmulcs_fl
821func cs_sgn(m: *i64) -> i64 { return sir_select(m, ws_cmp(m, ">" as *u8, cs_sx3(m, "vB" as *u8, "x" as *u8), ws_f(m, "0.0" as *u8)), ws_f(m, "1.0" as *u8), cs_negf(m, "1.0" as *u8), T_F32) }
called by 2: cs_fs_eyecs_fs_slice5 calls 2: cs_sx3cs_negf
823func cs_ihv(m: *i64, sel: *u8) -> i64 { return ws_sw(m, cs_idx(m, "uIH" as *u8, T_V4F, cs_i(m, "vII" as *u8)), sel, T_F32) }
called by 1: cs_fs_eye calls 2: cs_idxcs_i
825func cs_anat0(m: *i64, e: i64) -> i64 { return sir_select(m, cs_icmp(m, "==" as *u8, "uAnatM" as *u8, "1" as *u8), ws_f(m, "0.0" as *u8), e, T_F32) }
called by 2: cs_blinkcs_fs_eye calls 1: cs_icmp
835func cs_fs_eye(m: *i64) -> i64
878func cs_fs_slice5(m: *i64, f: i64) -> i64
934func cs_lockhash(m: *i64, a: *u8, b: *u8) -> i64
called by 1: cs_fs_hair_a calls 2: cs_dotcs_fmul
939func cs_chv(m: *i64, sel: *u8) -> i64 { return ws_sw(m, cs_g3(m, "uCH" as *u8), sel, T_F32) }
called by 1: cs_fs_hair_b calls 1: cs_g3
941func cs_lobe(m: *i64, op: *u8, sh1: i64, sh2: i64, b: *u8) -> i64
called by 1: cs_fs_hair_b calls 3: cs_fmulcs_flcs_fdiv
947func cs_1mf(m: *i64) -> i64 { return cs_fsub(m, ws_f(m, "1.0" as *u8), cs_fl(m, "fH8" as *u8)) }
called by 1: cs_fs_hair_b calls 2: cs_fsubcs_fl
950func cs_fs_hair_a(m: *i64) -> i64
979func cs_fs_hair_b(m: *i64) -> i64
1027func cs_fs_hair_c(m: *i64) -> i64
1039func cs_fs_slice6(m: *i64, f: i64) -> i64
1049func cs_fs_flush(m: *i64) -> i64
1073func cs_skin_maps_v1(m: *i64) -> i64
1096func cs_fs_slice7(m: *i64, f: i64) -> i64
1145func cs_fs_inspection_v1(m: *i64, f: i64) -> i64
1162func shsrc_cast_fs_main(m: *i64) -> i64
1202func shsrc_cast_fs(m: *i64) -> i64