code wiki / (root) / nx_synth_page.nx

nx_synth_page.nx source

↩ module page · 135 lines · 18056 B

1// nx_synth_page.nx -- EMITS the /synth lab page (author-by-organ: the HTML is generated, never hand-shipped). 2// nishifamily.com/synth = the synthetic-humans & creatures lab: the motion-on-demand clips (mannequin + skinned 3// SDF body APNGs), the swap-slot bestiary contact sheet, the critic scorecard, and the honest census standing. 4// Assets referenced RELATIVE (wave.png / wave_photo.png / pioneer.png / variants.png live next to index.html). 5// Static, no JavaScript (APNG autoplays in <img>). Writes knowledge/synth.html; deploy = send to 6// sites/nishifamily/synth/. license_tier: ORIGINAL expect_exit: 0 7import "nx_syscalls.nx" 8const K_MAGIC_3000: i64 = 3000 9 10func pw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } 11func pb(fd: i64, c: i64) -> i64 { let b: *u8 = sys_mmap(1); b[0] = c as u8; sys_write(fd, b, 1); return 0 } 12func sw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 13func swn(v: i64) -> i64 { 14 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 15 var m: i64 = v 16 let d: *u8 = sys_mmap(24); var k: i64 = 0 17 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 18 var j: i64 = k - 1 19 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 20 return 0 21} 22 23func main() -> i64 { 24 let fd: i64 = sys_openat_wr("knowledge/synth.html" as *u8, 0x1a4) 25 if fd < 0 { sw("SYNTH-PAGE: cannot open output\n"); sys_exit(1); return 1 } 26 pb(fd, 60); pb(fd, 33) // "<" "!" 27 pw(fd, "doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\">") 28 pw(fd, "<title>Synth Lab - Nishi</title><style>") 29 pw(fd, "body{margin:0 auto;max-width:900px;padding:36px 18px 70px;background:rgb(21,17,24);color:rgb(234,227,218);font:16px/1.55 system-ui,sans-serif}") 30 pw(fd, "h1{font-family:Georgia,serif;font-weight:600;font-size:1.7rem;margin:0 0 4px}") 31 pw(fd, "h1 em{color:rgb(230,165,130);font-style:normal}") 32 pw(fd, ".sub{color:rgb(160,148,170);margin:0 0 30px;max-width:65ch}") 33 pw(fd, ".eb{font:600 .72rem/1 ui-monospace,monospace;letter-spacing:.13em;text-transform:uppercase;color:rgb(230,165,130);margin:38px 0 10px}") 34 pw(fd, ".card{background:rgb(31,26,36);border:1px solid rgb(55,47,62);border-radius:10px;padding:16px}") 35 pw(fd, ".clips{display:grid;grid-template-columns:1fr 1fr;gap:12px}") 36 pw(fd, "@media(max-width:640px){.clips{grid-template-columns:1fr}}") 37 pw(fd, ".clips img,.sheet img{width:100%;border-radius:6px;background:rgb(12,10,16)}") 38 pw(fd, ".px img{image-rendering:pixelated}") 39 pw(fd, ".clips h3{margin:8px 0 2px;font-size:.95rem}.clips p{margin:0;color:rgb(160,148,170);font-size:.8rem}") 40 pw(fd, ".g{display:inline-block;font:600 .68rem/1 ui-monospace,monospace;padding:4px 8px;border-radius:99px;background:rgb(42,35,49);color:rgb(143,202,138);margin-top:8px}") 41 pw(fd, "table{border-collapse:collapse;width:100%;font-size:.85rem;font-variant-numeric:tabular-nums}") 42 pw(fd, "td,th{padding:8px 10px;border-bottom:1px solid rgb(55,47,62);text-align:left;vertical-align:top}") 43 pw(fd, "th{font:600 .68rem/1.3 ui-monospace,monospace;letter-spacing:.08em;text-transform:uppercase;color:rgb(160,148,170)}") 44 pw(fd, ".mut{color:rgb(160,148,170)}.mono{font:.78rem/1.7 ui-monospace,monospace;color:rgb(160,148,170);word-break:break-all}") 45 pw(fd, "a{color:rgb(230,165,130)}ul{padding-left:1.2em;margin:.3em 0}li{margin:.3em 0}") 46 pw(fd, "</style></head><body>") 47 pw(fd, "<h1>Synth Lab: she asked for a move that did not exist.<br>The system <em>built it, and filmed it.</em></h1>") 48 pw(fd, "<p class=sub>Synthetic humans and creatures, fully sovereign (NishiLang, no third-party encoders): motion-on-demand rendered to browser-native animated PNG, and one recipe system that emits a whole bestiary via swap slots. Everything below was generated by the ecosystem and gate-verified today.</p>") 49 50 // ---- LIVE interactive studio: the controls call /synth/api/* (nx_synth_serve daemon, rendered on demand) ---- 51 pw(fd, "<div class=eb>Try it live - the studio renders on demand</div>") 52 pw(fd, "<div class=card style=\"display:block\"><style>.sctl{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin:2px 0 10px}.sctl input,.sctl select,.sctl button{font:inherit;padding:8px 11px;border-radius:7px;border:1px solid rgb(55,47,62);background:rgb(18,16,25);color:rgb(234,227,218)}.sctl button{background:rgb(230,165,130);color:rgb(27,20,24);border:0;font-weight:600;cursor:pointer}.sctl label{font-size:.78rem;color:rgb(160,148,170)}.sout img{max-width:100%;image-rendering:pixelated;border-radius:6px;background:rgb(12,10,16);margin-top:6px}.sout{min-height:8px}</style>") 53 pw(fd, "<p class=mut style=margin:0_0_4px>Text to motion (neural): a sentence -> a learned perceptron encoder -> motion class -> generated tokens -> the rig -> a fresh clip.</p>") 54 pw(fd, "<div class=sctl><input id=scap value=\"say hello with a wave\" style=flex:1;min-width:220px><button onclick=st2m()>Generate</button></div><div class=sout id=so1></div>") 55 pw(fd, "<p class=mut style=margin:12px_0_4px>Talking avatar (lip-sync): a face that mouths your words (vowels open, plosives shut the lips).</p>") 56 pw(fd, "<div class=sctl><input id=tcap value=\"hello i am a synthetic human\" style=flex:1;min-width:220px><button onclick=talk()>Speak</button></div><div class=sout id=sotk></div>") 57 pw(fd, "<p class=mut style=margin:14px_0_4px>Named move &middot; and a swap-slot creature (choose species, head, ears, tail, build):</p>") 58 pw(fd, "<div class=sctl><select id=smv><option value=1>wave</option><option value=2>cheer</option><option value=3>sway</option><option value=4>kick</option><option value=5>lookaround</option><option value=6>armcircle</option><option value=7>clap</option><option value=8>punch</option><option value=9>bow</option><option value=10>jumping jack</option></select><button onclick=smove()>Play</button>") 59 pw(fd, "<span style=width:14px></span><label>species</label><select id=ssp><option value=0>human</option><option value=1>wolf</option><option value=2>goblin</option></select><label>head</label><select id=shv><option value=0>plain</option><option value=1>horns</option><option value=2>snout</option></select><label>ears</label><select id=sev><option value=1>pointed</option><option value=0>none</option></select><label>tail</label><select id=stv><option value=0>none</option><option value=1>tail</option></select><label>build</label><input id=sbd type=number value=100 min=70 max=140 style=width:64px><label>outfit</label><select id=sof><option value=0>none</option><option value=1>tunic</option><option value=2>robe</option><option value=3>cloak</option><option value=4>armor</option></select><button onclick=svar()>Render</button></div>") 60 pw(fd, "<div class=sout id=so2></div></div>") 61 pw(fd, "<div class=card style=display:block><p class=mut style=margin:0_0_6px><b style=color:#e6a582>Coach</b> - how's your form? An arm-raise, graded. Slide in an elbow-bend error; the coach scores your form and names the off joint (0 error = perfect).</p>") 62 pw(fd, "<div class=sctl><label>elbow error</label><input id=cerr type=range min=0 max=90 value=40 oninput=coach()> <span id=cerrv class=mono>40&deg;</span> <button onclick=coach()>Grade me</button></div>") 63 pw(fd, "<div id=cout class=mono style=font-size:1rem;margin-top:6px></div></div>") 64 pw(fd, "<script>function _sb(el,b){el.innerHTML='<img src='+URL.createObjectURL(b)+'>'}function _sw(el){el.textContent='rendering...'}\n") 65 pw(fd, "function st2m(){var e=document.getElementById('so1');_sw(e);fetch('/synth/api/text2motion',{method:'POST',body:document.getElementById('scap').value}).then(function(r){return r.blob()}).then(function(b){_sb(e,b)}).catch(function(){e.textContent='(offline)'})}\n") 66 pw(fd, "function smove(){var e=document.getElementById('so2');_sw(e);fetch('/synth/api/move?id='+document.getElementById('smv').value).then(function(r){return r.blob()}).then(function(b){_sb(e,b)}).catch(function(){e.textContent='(offline)'})}\n") 67 pw(fd, "function svar(){var e=document.getElementById('so2');_sw(e);var q='sp='+document.getElementById('ssp').value+'&hv='+document.getElementById('shv').value+'&ev='+document.getElementById('sev').value+'&tv='+document.getElementById('stv').value+'&build='+document.getElementById('sbd').value+'&of='+document.getElementById('sof').value;fetch('/synth/api/variant?'+q,{method:'POST'}).then(function(r){return r.blob()}).then(function(b){_sb(e,b)}).catch(function(){e.textContent='(offline)'})}\n") 68 pw(fd, "function talk(){var e=document.getElementById('sotk');_sw(e);fetch('/synth/api/talk',{method:'POST',body:document.getElementById('tcap').value}).then(function(r){return r.blob()}).then(function(b){_sb(e,b)}).catch(function(){e.textContent='(offline)'})}\n") 69 pw(fd, "function coach(){var v=document.getElementById('cerr').value;document.getElementById('cerrv').innerHTML=v+'&deg;';fetch('/synth/api/coach?err='+v).then(function(r){return r.json()}).then(function(d){var g=d.form>=800?'#7ac97a':(d.form>=500?'#e6c85a':'#e68a82');document.getElementById('cout').innerHTML='Form: <b style=color:'+g+'>'+d.form+'/1000</b> &mdash; worst joint: <b>'+d.worst+'</b>'+(d.dev>0?' (off by '+d.dev+')':' &#10003; perfect')}).catch(function(){document.getElementById('cout').textContent='(offline)'})}</script>") 70 71 pw(fd, "<div class=eb>Motion on demand - both clips loop</div><div class=clips>") 72 pw(fd, "<div class=card><img src=/synth/wave.png alt=\"mannequin wave, 16-frame animated PNG\" width=384 height=288>") 73 pw(fd, "<h3>v0 - FK mannequin, the wave</h3><p>A move is DATA (keyframes) -> 17-joint rig -> z-buffered render -> 16-frame APNG.</p><span class=g>nx_motion_video_gate 4/4</span></div>") 74 pw(fd, "<div class=\"card px\"><img src=/synth/wave_photo.png alt=\"skinned SDF body wave\" width=384 height=288 style=image-rendering:pixelated>") 75 pw(fd, "<h3>v0.5 - same move, skinned</h3><p>The continuous smin-fused body posed by the same rig, rendered on the production skin shader (SSS, pores, spec, AO). 128x96 shown 3x - honest pixels.</p><span class=g>nx_motion_photo_gate 4/4</span></div></div>") 76 77 pw(fd, "<div class=eb>One recipe system, twelve creatures - swap-as-data</div>") 78 pw(fd, "<div class=\"card sheet px\"><img src=/synth/variants.png alt=\"12-variant bestiary contact sheet\" width=768 height=432 style=image-rendering:pixelated>") 79 pw(fd, "<p class=mut style=margin:8px_0_0>A variant is a tuple: species x head x ears x tail x build. Row 1: human, horned, beastman (snout+tail), bulk. Row 2: elf (slim, pointy ears), goblin, horned goblin, snouted goblin. Row 3: hobgoblin, wolf, dire wolf (horned, bulk), coyote (slim). 12/12 tiles pairwise distinct; a head-slot-only swap visibly changes the render. <span class=g>nx_assetvariant_gate 4/4</span></p></div>") 80 81 pw(fd, "<div class=eb>Download the bestiary - watertight game assets</div><div class=card>") 82 pw(fd, "<p class=mut style=margin:0_0_8px>The same tuples exported through surface nets as CLOSED, watertight meshes. STL (print-ready) and OBJ (with smooth per-vertex normals - imports clean into Blender / Unity / Godot):</p>") 83 pw(fd, "<p class=mono>STL: <a href=/synth/human.stl download>human</a> - <a href=/synth/elf.stl download>elf</a> - <a href=/synth/goblin.stl download>goblin</a> - <a href=/synth/hobgoblin.stl download>hobgoblin</a> - <a href=/synth/wolf.stl download>wolf</a> - <a href=/synth/direwolf.stl download>direwolf</a></p>") 84 pw(fd, "<p class=mono>OBJ: <a href=/synth/human.obj download>human</a> - <a href=/synth/elf.obj download>elf</a> - <a href=/synth/goblin.obj download>goblin</a> - <a href=/synth/hobgoblin.obj download>hobgoblin</a> - <a href=/synth/wolf.obj download>wolf</a> - <a href=/synth/direwolf.obj download>direwolf</a></p>") 85 pw(fd, "<p class=mono>glTF (.glb, web/engine/VR standard): <a href=/synth/human.glb download>human</a> - <a href=/synth/elf.glb download>elf</a> - <a href=/synth/goblin.glb download>goblin</a> - <a href=/synth/hobgoblin.glb download>hobgoblin</a> - <a href=/synth/wolf.glb download>wolf</a> - <a href=/synth/direwolf.glb download>direwolf</a></p>") 86 pw(fd, "<p class=mut style=margin:8px_0_0>All six closed-manifold (Euler genus-0 band) and geometrically distinct - the swap slots change the MESH, not just the picture. Exports as STL (print), OBJ (+normals) and binary glTF (three.js / Unity / Godot / Blender / VRM foundation). <span class=g>nx_variant_mesh_gate 3/3</span> <span class=g>nx_obj_export_gate 2/2</span> <span class=g>nx_gltf_export_gate 4/4</span></p></div>") 87 88 pw(fd, "<div class=eb>Swap + motion, unified - creatures that move</div>") 89 pw(fd, "<div class=\"card px\" style=display:flex;gap:16px;align-items:center;flex-wrap:wrap>") 90 pw(fd, "<img src=/synth/beastman.png alt=\"horned tailed creature performing a move\" width=256 height=192 style=image-rendering:pixelated;border-radius:6px>") 91 pw(fd, "<p class=mut style=flex:1;min-width:220px;margin:0>The threads converge: one reusable synthetic body, diversified by SWAP SLOTS (horns + ears + tail), given MOTION on the same FK rig and shipped as video. The swap features are BONE-ANCHORED - the horns and ears ride the head as it turns. 43 parts, rendered on the production skin shader. <span class=g>nx_creature_motion_gate 4/4</span></p></div>") 92 pw(fd, "<div class=\"card px\" style=display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin-top:12px>") 93 pw(fd, "<img src=/synth/wolfwalk.png alt=\"wolf walking, diagonal gait, 8-frame animated PNG\" width=288 height=192 style=image-rendering:pixelated;border-radius:6px>") 94 pw(fd, "<p class=mut style=flex:1;min-width:220px;margin:0>And the ANIMALS move too: the bestiary wolf on an 18-joint QUADRUPED rig with a real diagonal walk gait (front-left strides with hind-right; knees bend mid-swing; tail sways). Same skeleton substrate, same shader, proven mechanically - opposing feet displace in opposite directions at peak phase. <span class=g>nx_wolf_walk_gate 4/4</span></p></div>") 95 96 pw(fd, "<div class=eb>Critic scorecard - no self-flattery</div><div class=card><table>") 97 pw(fd, "<tr><th>Render</th><th>Score /1000</th><th>Verdict</th></tr>") 98 pw(fd, "<tr><td>Pioneer body, static, 512x384 (earlier arc)</td><td>62</td><td class=mut>CLAY</td></tr>") 99 pw(fd, "<tr><td>Pioneer body, static, 128x96 (same res as clips)</td><td>218</td><td class=mut>CLAY</td></tr>") 100 pw(fd, "<tr><td>Posed body mid-wave, 128x96</td><td>250</td><td class=mut>CLAY - posing did not collapse quality</td></tr>") 101 pw(fd, "</table><p class=mut style=margin:10px_0_0>The critic (min of fine-detail / structure / chroma, noise-hardened) calls PHOTOREAL at 700. Nothing here is photoreal yet; that is the point of having the critic.</p></div>") 102 103 pw(fd, "<div class=eb>Standing vs the benchmarked state of the art</div><div class=card><table>") 104 pw(fd, "<tr><th>Capability</th><th>Industry SOTA (banked to disk)</th><th>Ours</th></tr>") 105 pw(fd, "<tr><td>Move library as data + want-a-move to video loop</td><td class=mut>Viggle, Kling, Runway, Pika</td><td>HAVE v0</td></tr>") 106 pw(fd, "<tr><td>Part/species swap for asset diversity</td><td class=mut>(game pipelines; neural i2i for images)</td><td>HAVE v0</td></tr>") 107 pw(fd, "<tr><td>Text-to-motion, free-form</td><td class=mut>MDM, T2M-GPT, MoMask</td><td>PARTIAL - parametric recipes</td></tr>") 108 pw(fd, "<tr><td>Pose-driven photoreal human video</td><td class=mut>Animate Anyone, MimicMotion, Champ</td><td>PARTIAL - clay-class SDF body</td></tr>") 109 pw(fd, "<tr><td>Face / clothes / hair swap on images</td><td class=mut>SimSwap, inswapper, IDM-VTON, Barbershop</td><td>GAP - S5 neural rung</td></tr>") 110 pw(fd, "<tr><td>Video diffusion backbone</td><td class=mut>SVD, AnimateDiff, HunyuanVideo</td><td>GAP</td></tr>") 111 pw(fd, "</table><p class=mut style=margin:10px_0_0>Census (liar-killed): 156 permille at benchmark -> 406 after motion shipped -> 468 after the bestiary. 35/34 SOTA sources fetched live to knowledge/fetched/sm_*.raw over the sovereign TLS stack.</p></div>") 112 113 pw(fd, "<div class=eb>What is honestly missing</div><div class=card><ul>") 114 pw(fd, "<li>Photoreal skin and faces on the moving body (critic must cross 700; currently clay).</li>") 115 pw(fd, "<li>Neural free-form text-to-motion (any sentence, any dance) and reference-image-driven video.</li>") 116 pw(fd, "<li>Image-space swapping (face/clothes/hair on generated photos) - the myimg-class suite.</li>") 117 pw(fd, "<li>Texture/UV emit + mesh export wiring for the bestiary variants into game scenes.</li>") 118 pw(fd, "</ul></div>") 119 120 pw(fd, "<div class=eb>Provenance</div>") 121 pw(fd, "<p class=mono>organs: nx_movelib, nx_figure_render, nx_bodypose, nx_apng, nx_assetvariant, nx_creature_motion, nx_quadruped, nx_critvis_lib | gates all GREEN: motion_video 4/4, motion_photo 4/4, assetvariant 4/4, variant_mesh 3/3, creature_motion 4/4, obj_export 2/2, wolf_walk 4/4 | tools registered: move_library, motion_video, asset_variant | sovereign nx_cc to nxasm_x86, no gcc, no 3rd-party encoders.</p>") 122 pw(fd, "<p class=mono>siblings: <a href=/charlab>/charlab</a> <a href=/gpulab>/gpulab</a> <a href=/physlab>/physlab</a> <a href=/gen>/gen</a></p>") 123 pw(fd, "</body></html>") 124 sys_close(fd) 125 126 let lp: *i64 = sys_mmap(16) as *i64 127 let b: *u8 = sys_read_file("knowledge/synth.html" as *u8, lp) 128 if (b as i64) == 0 { sw("SYNTH-PAGE RED: emit unreadable\n"); sys_exit(1); return 1 } 129 let n: i64 = lp[0] 130 sw("emitted knowledge/synth.html bytes="); swn(n); sw("\n") 131 var ok: i64 = 1 132 if n < K_MAGIC_3000 { ok = 0 } 133 if ok == 1 { sw("verdict=GREEN (page emitted by organ; assets: wave.png wave_photo.png variants.png)\n"); sys_exit(0); return 0 } 134 sw("verdict=RED\n"); sys_exit(1); return 1 135}