nx_cast_shader_authored_t55.nx
buildroot/runtime/nx_cast_shader_authored_t55.nx
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
imports: nx_world_shader_src.nx
imported by: nx_wgsl_authored_t55.nx
structs
| none |
consts
| none |
functions
| 24 | func cs_i(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_I32) } |
| 25 | func cs_fl(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_F32) } |
| 26 | func cs_v3(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V3F) } |
| 27 | func cs_v4(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V4F) } |
| 28 | func cs_f32(m: *i64, e: i64) -> i64 { return sir_cast(m, e, T_F32) } |
| 29 | func cs_i32(m: *i64, e: i64) -> i64 { return sir_cast(m, e, T_I32) } |
| 31 | func cs_negf(m: *i64, s: *u8) -> i64 { return sir_neg(m, ws_f(m, s), T_F32) } |
| 33 | func cs_idx(m: *i64, arr: *u8, ety: i64, i: i64) -> i64 { return sir_index(m, sir_ident(m, arr, ety), i, ety) } |
| 35 | func 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) } |
| 37 | func cs_sx3(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V3F, sel, T_F32) } |
| 38 | func cs_sx4(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V4F, sel, T_F32) } |
| 39 | func cs_xyz(m: *i64, n: *u8) -> i64 { return ws_sx(m, n, T_V4F, "xyz" as *u8, T_V3F) } |
| 40 | func cs_hsh(m: *i64, e: i64) -> i64 { return ws_c1(m, "hsh" as *u8, e, T_F32) } called by 1: shsrc_cast_main |
| 41 | func cs_fadd(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_F32) } |
| 42 | func cs_fsub(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "-" as *u8, a, b, T_F32) } |
| 43 | func cs_fmul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_F32) } |
| 44 | func cs_fdiv(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "/" as *u8, a, b, T_F32) } |
| 45 | func cs_iadd(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_I32) } |
| 46 | func 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 |
| 47 | func cs_imul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_I32) } |
| 48 | func 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 |
| 49 | func cs_v3add(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_V3F) } |
| 50 | func cs_v3sub(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "-" as *u8, a, b, T_V3F) } |
| 51 | func cs_v3mul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_V3F) } |
| 52 | func cs_v4add(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "+" as *u8, a, b, T_V4F) } called by 1: cs_blend |
| 53 | func cs_v4mul(m: *i64, a: i64, b: i64) -> i64 { return ws_bin(m, "*" as *u8, a, b, T_V4F) } called by 1: cs_blend |
| 54 | func cs_cross(m: *i64, a: i64, b: i64) -> i64 { return ws_c2(m, "cross" as *u8, a, b, T_V3F) } |
| 55 | func cs_dot(m: *i64, a: i64, b: i64) -> i64 { return ws_c2(m, "dot" as *u8, a, b, T_F32) } |
| 56 | func cs_ss(m: *i64, a: i64, b: i64, c: i64) -> i64 { return ws_c3(m, "smoothstep" as *u8, a, b, c, T_F32) } |
| 58 | func 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)) } |
| 61 | func shsrc_cast_decls(m: *i64) -> i64 called by 1: shsrc_cast_vs |
| 84 | func shsrc_cast_fn_hsh(m: *i64) -> i64 |
| 94 | func cs_jt(m: *i64, sel: *u8, row: *u8) -> i64 |
| 99 | func cs_sign(m: *i64, f: i64, name: *u8, rn: *u8) -> i64 |
| 104 | func cs_blend(m: *i64, q0: *u8, q1: *u8, q2: *u8, q3: *u8) -> i64 |
| 112 | func cs_rot(m: *i64, n: *u8) -> i64 |
| 117 | func cs_yaw(m: *i64, n: *u8) -> i64 |
| 123 | func cs_yup(m: *i64, n: *u8) -> i64 |
| 128 | func cs_slice2(m: *i64, f: i64) -> i64 |
| 198 | func cs_sb(m: *i64, k: *u8) -> i64 |
| 204 | func cs_fall(m: *i64, dn: *u8, k: *u8) -> i64 |
| 209 | func 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)) } |
| 211 | func cs_front(m: *i64) -> i64 |
| 215 | func cs_dnadd(m: *i64, dn: *u8, k: *u8) -> i64 |
| 219 | func cs_thigh(m: *i64, w: *u8) -> i64 |
| 226 | func cs_slice3(m: *i64, f: i64) -> i64 |
| 275 | func cs_ypm(m: *i64, sel: *u8) -> i64 { return cs_sx4(m, "uYPM" as *u8, sel) } |
| 276 | func cs_res(m: *i64, sel: *u8) -> i64 { return ws_sx(m, "uResM" as *u8, T_V2F, sel, T_F32) } called by 1: cs_slice4 |
| 278 | func cs_ieq(m: *i64, n: *u8, k: *u8) -> i64 { return ws_cmp(m, "==" as *u8, cs_i(m, n), ws_i(m, k)) } |
| 280 | func cs_skirt(m: *i64, n: *u8) -> i64 |
| 284 | func 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))) } |
| 286 | func 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)) } |
| 289 | func cs_slice4(m: *i64, f: i64) -> i64 |
| 336 | func shsrc_cast_main(m: *i64) -> i64 |
| 391 | func shsrc_cast_vs(m: *i64) -> i64 |
| 406 | func cs_u(m: *i64, s: *u8) -> i64 { return sir_lit_u(m, s) } |
| 407 | func cs_v3i(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_V3I) } called by 1: shsrc_cast_fs_vmarch |
| 408 | func cs_sxi3(m: *i64, n: *u8, sel: *u8) -> i64 { return ws_sx(m, n, T_V3I, sel, T_I32) } |
| 409 | func cs_u32(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_U32) } |
| 410 | func cs_icmp(m: *i64, op: *u8, n: *u8, k: *u8) -> i64 { return ws_cmp(m, op, cs_i(m, n), ws_i(m, k)) } |
| 411 | func cs_floor3(m: *i64, e: i64) -> i64 { return ws_c1(m, "floor" as *u8, e, T_V3F) } |
| 414 | func shsrc_cast_fs_decls(m: *i64) -> i64 called by 1: shsrc_cast_fs |
| 437 | func shsrc_cast_fs_vxm(m: *i64) -> i64 |
| 452 | func shsrc_cast_fs_vmarch(m: *i64) -> i64 |
| 485 | func cs_fs_slice2(m: *i64, f: i64) -> i64 |
| 530 | func cs_gm(m: *i64, k: *u8) -> i64 { return cs_icmp(m, "==" as *u8, "uGM" as *u8, k) } |
| 532 | func cs_v3l(m: *i64, s: *u8) -> i64 { return ws_v1(m, T_V3F, ws_f(m, s)) } |
| 534 | func cs_fog(m: *i64, n: *u8) -> i64 |
| 539 | func cs_grade(m: *i64, n: *u8) -> i64 |
| 545 | func cs_sunL(m: *i64, n: *u8, els: i64) -> i64 |
| 550 | func 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) } |
| 555 | func cs_sunvis_decl(m: *i64, sv: *u8) -> i64 { return sir_var(m, sv, T_F32, ws_f(m, "1.0" as *u8)) } |
| 556 | func cs_sunvis_if(m: *i64, sv: *u8, t: *u8, L: *u8) -> i64 |
| 563 | func 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)) } |
| 565 | func 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) } |
| 567 | func 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 |
| 572 | func cs_fs_slice3(m: *i64, f: i64) -> i64 |
| 630 | func cs_b(m: *i64, n: *u8) -> i64 { return sir_ident(m, n, T_BOOL) } called by 1: cs_fs_slice4 |
| 632 | func 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))) } |
| 634 | func cs_h(m: *i64, op: *u8, lit: *u8) -> i64 { return ws_cmp(m, op, cs_fl(m, "h" as *u8), ws_f(m, lit)) } |
| 636 | func 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))) } |
| 638 | func cs_axb(m: *i64) -> i64 { return ws_cmp(m, "<" as *u8, cs_fl(m, "axb" as *u8), ws_f(m, "15000.0" as *u8)) } |
| 640 | func cs_g3(m: *i64, arr: *u8) -> i64 { return cs_idx(m, arr, T_V3F, cs_i(m, "vII" as *u8)) } |
| 641 | func cs_gf(m: *i64, arr: *u8) -> i64 { return cs_idx(m, arr, T_F32, cs_i(m, "vII" as *u8)) } |
| 643 | func cs_vby(m: *i64, op: *u8, e: i64) -> i64 { return ws_cmp(m, op, cs_sx3(m, "vB" as *u8, "y" as *u8), e) } |
| 645 | func cs_auth0(m: *i64) -> i64 { return cs_icmp(m, "==" as *u8, "uAuth" as *u8, "0" as *u8) } |
| 647 | func cs_and3(m: *i64, a: i64, b: i64, c: i64) -> i64 { return ws_and(m, ws_and(m, a, b), c) } |
| 648 | func cs_and4(m: *i64, a: i64, b: i64, c: i64, d: i64) -> i64 { return ws_and(m, cs_and3(m, a, b, c), d) } |
| 650 | func 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)) } |
| 655 | func cs_fs_slice4(m: *i64, f: i64) -> i64 |
| 735 | func cs_hh(m: *i64, k: *u8) -> i64 { return cs_fmul(m, ws_f(m, k), cs_fl(m, "HH9" as *u8)) } |
| 736 | func cs_hhf(m: *i64, k: *u8) -> i64 { return cs_fmul(m, cs_hh(m, k), cs_fl(m, "fs9" as *u8)) } |
| 738 | func cs_erk(m: *i64, k: *u8) -> i64 { return cs_fmul(m, cs_fl(m, "er9" as *u8), ws_f(m, k)) } |
| 739 | func cs_ker(m: *i64, k: *u8) -> i64 { return cs_fmul(m, ws_f(m, k), cs_fl(m, "er9" as *u8)) } |
| 741 | func 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) } |
| 743 | func 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) } |
| 745 | func 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) } |
| 747 | func cs_blink(m: *i64, b: *u8, lf: *u8) -> i64 |
| 755 | func cs_fs_eye(m: *i64) -> i64 |
| 798 | func cs_fs_slice5(m: *i64, f: i64) -> i64 |
| 854 | func cs_lockhash(m: *i64, a: *u8, b: *u8) -> i64 |
| 859 | func cs_chv(m: *i64, sel: *u8) -> i64 { return ws_sw(m, cs_g3(m, "uCH" as *u8), sel, T_F32) } |
| 861 | func cs_lobe(m: *i64, op: *u8, sh1: i64, sh2: i64, b: *u8) -> i64 |
| 867 | func cs_1mf(m: *i64) -> i64 { return cs_fsub(m, ws_f(m, "1.0" as *u8), cs_fl(m, "fH8" as *u8)) } |
| 870 | func cs_fs_hair_a(m: *i64) -> i64 |
| 899 | func cs_fs_hair_b(m: *i64) -> i64 |
| 947 | func cs_fs_hair_c(m: *i64) -> i64 |
| 959 | func cs_fs_slice6(m: *i64, f: i64) -> i64 |
| 969 | func cs_fs_flush(m: *i64) -> i64 |
| 994 | func cs_fs_slice7(m: *i64, f: i64) -> i64 |
| 1038 | func shsrc_cast_fs_main(m: *i64) -> i64 |
| 1077 | func shsrc_cast_fs(m: *i64) -> i64 |