A 3D model pipeline, pushed by GPT-6-Astra

agent

+4:21

The cached body is available, so the study can reuse it without rebuilding the shared data. The garment kit also supports most of the planned outfit. I’m combining a short teal coat, pale loose sleeves, steel and a spear, then checking how they fit and read in the pose.

  • write_stdin, exec_commandpoll session 81751 (+1 more)

    input

    text(await tools.write_stdin({session_id:81751,chars:"",yield_time_ms:1000,max_output_tokens:1500}));
    text(await tools.exec_command({cmd:"rg -n 'save|open\\(|mkdir|write' tools/rig.py tools/plates.py tools/fitting.py tools/vroid_portrait.py | tail -15 && git diff --stat && ls -lh review/out/astra/site | head","max_output_tokens":1800}));
    

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"19384d","wall_time_seconds":0.000003831,"exit_code":1,"original_token_count":38,"output":"page.waitForFunction: Timeout 60000ms exceeded.\n    at ~/work/lowmarch/review/astra/shoot.cjs:18:16 {\n  log: [],\n  name: 'TimeoutError'\n}\n"}{"chunk_id":"343bb5","wall_time_seconds":0.00000436,"exit_code":0,"original_token_count":47,"output":"tools/vroid_portrait.py:1403:        image(c, a.scale).save(a.png)\ntotal 116K\n-rw------- 1 runner runner 110K Nov 15 03:16 index.html\ndrwx------ 4 runner runner 4.0K Nov 15 03:16 vendor\n"}
  • exec_commandsed -n '373,517p' review/vroid-02/index.html && rg -n 'def report|class Body|def worst|def measure' tools/checks.py

    command

    sed -n '373,517p' review/vroid-02/index.html && rg -n 'def report|class Body|def worst|def measure' tools/checks.py

    result, 4 lines

    Script completed
    Wall time 0.1 seconds
    Output:
    {"chunk_id":"f78c22","wall_time_seconds":0.000004261,"exit_code":0,"original_token_count":2668,"output":"  varying vec3 vN; varying vec2 vUv; varying vec3 vView; varying vec3 vObj; varying float vEdge; varying vec4 vPlate;\n  ${HSV}\n  float hash(vec3 p) { p = fract(p * 0.3183099 + 0.1); p *= 17.0; return fract(p.x * p.y * p.z * (p.x + p.y + p.z)); }\n  float vnoise(vec3 x) {\n    vec3 i = floor(x), f = fract(x); f = f * f * (3.0 - 2.0 * f);\n    return mix(mix(mix(hash(i), hash(i + vec3(1,0,0)), f.x), mix(hash(i + vec3(0,1,0)), hash(i + vec3(1,1,0)), f.x), f.y),\n               mix(mix(hash(i + vec3(0,0,1)), hash(i + vec3(1,0,1)), f.x), mix(hash(i + vec3(0,1,1)), hash(i + vec3(1,1,1)), f.x), f.y), f.z);\n  }\n  float toward(float h, float target, float amt) { float d = target - h; d -= floor(d + 0.5); return fract(h + clamp(d, -amt, amt)); }\n  vec3 tone(vec3 base, float hue, float amt, float sMul, float vMul) {\n    vec3 h = rgb2hsv(base);\n    return hsv2rgb(vec3(toward(h.x, hue, amt), clamp(h.y * sMul, 0.0, 1.0), clamp(h.z * vMul, 0.0, 1.0)));\n  }\n  float st(float x, float t) { return smoothstep(t - 0.03, t + 0.03, x); }\n  // Steel and gold. Hard reflection bands (dark below the horizon, a dark core under a white streak)\n  // read well where the surface turns fast: rims, tubes, lames. On a broad plate the reflection\n  // barely changes, so a band there fills the whole plate (the blotches): bands fade by how sharply\n  // the surface curves (normal change per metre on screen), and broad plates get a soft tone that\n  // lightens up each outline plate (hgt: height in the plate 0..1, or -1 without plate data).\n  vec3 metal(bool gold, vec3 base, vec3 n, vec3 v, float lit, float hgt) {\n    vec3 r = reflect(-v, n);\n    float ry = r.y + (vnoise(vObj * vec3(3.0, 14.0, 3.0)) - 0.5) * 0.14;   // jitter the bands along their length, not into blobs\n    float curv = length(fwidth(n)) / max(length(fwidth(vView)), 1e-5);\n    float sharp = smoothstep(5.0, 14.0, curv);\n    // a shaped plate's domes (over the bust, a crowned panel) turn the bands into closed rings: plates\n    // keep only a little of them and take a crisp highlight toward the light instead\n    if (hgt >= 0.0) sharp *= 0.25; else sharp = max(sharp, 0.3);\n    vec3 s0, s1, s2, s3;\n    if (!gold) { s0 = tone(base, 0.68, 0.10, 2.4, 0.32); s1 = tone(base, 0.68, 0.06, 1.7, 0.76);\n                 s2 = tone(base, 0.12, 0.0, 0.8, 0.88); s3 = vec3(0.97, 0.96, 0.92); }\n    else { s0 = vec3(0.30, 0.20, 0.30); s1 = tone(base, 0.20, 0.03, 1.0, 0.72); s2 = base; s3 = tone(base, 0.16, 0.03, 0.5, 1.5); }\n    vec3 hard = mix(s0, s1, st(ry, -0.42));                          // facing down: dark\n    hard = mix(hard, s2, st(ry, -0.08));                             // facing us: the plate's own grey\n    hard = mix(hard, s0, st(ry, 0.36));                              // dark core under the streak\n    hard = mix(hard, s3, st(ry, 0.47));                              // the white streak\n    hard = mix(hard, s2 * 1.06, st(ry, 0.70));\n    float k = smoothstep(-0.55, 0.30, r.y);                          // broad: darker toward the ground (no jitter:\n    if (hgt >= 0.0) k = clamp(k * 0.45 + hgt * 0.80 - 0.18, 0.0, 1.0);   // on a flat plate it streaks)\n    else k = clamp(k * 0.6 + n.y * 0.35 + 0.05, 0.0, 1.0);           // without plate data: lighter facing up\n    vec3 soft = mix(s1 * 0.9, s2, k);\n    float hl = dot(n, normalize(uKey + v));                          // the key's highlight, a hard-edged shape\n    if (hgt >= 0.0) soft = mix(soft, mix(s2, s3, 0.6), st(hl, 0.955) * smoothstep(0.45, 0.8, hgt));   // the upper part only\n    vec3 col = mix(soft, hard, sharp);\n    return mix(col * 0.72 + s0 * 0.28, col, st(lit, 0.30));\n  }\n  void main() {\n    vec4 tex = texture2D(uMap, vUv);\n    if (uAlpha == 1 && tex.a < 0.5) discard;\n    if (uAlpha == 2 && (tex.a < 0.5 || dot(tex.rgb, vec3(1.0 / 3.0)) >= 0.42)) discard;\n    if (uPass == 1) { gl_FragColor = uInfo; return; }\n    vec3 n = normalize(vN); if (!gl_FrontFacing) n = -n;\n    vec3 v = normalize(vView);\n    float lit = dot(n, uKey) * 0.5 + 0.5;\n    if (uShadeOnly == 1) lit = min(lit, 0.37);                        // shadow cards only ever darken skin, to a soft shade\n    else if (uCastOn == 1 && uKind == 1 && int(uInfo.x * 255.0 + 0.5) == 2 && castShadow() > 0.5)\n      lit = min(lit, 0.37);                                           // body skin under the jaw's or the hair's shadow\n    float g1 = vnoise(vObj * 40.0), g2 = vnoise(vObj * 150.0);\n    vec3 col;\n    if (uKind == 0 || uKind == 5 || uKind == 6) {                    // cloth, leather, ground\n      vec3 hb = rgb2hsv(uBase);\n      bool cool = hb.x > 0.42 && hb.x < 0.86;\n      float sh = uKind == 5 ? 0.93 : (cool ? 0.70 : 0.96);\n      float li = cool ? 0.52 : 0.13;\n      vec3 c0 = tone(uBase, sh, 0.09, 1.12, 0.40), c1 = tone(uBase, sh, 0.05, 1.08, 0.64);\n      vec3 c3 = tone(uBase, li, 0.03, 0.80, 1.20);\n      float l = lit + (g1 - 0.5) * uGrain - (uKind == 6 ? 0.22 : 0.0);  // ground: a flat top sits at the base colour\n      col = mix(c0, c1, st(l, 0.30)); col = mix(col, uBase, st(l, 0.50)); col = mix(col, c3, st(l, 0.91));\n      if (uKind == 5) col *= 0.965 + 0.07 * vnoise(vObj * 22.0);       // mottled leather\n    } else if (uKind == 1) {                                           // skin: pale, nearly unshaded from the front\n      vec3 sL = vec3(0.973, 0.882, 0.835), sS = vec3(0.776, 0.659, 0.608), sC = vec3(0.451, 0.322, 0.310);\n      if (uSkinRamp == 1) { sL = uSkinL; sS = uSkinS; sC = uSkinC; }   // the character's tone, designed per tone\n      col = mix(sC, sS, st(lit, 0.20)); col = mix(col, sL, st(lit, 0.38));\n      if (uFaceTex == 1) col *= clamp(tex.rgb / uSkinRef, 0.55, 1.05);\n      if (uFaceTex == 1 && vUv.x > 0.38 && vUv.x < 0.62 && vUv.y > 0.68 && vUv.y < 0.84) {\n        // the closed mouth: VRoid paints a 2-texel line that the clamp above leaves faint; ink it and widen it\n        // (the darkest of a few taps), so it follows the mouth's shape keys as a drawn line\n        float d = 0.0, sl = dot(uSkinRef, vec3(1.0 / 3.0));\n        for (int k = -2; k <= 2; k++) for (int j = -1; j <= 1; j++) {\n          vec3 t = texture2D(uMap, vUv + vec2(float(j) * 1.2, float(k) * 0.8) / 512.0).rgb;\n          d = max(d, 1.0 - dot(t, vec3(1.0 / 3.0)) / sl);\n        }\n        float taper = 1.0 - 0.55 * smoothstep(0.035, 0.065, abs(vUv.x - 0.5));   // a brush stroke: lighter at the corners\n        col = mix(col, vec3(0.42, 0.22, 0.22), smoothstep(0.10, 0.22, d) * taper);\n      }\n      if (uSkinRamp == 0) col *= uSkinTone;                            // older builds: one tint over the light skin\n    } else if (uKind == 2) {                                           // hair: four even bands, hard strand highlights\n      float strand = dot(tex.rgb, vec3(1.0 / 3.0));\n      vec3 c0 = tone(uBase, 0.72, 0.07, 1.10, 0.45), c1 = tone(uBase, 0.72, 0.035, 1.05, 0.68);\n      vec3 c2 = tone(uBase, 0.56, 0.02, 0.92, 1.10), c3 = tone(uBase, 0.56, 0.03, 0.55, 1.42);\n      float l = lit + (strand - 0.6) * 0.12;\n      col = mix(c0, c1, st(l, 0.40)); col = mix(col, uBase, st(l, 0.56)); col = mix(col, c2, st(l, 0.84));\n      float sp = dot(n, normalize(uKey + v)) + (strand - 0.6) * 0.18;\n      col = mix(col, c3, st(sp, 0.90) * (1.0 - st(sp, 0.985)));\n    } else if (uKind == 3 || uKind == 4) {                             // steel, gold\n      bool plate = vPlate.x > 0.5;\n      float e = vPlate.y, w = vPlate.z;\n      bool gilt = uKind == 4 || (plate && w > 0.0 && e < w);            // an outline plate's gold border\n      col = metal(gilt, gilt && uKind == 3 ? uGold : uBase, n, v, lit, plate ? vPlate.w : -1.0);\n      if (plate && w > 0.0) {                                           // engraved lines: one inside the border, one on its seam\n        float aa = fwidth(e) * 1.2 + 1e-5;\n        float l1 = 1.0 - smoothstep(0.0010, 0.0010 + aa, abs(e - (w + 0.0050)));\n        float l2 = 1.0 - smoothstep(0.0006, 0.0006 + aa, abs(e - w));\n        col = mix(col, col * 0.42, max(l1, l2 * 0.8));\n      }\n    } else if (uKind == 7) {                                           // iris\n      float l = dot(tex.rgb, vec3(1.0 / 3.0));\n      col = l < 0.3 ? mix(uEye[0], uEye[1], l / 0.3) : mix(uEye[1], uEye[2], clamp((l - 0.3) / 0.6, 0.0, 1.0));\n    } else if (uKind == 8) { col = tex.rgb; }\n    else if (uKind == 10) {                                            // the open mouth: VRoid's map read as three parts,\n      float lum = dot(tex.rgb, vec3(1.0 / 3.0));                       // teeth (white), tongue (its light pink) and the\n      col = mix(vec3(0.36, 0.11, 0.14), vec3(0.78, 0.38, 0.42), smoothstep(0.53, 0.58, tex.g));   // dark inside\n      col = mix(col, vec3(0.98, 0.96, 0.95), smoothstep(0.80, 0.86, lum));\n    }\n    else { col = uFlat; }\n    if (vPlate.x > 0.5 && vPlate.z > 0.0 && uKind != 3 && uKind != 4) {   // a cloth outline piece's gold border,\n      float e = vPlate.y, w = vPlate.z, aa = fwidth(e) * 1.2 + 1e-5;       // and a fine gold line inside it\n      float band = 1.0 - smoothstep(w - aa, w, e);\n      float l1 = 1.0 - smoothstep(0.0006, 0.0006 + aa, abs(e - (w + 0.0040)));\n      col = mix(col, metal(true, uGold, n, v, lit, -1.0), max(band, l1 * 0.9));\n    }\n    if (uDecal == 1) {                                                 // a design in the piece's own coordinates:\n      vec3 dm = tex.rgb;                                               // R paint, G groove, B gold inlay\n      float pm = smoothstep(0.3, 0.7, dm.r), gm = smoothstep(0.3, 0.7, dm.g), au = smoothstep(0.3, 0.7, dm.b);\n      if (au > 0.0) col = mix(col, metal(true, uGold, n, v, lit, -1.0), au);\n      if (pm > 0.0) {\n        vec3 pc = mix(tone(uMotif, 0.70, 0.05, 1.10, 0.62), uMotif, st(lit, 0.42));\n        col = mix(col, mix(pc, tone(uMotif, 0.56, 0.03, 0.8, 1.25), st(lit, 0.92)), pm);\n      }\n      if (gm > 0.0) col = mix(col, col * 0.30, gm);\n    }\n    if (vEdge > 0.5) {                                                 // the cloth's border band\n      vec3 gd = tone(uBand, 0.20, 0.03, 1.0, 0.72);\n      col = mix(gd, uBand, st(lit, 0.45)); col = mix(col, tone(uBand, 0.16, 0.03, 0.5, 1.45), st(lit, 0.85));\n    }\n    if (uKind <= 6) {\n      vec3 grade = mix(uAmbient, uKeyCol, st(lit, 0.55));\n      col *= uKind == 1 && uSkinRamp == 1 ? mix(vec3(1.0), grade, 0.3) : grade;   // a designed skin ramp takes less of it\n      float fr = pow(1.0 - max(dot(n, v), 0.0), 4.0);\n      float back = clamp(dot(n, normalize(vec3(0.55, 0.45, -0.35))), 0.0, 1.0);\n      col += uRimCol * fr * smoothstep(0.1, 0.5, back);\n      if (uKind != 1) col *= 1.0 + (g2 - 0.5) * 0.06;\n    }\n    gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n  }`;\nconst PAINT_COMP = `\n33:class Body:\n92:    def worst(self, pose, limbs=None):\n110:def report(name, clips, body):\n"}
  • write_stdinpoll session 44458

    input

    text(await tools.write_stdin({session_id:44458,chars:"",yield_time_ms:1000,max_output_tokens:1500}));
    

    result, 4 lines

    Script completed
    Wall time 5.0 seconds
    Output:
    {"chunk_id":"da5fa1","wall_time_seconds":5.000902279,"session_id":44458,"original_token_count":0,"output":""}
  • exec_commandcat > review/astra/page.html <<'HTML'

    command

    cat > review/astra/page.html <<'HTML'
    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="color-scheme" content="light">
    <title>Lowmarch | A separate look</title>
    <style>
    :root{--paper:#f1efe6;--ink:#24383b;--muted:#526366;--line:#c9cec3;--accent:#885139;--panel:#e7e8df}
    *{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--paper);color:var(--ink);font:17px/1.55 system-ui,-apple-system,"Segoe UI",sans-serif}main{max-width:1200px;margin:auto;padding:38px 36px 70px}.byline{font-size:13px;color:var(--muted);margin:0;display:flex;flex-wrap:wrap;gap:6px 22px}.byline strong{font-weight:600}header{padding-bottom:28px;border-bottom:1px solid var(--line)}h1{font:500 clamp(35px,5.4vw,62px)/1.08 Georgia,serif;letter-spacing:-.035em;margin:25px 0 14px}header p:last-child{max-width:710px;font-size:20px;margin-bottom:0}h2{font:500 30px/1.2 Georgia,serif;margin:0 0 20px}h3{font-size:13px;text-transform:uppercase;letter-spacing:.1em;margin:0 0 8px;color:var(--accent)}section{padding:30px 0;border-bottom:1px solid var(--line)}p{margin:0 0 12px}.read{display:grid;grid-template-columns:1fr 1fr;gap:16px 42px}.read p{max-width:60ch;margin:0}.disagree{margin-top:23px;padding:20px 23px;background:var(--panel)}.disagree p{max-width:95ch;margin-bottom:0}.steps{list-style:none;counter-reset:step;margin:0;padding:0;display:grid;gap:11px}.steps li{counter-increment:step;display:grid;grid-template-columns:28px 1fr;gap:11px}.steps li:before{content:counter(step,decimal-leading-zero);font:13px/1.9 ui-monospace,monospace;color:var(--accent)}.steps span{max-width:91ch}figure{margin:0}figure img{width:100%;height:auto;display:block;background:#c9cbbf}figcaption{font-size:14px;color:var(--muted);margin-top:11px;max-width:85ch}.visual-head{display:flex;align-items:baseline;justify-content:space-between;gap:20px}.tag{font-size:12px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}.made{display:grid;grid-template-columns:1fr 1fr;gap:30px;margin-top:23px}.made p{font-size:15px;max-width:65ch;margin:0}details{margin-top:18px;font-size:14px}summary{cursor:pointer;color:var(--muted);width:fit-content}summary:focus-visible,a:focus-visible{outline:2px solid var(--accent);outline-offset:5px}pre{white-space:pre-wrap;overflow-wrap:anywhere;padding:16px;background:var(--panel);font:12px/1.6 ui-monospace,monospace}footer{font-size:12px;color:var(--muted);padding-top:22px;max-width:95ch}a{color:inherit;text-underline-offset:3px}@media(max-width:680px){main{padding:24px 18px 45px}.read,.made{grid-template-columns:1fr;gap:19px}.visual-head{display:block}.visual-head h2{margin-bottom:7px}.tag{display:block;margin-bottom:18px}header p:last-child{font-size:18px}h2{font-size:27px}.disagree{padding:17px}body{font-size:16px}section{padding:25px 0}}
    </style>
    </head>
    <body><main>
    <header>
    <p class="byline"><strong>GPT-6-Astra (gpt-6-astra), effort high</strong><time datetime="2026-11-15">15 November 2026</time></p>
    <h1>Lowmarch, as a whole person.</h1>
    <p>The body pipeline has earned its place. The next test is a dressed, posed character whose parts belong together.</p>
    </header>
    <section aria-labelledby="read"><h2 id="read">My read</h2>
    <div class="read">
    <div><h3>Keep</h3><p>The current bodies, fitted garments, painted renderer and saved comparisons. The body breakthrough and Saber study are evidence that this can make things you like.</p></div>
    <div><h3>What is missing</h3><p>A whole character on the current base. Fourteen bodies and fourteen expressions multiply work before costume, pose and face have agreed on one person.</p></div>
    <div><h3>Drop for the restart</h3><p>Cast-wide fixes, tool shopping and new scores for beauty. Keep checks for holes, fit and unintended changes. A passing measurement cannot approve a face.</p></div>
    <div><h3>Change the unit of work</h3><p>Each session should leave one better whole character. Keep the last accepted image visible. Record your choices in your words, and make the next proposal myself.</p></div>
    </div>
    <div class="disagree"><h3>Where I disagree with the reflection</h3><p>Use the game frame as the main view, plus a second angle for fit. Try a pose before polishing the face. Early options may change several things to make distinct, coherent designs; isolate variables once a direction is chosen. A week can test the workflow, but cannot establish code's artistic ceiling.</p></div>
    </section>
    <section aria-labelledby="next"><h2 id="next">The first session</h2>
    <ol class="steps">
    <li><span><strong>Pick the target.</strong> Your one picture, the first character and what they are doing. Say back three visible traits for you to correct.</span></li>
    <li><span><strong>Frame and pose.</strong> Put one existing body at the intended size. Rough in a stance and the largest outfit shapes.</span></li>
    <li><span><strong>Show two directions.</strong> Complete silhouettes and colour groups. Recommend one. You pick, reject or mark it.</span></li>
    <li><span><strong>Test the pick.</strong> One fitted outfit, one useful pose, one second angle. Fix the largest visible mismatch before face details.</span></li>
    <li><span><strong>Keep the evidence.</strong> Save the accepted image, your words and answer-to-image time. If the improvement is unclear after two rounds, stop and name what remains uncertain.</span></li>
    </ol>
    </section>
    <section aria-labelledby="visual">
    <div class="visual-head"><h2 id="visual">Border warden</h2><span class="tag">One costume and pose study</span></div>
    <figure><img src="warden.png" width="1600" height="1200" alt="A copper-haired border warden in a teal travelling cape, pale sleeves and steel armour, holding a spear on a misty causeway."><figcaption>A proposed direction for this separate look. The character, palette and camera are my choices for the test; they do not set the restart's design.</figcaption></figure>
    <div class="made"><div><h3>Made from the shelf</h3><p>The current strong woman, her AvatarSample face and hair, the garment and armour kits, the rig tools, and a copy of the painted renderer. Headless Chromium. No generated illustration or borrowed reference art.</p></div><div><h3>Change next</h3><p>FINAL_VISUAL_CRITIQUE</p></div></div>
    <details><summary>Commands and time</summary><p style="margin-top:12px">TIMING_TEXT</p><pre>OPENBLAS_NUM_THREADS=1 python3 review/astra/build.py
    python3 review/astra/prepare.py
    NODE_PATH=~/context/sortie-node_modules node review/astra/shoot.cjs</pre></details>
    </section>
    <footer>Based on the repository at a97f25f, its handbook and portrait guide, the 8 November reflection, the handoff and today's render. This is an independent study in the astra worktree. The source assets and the project's other session were not changed.</footer>
    </main></body></html>
    HTML
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    {"chunk_id":"e4a476","wall_time_seconds":0.000003181,"exit_code":0,"original_token_count":0,"output":""}
  • write_stdin, clock__curr_timepoll session 44458 (+1 more)

    input

    text(await tools.write_stdin({session_id:44458,chars:"",yield_time_ms:1000,max_output_tokens:1500}));
    text(await tools.clock__curr_time({}));
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    {"chunk_id":"741b5b","wall_time_seconds":0.000003271,"exit_code":0,"original_token_count":43,"output":"{\"build_seconds\": 40.352, \"body\": \"~/.local/share/lowmarch/vroid/lowmarch_bodies/cage/arm_f_strong_4ad9ea3b57cd9a77.vrm\", \"glb_bytes\": 5552196, \"pieces\": 44}\n"}{"current_time":"2026-11-15 03:18:32 UTC"}
  • exec_commandNODE_PATH=~/context/sortie-node_modules node review/astra/shoot.cjs

    command

    NODE_PATH=~/context/sortie-node_modules node review/astra/shoot.cjs

    result, 4 lines

    Script completed
    Wall time 1.2 seconds
    Output:
    {"chunk_id":"d94cb8","wall_time_seconds":1.001296437,"session_id":3473,"original_token_count":0,"output":""}
  • write_stdinpoll session 3473

    input

    text(await tools.write_stdin({session_id:3473,chars:"",yield_time_ms:1000,max_output_tokens:3000}));
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    {"chunk_id":"d53f18","wall_time_seconds":0.00000276,"exit_code":0,"original_token_count":18,"output":"{ render_seconds: 1.934, errors: [], options: {}, file: 'probe.png' }\n"}
  • view_image~/work/lowmarch/review/out/astra/probe.png

    input

    image((await tools.view_image({path:"~/work/lowmarch/review/out/astra/probe.png"})).image_url);
    

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    
    probe.png
    probe.png
  • exec_commandsed -n '1,200p' tools/plates.py && sed -n '900,944p' tools/outfit.py && sed -n '338,353p' tools/outfit.py && sed -n '355,397p' tools/outfit.py

    command

    sed -n '1,200p' tools/plates.py && sed -n '900,944p' tools/outfit.py && sed -n '338,353p' tools/outfit.py && sed -n '355,397p' tools/outfit.py

    result, 4 lines

    Script completed
    Wall time 0.0 seconds
    Output:
    {"chunk_id":"985639","wall_time_seconds":0.00000385,"exit_code":0,"original_token_count":3862,"output":"\"\"\"Plates drawn as outlines: the armour kit's second generation (portrait guide, lesson 13).\n\nThe first kit builds plate as bands (limb_lames, pauldron lames) or shrink-wraps (the cuirass): fine\nfor stacked lames, but it can't draw a shape. Here a plate is drawn like a pattern piece laid on a\ndress form.\n\nA chart wraps a body region in two coordinates:\n  TorsoChart  u = degrees round the body (0 front, +90 the character's right, 180 back), v = height (m)\n  LimbChart   u = degrees round a bone (0 = `front`), v = fraction along it (0 at the joint)\npoint(u, v) is on the surface the chart covers: a ray out of the chart's axis, at a radius taken from\na field of ray casts that is filled and smoothed (and, as a shell, kept from following hollows), so\nplates come out as shells rather than mouldings of the skin.\n\nA plate is the region between two edge curves over a range of u, bottom(u) and top(u), so its outline\nis exactly the mesh boundary (no jagged clipping) and a pointed waist, a scooped neckline or a pointed\ncuff is one function each. It sits `offset` off the chart, is domed by `crown`, given thickness, and\ncarries per-vertex plate data for the painted renderer:\n  plate = (1, distance to the outline in metres, gold border width in metres, height in the plate 0..1)\nfrom which the shader paints the border, an engraved line inside it, and a top-to-bottom gradient\nso a flat plate doesn't read as one flat value.\n\"\"\"\nimport math\n\nimport numpy as np\nfrom scipy.ndimage import gaussian_filter\nfrom scipy.spatial import cKDTree\n\n\ndef _fill_nan(R, wrap_u=True):\n    \"\"\"Fill missing radii (rays that hit nothing) from their neighbours round u, then along v.\"\"\"\n    R = R.copy()\n    nu, nv = R.shape\n    idx = np.arange(nu)\n    for j in range(nv):\n        col = R[:, j]\n        ok = np.isfinite(col)\n        if ok.sum() >= 2:\n            if wrap_u:\n                xs = np.concatenate([idx[ok] - nu, idx[ok], idx[ok] + nu])\n                R[:, j] = np.interp(idx, xs, np.tile(col[ok], 3))\n            else:\n                R[:, j] = np.interp(idx, idx[ok], col[ok])\n    good = np.isfinite(R).all(0)\n    if not good.any():\n        raise ValueError(\"chart: no ray hit the surface\")\n    for j in range(nv):\n        if not good[j]:\n            k = np.nonzero(good)[0]\n            R[:, j] = R[:, k[np.argmin(np.abs(k - j))]]\n    return R\n\n\nclass _Chart:\n    \"\"\"Shared: a radius field R[u, v] over a grid, sampled bilinearly (u wraps).\"\"\"\n\n    def _setup(self, R, smooth, shell, wrap_u):\n        R = _fill_nan(R, wrap_u)\n        mode = (\"wrap\" if wrap_u else \"nearest\", \"nearest\")\n        if shell:                                      # bridge hollows (between the breasts, the spine)\n            R = np.maximum(R, gaussian_filter(R, (smooth[0] * 3, smooth[1] * 3), mode=mode))\n        self.R = gaussian_filter(R, smooth, mode=mode)\n\n    def radius(self, u, v):\n        u, v = np.broadcast_arrays(np.asarray(u, float), np.asarray(v, float))\n        fu = (u - self.u0) / self.du\n        fv = np.clip((v - self.v0) / self.dv, 0, self.R.shape[1] - 1.000001)\n        nu = self.R.shape[0]\n        if self.wrap:\n            fu = np.mod(fu, nu)\n        else:\n            fu = np.clip(fu, 0, nu - 1.000001)\n        i0 = np.floor(fu).astype(int)\n        i1 = (i0 + 1) % nu if self.wrap else np.minimum(i0 + 1, nu - 1)\n        j0 = np.floor(fv).astype(int)\n        j1 = np.minimum(j0 + 1, self.R.shape[1] - 1)\n        a, b = fu - i0, fv - j0\n        R = self.R\n        return ((R[i0, j0] * (1 - a) + R[i1, j0] * a) * (1 - b) + (R[i0, j1] * (1 - a) + R[i1, j1] * a) * b)\n\n    def point(self, u, v, off=0.0):\n        o, d = self.ray(u, v)\n        return o + d * (self.radius(u, v) + off)[..., None]\n\n    def normal(self, u, v, eu=1.0, ev=None):\n        \"\"\"The chart surface's outward normal (finite differences of point()).\"\"\"\n        ev = self.ev if ev is None else ev\n        pu = self.point(np.asarray(u) + eu, v) - self.point(np.asarray(u) - eu, v)\n        pv = self.point(u, np.asarray(v) + ev) - self.point(u, np.asarray(v) - ev)\n        n = np.cross(pv, pu)\n        _, d = self.ray(u, v)\n        n = np.where((np.einsum(\"...i,...i->...\", n, d) < 0)[..., None], -n, n)\n        return n / np.maximum(np.linalg.norm(n, axis=-1, keepdims=True), 1e-12)\n\n\nclass TorsoChart(_Chart):\n    \"\"\"u = degrees round the vertical axis through (cx, cz) (0 = front, -z; +90 = the character's\n    right, +x), v = height in metres. `over`: the Surface the plates sit on.\"\"\"\n\n    def __init__(self, over, y0, y1, cx=0.0, cz=0.0, du=3.0, dv=0.01, smooth=(1.5, 1.2), shell=True, rmax=0.4):\n        self.cx, self.cz, self.wrap = cx, cz, True\n        self.u0, self.du, self.v0, self.dv, self.ev = -180.0, du, y0, dv, dv * 0.5\n        us = np.arange(-180.0, 180.0, du)\n        vs = np.arange(y0, y1 + dv * 0.5, dv)\n        R = np.full((len(us), len(vs)), np.nan)\n        for i, u in enumerate(us):\n            d = np.array([math.sin(math.radians(u)), 0.0, -math.cos(math.radians(u))])\n            for j, v in enumerate(vs):\n                R[i, j] = over.cast(np.array([cx, v, cz]), d, rmax=rmax, far=True)\n        self._setup(R, smooth, shell, True)\n\n    def ray(self, u, v):\n        u, v = np.broadcast_arrays(np.asarray(u, float), np.asarray(v, float))\n        ur = np.radians(u)\n        d = np.stack([np.sin(ur), np.zeros_like(ur), -np.cos(ur)], -1)\n        o = np.stack([np.full_like(u, self.cx), v, np.full_like(u, self.cz)], -1)\n        return o, d\n\n    def metric(self, u, v):\n        \"\"\"(arc length round the body, height) in metres: distances along the surface for trim.\"\"\"\n        return np.stack([np.radians(u) * self.radius(u, v), np.asarray(v, float) + 0 * np.asarray(u, float)], -1)\n\n    def centre(self, v):\n        return np.array([self.cx, v, self.cz])\n\n\nclass ConeChart(TorsoChart):\n    \"\"\"A TorsoChart whose radius is a function r(u, v) instead of ray casts: a skirt's cone, a\n    plate standing off a skirt. r_fn takes and returns arrays.\"\"\"\n\n    def __init__(self, r_fn, cx=0.0, cz=0.0, ev=0.005):\n        self.cx, self.cz, self.r_fn, self.ev, self.wrap = cx, cz, r_fn, ev, True\n\n    def radius(self, u, v):\n        u, v = np.broadcast_arrays(np.asarray(u, float), np.asarray(v, float))\n        return np.asarray(self.r_fn(u, v), float) + 0 * u\n\n\nclass LimbChart(_Chart):\n    \"\"\"u = degrees round the bone from a to b (0 = toward `front`, +90 = toward front x axis, i.e.\n    the right-handed turn about the bone), v = fraction along it (0 at a, 1 at b; -0.2..1.2 covered).\"\"\"\n\n    def __init__(self, over, a, b, front=(0, 0, -1), du=6.0, dv=0.025, smooth=(1.2, 1.2), shell=True, rmax=0.14,\n                 v_range=(-0.2, 1.2)):\n        self.a, self.b = np.asarray(a, float), np.asarray(b, float)\n        ax = self.b - self.a\n        self.L = float(np.linalg.norm(ax))\n        self.ax = ax / self.L\n        f = np.asarray(front, float) - self.ax * (np.asarray(front, float) @ self.ax)\n        self.f = f / np.linalg.norm(f)\n        self.s = np.cross(self.ax, self.f)\n        self.wrap = True\n        self.u0, self.du, self.v0, self.dv, self.ev = -180.0, du, v_range[0], dv, dv * 0.5\n        us = np.arange(-180.0, 180.0, du)\n        vs = np.arange(v_range[0], v_range[1] + dv * 0.5, dv)\n        R = np.full((len(us), len(vs)), np.nan)\n        for i, u in enumerate(us):\n            ur = math.radians(u)\n            d = self.f * math.cos(ur) + self.s * math.sin(ur)\n            for j, v in enumerate(vs):\n                R[i, j] = over.cast(self.a + self.ax * self.L * v, d, rmax=rmax, far=True)\n        self._setup(R, smooth, shell, True)\n\n    def ray(self, u, v):\n        u, v = np.broadcast_arrays(np.asarray(u, float), np.asarray(v, float))\n        ur = np.radians(u)\n        d = np.cos(ur)[..., None] * self.f + np.sin(ur)[..., None] * self.s\n        o = self.a + self.ax * (self.L * v)[..., None]\n        return o, d\n\n    def metric(self, u, v):\n        return np.stack([np.radians(u) * self.radius(u, v), np.asarray(v, float) * self.L + 0 * np.asarray(u, float)], -1)\n\n    def centre(self, v):\n        return self.a + self.ax * self.L * v\n\n\ndef _thick(G, n, thickness, data, uv):\n    \"\"\"A grid shell (outer face G, inner face G - n*thickness, the four edges closed) with per-vertex\n    plate data and decal coordinates: the inner face copies the outer, edge walls sit at the outline\n    (distance 0).\"\"\"\n    U, V = G.shape[:2]\n    idx = np.arange(U * V).reshape(U, V)\n    a, b, c, d = idx[:-1, :-1], idx[1:, :-1], idx[1:, 1:], idx[:-1, 1:]\n    tri = np.concatenate([np.stack([a, b, c], -1).reshape(-1, 3), np.stack([a, c, d], -1).reshape(-1, 3)])\n    th = np.asarray(thickness, float)\n    outer, inner = G.reshape(-1, 3), (G - n * (th[..., None] if th.ndim else th)).reshape(-1, 3)\n    fn = np.cross(outer[tri[:, 1]] - outer[tri[:, 0]], outer[tri[:, 2]] - outer[tri[:, 0]])\n    if (np.einsum(\"ij,ij->i\", fn, n.reshape(-1, 3)[tri[:, 0]]) < 0).mean() > 0.5:\n        tri = tri[:, ::-1]                             # the outer face winds outward (along the chart normal)\n    mid = (outer.mean(0) + inner.mean(0)) / 2\n    D, UV = data.reshape(-1, 4), uv.reshape(-1, 2)\n    pos, tris, dat, uvs = [outer, inner], [tri, tri[:, ::-1] + U * V], [D, D], [UV, UV]\n    off = 2 * U * V\n    for e in (idx[:, 0], idx[:, -1], idx[0, :], idx[-1, :]):\n        m = len(e)\n        P = np.concatenate([outer[e], inner[e]])\n        k = np.arange(m - 1)\n        t = np.concatenate([np.stack([k, k + 1, m + k + 1], 1), np.stack([k, m + k + 1, m + k], 1)])\n        wn = np.cross(P[t[:, 1]] - P[t[:, 0]], P[t[:, 2]] - P[t[:, 0]])\n        if (np.einsum(\"ij,ij->i\", wn, P[t[:, 0]] - mid) < 0).mean() > 0.5:\ndef sabaton(fit, name, side, role=\"metal\", pad=0.010, ridges=3, seg=26, rows=14):\n    \"\"\"A steel shoe over the whole foot (hides the base model's toes), built as a shoe last from\n    the foot's measurements: sole outline rounded at heel and toe and widest at the ball, top\n    rising from a rounded toe over the instep to the ankle at the heel. Lame ridges follow its\n    cross-section over the instep. Rides the foot bone.\n    (A squashed ellipsoid read as a triangular hoof; a shell projected onto the foot's convex\n    hull creased on the hull's facets.)\"\"\"\n    w = fit.weight((f\"{side}_Foot\", f\"{side}_ToeBase\"))\n    P = fit.pos[w > 0.5]\n    P = P[(P[:, 0] < 0.01) if side == \"L\" else (P[:, 0] > -0.01)]\n    lo, hi = P.min(0), P.max(0)\n    sole = lo[1] - 0.003\n    ankle = fit.bone[f\"J_Bip_{side}_Foot\"][1]\n    z_heel, z_toe = hi[2] + pad, lo[2] - pad                  # the foot points -z\n    width = (hi[0] - lo[0]) + 2 * pad\n    S = np.linspace(0, 1, seg)\n    # centreline: the foot's middle at each station, smoothed\n    cx = np.array([np.median(P[np.abs(P[:, 2] - (z_heel + t * (z_toe - z_heel))) < 0.02, 0])\n                   if (np.abs(P[:, 2] - (z_heel + t * (z_toe - z_heel))) < 0.02).any() else (lo[0] + hi[0]) / 2 for t in S])\n    cx = np.convolve(np.pad(cx, 3, mode=\"edge\"), np.ones(7) / 7, \"valid\")\n    ends = np.sin(np.pi * np.clip(S, 0, 1)) ** 0.42                 # rounds the heel and the toe\n    half_w = width / 2 * ends * (0.80 + 0.20 * np.sin(np.pi * np.clip(S * 1.2, 0, 1)))   # widest at the ball\n    tall = (ankle + 0.02 - sole) * (1 - 0.62 * np.clip((S - 0.25) / 0.6, 0, 1) ** 0.8)   # ankle at the heel, low toe\n    tall = np.maximum(tall * np.sin(np.pi * np.clip(S, 0, 1)) ** 0.22, 0.004)\n    phi = np.linspace(0, np.pi, rows)\n    G = np.zeros((seg, rows, 3))\n    for i, t in enumerate(S):\n        z = z_heel + t * (z_toe - z_heel)\n        G[i] = np.stack([cx[i] + half_w[i] * np.cos(phi), sole + tall[i] * np.sin(phi), np.full(rows, z)], 1)\n    pos, tri = grid_mesh(G)\n    c = np.array([(lo[0] + hi[0]) / 2, sole, (z_heel + z_toe) / 2])\n    pc = piece(name, role, pos, tri, outward_from=c - [0, 0.05, 0])\n    out = [pc]\n    for k, t in enumerate(np.linspace(0.50, 0.74, ridges)):            # lames over the instep\n        i = int(round(t * (seg - 1)))\n        ring = G[i, 1:-1] + np.stack([np.cos(phi[1:-1]), np.sin(phi[1:-1]) * 1.0, np.zeros(rows - 2)], 1) * 0.0018\n        out.append(pipe(f\"{name}_ridge{k}\", role, ring, r=0.0024))\n    for q_ in out:\n        fit.bind(q_, rigid=f\"J_Bip_{side}_Foot\")\n    return out\n\n\ndef knight_dress(fit):\n    \"\"\"A blonde knight-princess: a long blue dress with a white petticoat edge, a fitted steel\n    breastplate, small spaulders, steel gauntlets and armoured boots, a two-handed sword with a\n        d = np.array([math.sin(a), 0, math.cos(a)])\n        front = (1 - math.cos(a)) / 2                       # 0 back .. 1 front\n        base_y = nk[1] - 0.010 - 0.012 * front\n        h = height_back + (height_front - height_back) * front\n        for j, t in enumerate(np.linspace(0, 1, rows)):\n            o = np.array([nk[0], base_y + h * t, nk[2]])\n            r = neck.cast(o, d, rmax=0.2, far=False)\n            r = 0.05 if np.isnan(r) else r\n            P[i, j] = o + d * (r + clear[0] + (clear[1] - clear[0]) * t)\n    pos, tri, outer = thick_grid(P, thickness, outward_from=nk, axis=[0, 1, 0])\n    pc = piece(name, role, pos, tri)\n    t = np.clip((pos[:, 1] - (nk[1] - 0.022)) / height_back, 0, 1)\n    fit.bind(pc, blend={\"J_Bip_C_UpperChest\": 0.5, \"J_Bip_C_Neck\": 0.5})\n    pc[\"W\"][:, 0], pc[\"W\"][:, 1] = 1 - 0.7 * t, 0.7 * t     # base on the chest, top mostly on the neck\n    return pc, outer[:, -1], (outer[0], outer[-1])\n\ndef pauldron(fit, name, role, over, side=\"L\", lames=((0, 62, 0.012, 0.016), (55, 78, 0.010, 0.013),\n             (72, 92, 0.008, 0.011)), spread=135, thickness=0.004, seg=30, rows=7):\n    \"\"\"Overlapping lames over the shoulder. Each lame's shape comes from ray casts out of the\n    deltoid to the surface it covers (`over`: the tunic, plus the cape if it runs under), plus an\n    offset that grows toward the rim. Lower lames tuck under the one above. Open on the neck side.\"\"\"\n    sh = fit.bone[f\"J_Bip_{side}_UpperArm\"]\n    el = fit.bone[f\"J_Bip_{side}_LowerArm\"]\n    down = (el - sh) / np.linalg.norm(el - sh)\n    up = -down\n    sx = -1 if side == \"L\" else 1\n    outw = np.array([sx, 0, 0.0]) - down * (np.array([sx, 0, 0.0]) @ down)\n    outw /= np.linalg.norm(outw)\n    fwd = np.cross(down, outw)\n    fwd = -fwd if fwd[2] > 0 else fwd\n    C = sh + down * 0.015\n    pole = up * math.cos(math.radians(28)) + outw * math.sin(math.radians(28))\n    pole /= np.linalg.norm(pole)\n    e1 = fwd - pole * (fwd @ pole)\n    e1 /= np.linalg.norm(e1)\n    e2 = np.cross(pole, e1)\n    e2 = -e2 if e2 @ outw < 0 else e2\n    ph = np.linspace(-math.radians(spread), math.radians(spread), seg)\n    pieces, rims = [], []\n    for k, (t0, t1, o0, o1) in enumerate(lames):\n        G = np.zeros((seg, rows, 3))\n        for j, th in enumerate(np.radians(np.linspace(t0, t1, rows))):\n            for i, p in enumerate(ph):\n                d = pole * math.cos(th) + math.sin(th) * (e2 * math.cos(p) + e1 * math.sin(p))\n                r = over.cast(C, d, rmax=0.25, far=True)\n                r = 0.06 if np.isnan(r) else r\n                G[i, j] = C + d * (r + o0 + (o1 - o0) * j / (rows - 1))\n        pos, tri, outer = thick_grid(G, thickness, outward_from=C)\n        pc = piece(f\"{name}{k}\", role, pos, tri)\n        if k == 0:\n            fit.bind(pc, blend={f\"J_Bip_{side}_UpperArm\": 0.7, f\"J_Bip_{side}_Shoulder\": 0.3})\n        else:\n            fit.bind(pc, rigid=f\"J_Bip_{side}_UpperArm\")\n        pieces.append(pc)\n        rims.append(outer[:, -1])\n    return pieces, rims\n\n\ndef drape(P0, collide, clearance, pinned, steps=90, iters=10, gravity=0.0025, bend=0.25, closed=False):\n"}
  • exec_commandpython3 - <<'PY'

    command

    python3 - <<'PY'
    p='review/astra/build.py'
    s=open(p).read().replace('import mobs\n','import mobs\nimport plates\n')
    s=s.replace("    out += G.breastplate(fit, coat, y_top=neck[1]-0.085, y_bottom=hips[1]+0.11,\n                        plackart=False, keel=0.006, arm=63)","""    # Broader chart smoothing keeps the cuirass a single shell over the chest.
        torso_chart = G.TorsoChart
        def broad_chart(*args, **kwargs):
            return torso_chart(*args, **dict(kwargs, smooth=(7.0, 5.0)))
        G.TorsoChart = broad_chart
        try:
            out += G.breastplate(fit, coat, y_top=neck[1]-0.085, y_bottom=hips[1]+0.085,
                                plackart=False, keel=0.003, arm=63)
        finally:
            G.TorsoChart = torso_chart""")
    s=s.replace("    out += cuffs\n", """    out += cuffs
        # The wrap makes stockings at the toes; the existing shoe last supplies actual boots.
        for side in 'LR':
            out += O.sabaton(fit, 'warden_shoe_'+side, side, role='boot', pad=0.018, ridges=0)
        foot_y = max(B['J_Bip_L_Foot'][1], B['J_Bip_R_Foot'][1]) + 0.015
        boots['tri'] = boots['tri'][boots['pos'][boots['tri'],1].max(1) > foot_y]
    """)
    s=s.replace("length=2.18,grip=0.77,head=0.32", "length=1.90,grip=0.91,head=0.26")
    s=s.replace("rest={'Fcl_BRW_Angry':0.16}","rest={'Fcl_BRW_Angry':0.20,'Fcl_EYE_Close':0.08}")
    # Save the built portrait so the pose and renderer can be checked without regenerating garments.
    s=s.replace("    size=E.export_skinned", "    import pickle\n    (OUT/'portrait.pkl').write_bytes(pickle.dumps(portrait))\n    size=E.export_skinned")
    open(p,'w').write(s)
    PY
    OPENBLAS_NUM_THREADS=1 python3 review/astra/build.py

    result, 4 lines

    Script completed
    Wall time 1.2 seconds
    Output:
    {"chunk_id":"256586","wall_time_seconds":1.002022228,"session_id":86528,"original_token_count":0,"output":""}