agent

+33:38
reasoning

Lines 141-442 of the specified file have already been reviewed. This portion contains the base64 encoded images. The earlier analysis covered this content. No further inspection of these lines is needed.

  • read_file{"EndLine":380,"Path":"~/context/reflect/lowmarch.html","StartLine":230}

    input

    {
      "EndLine": 380,
      "Path": "~/context/reflect/lowmarch.html",
      "StartLine": 230
    }

    result, 152 lines

    Showing lines 230-380 of 442
    230:   <p class="note"><strong>What I'd keep:</strong> the bodies and their fit checks, VRoid as the base, the painted renderer and its cast chin shadow, regression checks, the Saber armour kit, the one-lash rule, and blind rows.</p>
    231:   <p class="note"><strong>What this rests on:</strong> your typed messages in the two main sessions, the handoff, the portrait guide, commits, the ledger, sheets, and a fresh reader with no stake in the work, whose read I checked and largely agree with. I did not read comments left on review pages. My guess at what you want, for you to correct: a character you'd love, whole, doing something, like Saber, and someone who says plainly how far this goes.</p>
    232: 
    233:   <h2 id="pros">2. How professionals do it</h2>
    234:   <p>Numbers point to sources, read 2026-11-08. <span class="g">guess</span> marks my inference. Gaps: I found no HoYoverse primary source, and no studio publishes hours per character. The Guilty Gear GDC PDF, vroid.com, Polycount and ArtStation refused automated reads. I couldn't confirm the idea in my own lesson 03 that Guilty Gear stores geometry per angle.</p>
    235: 
    236:   <h3>Faces</h3>
    237:   <div class="two">
    238:     <div><h4>What they do</h4><ul>
    239:       <li>Make the three-quarter face work first. Straight-on and pure profile are rare, and if 3/4 works, the angles between tend to.<sup><a href="#s1">1</a></sup></li>
    240:       <li>Four things decide it: the cheek line, brow and eye depth, how far the mouth sits back, the jaw line. The cheek line sets sharp or soft and is called a <q>lifeline</q> for pretty characters.<sup><a href="#s1">1</a></sup></li>
    241:       <li>Common failure: squash the head front to back to slim the 3/4, which gives a <q>festival mask</q>.<sup><a href="#s1">1</a></sup></li>
    242:       <li><q>Breakage can't be avoided</q>, so fix it with bones or shapes.<sup><a href="#s1">1</a></sup> Gakumas has one shape that pushes the nose dot back so it vanishes in profile.<sup><a href="#s9">9</a></sup> Guilty Gear keeps separate battle and close-up heads,<sup><a href="#s3">3</a></sup> and in finishers the rig moves eyes, nose and mouth so the face reads from that one camera.<sup><a href="#s4">4</a></sup></li>
    243:       <li>Expressions don't transfer. Uma Musume authors named presets per character, because parts sit differently.<sup><a href="#s6">6</a></sup></li>
    244:       <li>The drawing is a guide, and copying it exactly isn't the goal.<sup><a href="#s1">1</a></sup> Arc trains new modellers for a year.<sup><a href="#s13">13</a></sup></li>
    245:     </ul></div>
    246:     <div><h4>For us</h4><ul>
    247:       <li><q>Too sharp</q> probably lives in the cheek line. <span class="g">guess</span></li>
    248:       <li>The four moves are small, so code can make them per character at 3/4. <span class="g">guess</span></li>
    249:       <li>One shared expression list is the wrong shape. Every character needs a tuned set, which is why the open mouths look alike.</li>
    250:       <li>If the game shows both battle and dialogue, plan on two faces. <span class="g">guess</span></li>
    251:     </ul></div>
    252:   </div>
    253: 
    254:   <h3>Shading a face so it reads as drawn; outlines</h3>
    255:   <div class="two">
    256:     <div><h4>What they do</h4><ul>
    257:       <li>Quality sits in authored control data, not polygons. Uma Musume: under 20k polygons a character. Its shadow mask, a painted map of where shadow may fall, has the biggest effect on quality and takes most of the texture work. Shape-based shading can't look anime.<sup><a href="#s5">5</a></sup></li>
    258:       <li><q>Where there is no vertex, you can't change the shadow shape.</q> A vertex is a mesh point.<sup><a href="#s1">1</a></sup></li>
    259:       <li>Guilty Gear paints a value on each mesh point: how readily it goes into shadow, and how thick its line is.<sup><a href="#s2">2</a><a href="#s3">3</a></sup></li>
    260:       <li>Normals are the direction a surface claims to face, which decides light or shadow. Faces get them edited by hand; hair and clothes get them copied from simple shapes.<sup><a href="#s1">1</a><a href="#s3">3</a></sup> Outlines keep a separate set.<sup><a href="#s2">2</a><a href="#s5">5</a></sup></li>
    261:       <li>Guilty Gear adjusts each character's light per motion, and per frame in cutscenes.<sup><a href="#s3">3</a></sup> Blue Protocol keeps light to shade at 7:3, because 5:5 went flat in backlight, and cuts the light's angle on skin by half to stop stray face shadows.<sup><a href="#s7">7</a></sup></li>
    262:       <li>Face shadow maps: paint masks at about 9 light angles and merge them. It's a community method, mirrored from one side.<sup><a href="#s10">10</a></sup></li>
    263:       <li>Outlines: a dark inverted copy of the mesh gives per-point control, while screen-wide lines are hard to tune. <q>Not showing lines where unintended</q> matters as much as showing them.<sup><a href="#s2">2</a><a href="#s7">7</a></sup></li>
    264:     </ul></div>
    265:     <div><h4>For us</h4><ul>
    266:       <li>This explains the <q>scar</q>: the shadow's edge followed VRoid's mesh points. <span class="g">guess</span></li>
    267:       <li>All 26 VRoid faces share one texture layout (lesson 29), so one designed shadow mask could serve them all, tuned per character. This is the best cheap next step for faces. <span class="g">guess</span></li>
    268:       <li>Moving light per shot is a cheap cheat once we have shots. <span class="g">guess</span></li>
    269:     </ul></div>
    270:   </div>
    271: 
    272:   <h3>Hair</h3>
    273:   <div class="two">
    274:     <div><h4>What they do</h4><ul>
    275:       <li>Bundles of locks with thickness. A study of 37,000 VRoid styles found 25 to 130 per style.<sup><a href="#s14">14</a></sup></li>
    276:       <li>Start from the drawing's outline and shadow positions. Keep only what's needed, and delete locks that get in the way from other angles.<sup><a href="#s11">11</a></sup> Too many fine strands make posing hard.<sup><a href="#s11">11</a></sup></li>
    277:       <li>Build the inside first, decide the bones then, and add the outer hair last.<sup><a href="#s17">17</a></sup></li>
    278:       <li>Hair can cost as much as the body: Gakumas 23k to 26k polygons, body 25k to 26k.<sup><a href="#s16">16</a></sup></li>
    279:       <li>Motion: root keyed, tip simulated, simulation off for dramatic moments.<sup><a href="#s6">6</a></sup> A hobbyist's settings for long cel hair: high stiffness, no gravity, to hold the drawn shape.<sup><a href="#s18">18</a></sup></li>
    280:     </ul></div>
    281:     <div><h4>For us</h4><ul>
    282:       <li>Our lock kit is the same family as VRoid's, so building hair in code is sound. <span class="g">guess</span></li>
    283:       <li>What's missing is design: a silhouette first, then few big dark shapes before any strands. <span class="g">guess</span></li>
    284:       <li>A dark inner layer is still the fix for the slice.</li>
    285:       <li><strong>Correction:</strong> my 10-31 report said to lay back, then sides, then front. No source here confirms that order.</li>
    286:     </ul></div>
    287:   </div>
    288: 
    289:   <h3>Clothing</h3>
    290:   <div class="two">
    291:     <div><h4>What they do</h4><ul>
    292:       <li>Folds are placed by hand for common poses, exaggerated, with shapes taken from animation rather than life.<sup><a href="#s11">11</a></sup> Revisions moved to pose shapes an animator dials in.<sup><a href="#s12">12</a></sup></li>
    293:       <li>Skirts follow the legs first and sway second. Getting the skin weights right (how much each bone moves each mesh point) beats physics settings.<sup><a href="#s18">18</a><a href="#s22">22</a></sup> Colliders on legs alone fail, and a keep-inside cage works better.<sup><a href="#s19">19</a></sup> VRM now has inside colliders.<sup><a href="#s20">20</a></sup></li>
    294:       <li>Nobody reaches zero clipping. Uma Musume adds special motions for big sleeves.<sup><a href="#s6">6</a></sup> Blue Protocol hides clashing parts.<sup><a href="#s7">7</a></sup> Dark Souls capes <q>intersect pretty much everywhere</q> and <q>nobody really notices</q>.<sup><a href="#s21">21</a></sup></li>
    295:       <li>Real simulation is for big items like capes.<sup><a href="#s21">21</a></sup></li>
    296:       <li>Fabric pattern shows in light and mostly vanishes in shadow.<sup><a href="#s24">24</a></sup></li>
    297:       <li>Armour: only forum evidence found. Why simulated folds look wrong: no source says so outright.</li>
    298:     </ul></div>
    299:     <div><h4>For us</h4><ul>
    300:       <li>Our folds are sine ripples that don't change with pose. A few named fold shapes tied to joint angles would suit code. <span class="g">guess</span></li>
    301:       <li>Our stiff skirt cone is close to the opposite weighting. <span class="g">guess</span></li>
    302:       <li>Grade clipping by what the game camera sees, not by millimetres. <span class="g">guess</span></li>
    303:       <li>Keep our cloth sim for capes only. <span class="g">guess</span></li>
    304:     </ul></div>
    305:   </div>
    306: 
    307:   <h3>VRoid, studios, and where code falls down</h3>
    308:   <div class="two">
    309:     <div><h4>What's known</h4><ul>
    310:       <li><strong>VRoid:</strong> hair guides don't survive export. Files hold merged, baked meshes. No scripting API found, and our driver is blocked by Windows until you allow it (#1105).</li>
    311:       <li><strong>Better base:</strong> none found that ships in a closed game. MB-Lab and CharMorph require AGPL, which can block closed-source games; Ready Player Me ended in January; Character Creator is paid and realistic.<sup><a href="#s32">32</a></sup></li>
    312:       <li><strong>Studios:</strong> modeller, texture artist, rigger, technical artist. A freelance listing prices an anime model at about 195,000 to 295,000 yen over 3 to 4 weeks.<sup><a href="#s31">31</a></sup> My estimate for a hero with rig: 3 to 8 person-weeks. <span class="g">guess</span></li>
    313:       <li><strong>Agents judging looks:</strong> in BlenderGym the best model's error was about 10 times a person's on shape edits and 5 times on geometry. Judging which result was better, the best model agreed with people at 0.66; people agree with each other at 0.79. These are older models.<sup><a href="#s25">25</a></sup></li>
    314:       <li><strong>Agents in Blender:</strong> good at scene work, poor at organic forms, proportion and weights, per mostly vendor reports.<sup><a href="#s29">29</a></sup></li>
    315:       <li><strong>Code-built garments:</strong> about 64 to 72% simulate cleanly, with no fine straps and nothing on armour or anime.<sup><a href="#s27">27</a></sup> Models do far better on a small spec language: 94% vs 65% in one test.<sup><a href="#s26">26</a></sup></li>
    316:       <li><strong>AI-to-3D anime:</strong> fused meshes or research-only weights, all trained on VRoid models.<sup><a href="#s28">28</a></sup></li>
    317:     </ul></div>
    318:     <div><h4>For us</h4><ul>
    319:       <li>Keep VRoid. Keep our spec language small. <span class="g">guess</span></li>
    320:       <li>Have code produce shadow masks, normals and line weights, not more geometry. <span class="g">guess</span></li>
    321:       <li>You stay the eye, but earlier. One CG studio keeps fixing the block model until it reads as the character.<sup><a href="#s30">30</a></sup></li>
    322:       <li><strong>A licence catch:</strong> our sample exports say <code>Redistribution_Prohibited</code>, <code>OnlyAuthor</code>, commercial <code>Disallow</code> inside the file. I checked two. It's probably the export dialog's default, since VRoid Hub lists samples A to C as open. Pixiv's A to Z help page has never been read; it blocks me.</li>
    323:     </ul></div>
    324:   </div>
    325: 
    326:   <h2 id="tools">3. Tools</h2>
    327:   <p><strong>Cost: $0. Nothing here needs buying, and I'd buy nothing yet.</strong> You said on 10-30 you're open to paid extensions. No paid hair tool I found has a documented way to script it, so they only help if someone styles by hand. Versions read 11-08, except where noted.</p>
    328:   <div class="tbl w"><table>
    329:     <thead><tr><th style="width:20%">Free</th><th>What it does</th><th>Suits us?</th><th style="width:19%">Licence, how alive</th><th style="width:10%">Say</th></tr></thead>
    330:     <tbody>
    331:       <tr><td><a href="https://docs.blender.org/manual/en/latest/modeling/geometry_nodes/hair/index.html">Blender 5.2.3 hair nodes</a>, Curve to Tube</td><td>Braid, Curl, Frizz, Clump; tube meshes ready for textures</td><td>Yes. Scriptable, already installed, no install needed</td><td>GPL. LTS to Jul 2028</td><td><span class="tag yes">try</span></td></tr>
    332:       <tr><td>VRoid Studio</td><td>Face and hair editor. Its sliders keep a face coherent, and it's the only source of mature faces</td><td>By hand, or through our driver once you allow it</td><td>Free; game use allowed per 10-09 notes. v2.14, Jun 2026</td><td><span class="tag yes">use</span></td></tr>
    333:       <tr><td><a href="https://github.com/pixiv/three-vrm">three-vrm</a></td><td>The standard VRM renderer</td><td>Cross-check our models outside our own renderer</td><td>MIT. 3.5.5, Jul 2026</td><td><span class="tag yes">use</span></td></tr>
    334:       <tr><td><a href="https://github.com/mikedh/trimesh">trimesh</a>, <a href="https://github.com/KhronosGroup/glTF-Validator">glTF-Validator</a></td><td>Ray and mesh checks; export file check</td><td>Yes, for clipping checks and an export gate</td><td>MIT; Apache-2.0</td><td><span class="tag yes">use</span></td></tr>
    335:       <tr><td><a href="https://github.com/saturday06/VRM-Addon-for-Blender">VRM Add-on for Blender</a></td><td>VRM in and out of Blender, by script</td><td>Only if the Blender trial earns its place. Installing it needs your go</td><td>MIT or GPL-3. 4.10.4, 4 Nov 2026</td><td><span class="tag later">later</span></td></tr>
    336:       <tr><td>Blender 5.2 Cloth and Hair Dynamics nodes</td><td>Node-based physics</td><td>One skirt trial, only if a rigged skirt fails. Marked experimental</td><td>GPL. In our copy</td><td><span class="tag later">later</span></td></tr>
    337:       <tr><td><a href="https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_springBone-1.0">VRM 1.0 capsule colliders</a>, spring limits</td><td>Fewer collision spheres, possibly less hair through bodies. We're on VRM 0.0</td><td>A half-day test. Low urgency</td><td>Open spec. Limits landed Oct 2026, not ratified</td><td><span class="tag later">later</span></td></tr>
    338:       <tr><td>Our own shadow-map bake</td><td>A clean face shadow that moves with the light</td><td>No free Python baker found. QuickSDFTool is Unreal-only. Write it in numpy if a mask isn't enough</td><td>Ours</td><td><span class="tag later">later</span></td></tr>
    339:       <tr><td><a href="https://github.com/maria-korosteleva/GarmentCode">GarmentCode</a></td><td>Sewing patterns from code</td><td>Ideas only. One garment averages 30k triangles, more than a whole Uma Musume character</td><td>MIT. 2.0.1, 2024</td><td><span class="tag later">ideas</span></td></tr>
    340:     </tbody>
    341:   </table></div>
    342:   <p class="note"><strong>Rejected, free:</strong> official Blender MCP (running Blender by script is simpler); mcp-for-blender (four security flaws reported by a third party); UniRig (we have a rig); Abnormal (hand tool); CATS (on life support); Goo Engine (doesn't reach three.js); lilToon, Poiyomi, Unity Toon Shader (Unity only, read them for technique); MB-Lab and CharMorph (AGPL); StdGEN and CharacterGen (see above).</p>
    343:   <div class="tbl w"><table>
    344:     <thead><tr><th style="width:27%">Paid, all on hold</th><th style="width:22%">Cost</th><th>Why hold</th></tr></thead>
    345:     <tbody>
    346:       <tr><td><a href="https://superhivemarket.com/products/stylized-hair-pro">Stylized Hair PRO</a></td><td>$22, MIT (read 10-31)</td><td>The first buy if you want hair styled by hand. Anime locks, braids, curls. No scripting. A separate build per Blender version.</td></tr>
    347:       <tr><td><a href="https://bartoszstyperek.gumroad.com/l/hairtool">Hair Tool 4</a>, <a href="https://superhivemarket.com/products/anime-hair-maker">Anime Hair Maker</a></td><td>$52; $25 to $27 (read 10-31)</td><td>Hand tools. Stylized Hair PRO comes first.</td></tr>
    348:       <tr><td>Marvelous Designer</td><td>$39 a month or $280 a year</td><td>Hand tool for simulated clothes. I found no confirmed way to script it.</td></tr>
    349:       <tr><td>Lightning Boy, Anime Shading Plus, Character Creator 5</td><td>$30+; $30; $299</td><td>Blender 3.4 only per its listing; Unity; realistic and hand-driven.</td></tr>
    350:     </tbody>
    351:   </table></div>
    352: 
    353:   <h2 id="forward">4. How to move forward</h2>
    354:   <div class="box"><p style="margin:0"><strong>Restart on one whole character in one game frame. Everything else waits.</strong> Cost: $0, about 10 minutes of your time on most days.</p></div>
    355: 
    356:   <h3>What I'd change</h3>
    357:   <ol>
    358:     <li><strong>One whole character first:</strong> dressed, moving, in the frame the player sees. Range comes after. Saber is what won you over, and it was a whole person.</li>
    359:     <li><strong>Big shapes before detail.</strong> You approve hair and outfit as flat shapes, plus the light and dark pattern, before any fine work.</li>
    360:     <li><strong>You choose between rows.</strong> Two to four options beside your references, blind when it matters. You point, and I work out why.</li>
    361:     <li><strong>Per-character work over global fixes:</strong> a tuned expression set and a designed shadow mask per character, and hair designed from a silhouette.</li>
    362:     <li><strong>Study first, test the same day.</strong> One look at how it's done before the first build of anything new, and every piece of research ends in a test on our model.</li>
    363:     <li><strong>I hold the map.</strong> One short page: the target, this week, what's parked. And each week one plain line: how far we are, and whether I still think this route gets there.</li>
    364:     <li><strong>Two rounds on one complaint with no visible change, and I stop and say so.</strong></li>
    365:   </ol>
    366: 
    367:   <h3>What I'd ask you, one at a time</h3>
    368:   <div class="tbl w"><table>
    369:     <thead><tr><th style="width:52%">Question</th><th>What I'd assume if you have no strong view</th></tr></thead>
    370:     <tbody>
    371:       <tr><td>What do you wish ours looked like now? Five images.</td><td>Yin and Yang for faces, Unicorn Overlord for costume. Your reference moved, and I never asked.</td></tr>
    372:       <tr><td>What does the player actually see? Camera and size, in battle and in dialogue.</td><td>A side-view battle frame, plus one dialogue close-up.</td></tr>
    373:       <tr><td>Who's the first character, and what are they doing?</td><td>An original swordswoman on the slender body, in the Saber armour kit, doing one attack. Saber was the high point, and the kit exists.</td></tr>
    374:       <tr><td>What's this for: a game you'll ship, or finding how far a model can go?</td><td>Both, with the second driving. It changes what "done" means.</td></tr>
    375:       <tr><td>Is model-only part of the point, or would a person's eye on key decisions be welcome, if free?</td><td>Model-only for week one. No money implied.</td></tr>
    376:       <tr><td>Could you open pixiv's AvatarSample A to Z help page by hand? It blocks me, and we need it before anything ships.</td><td>Not urgent, but nobody has read it.</td></tr>
    377:     </tbody>
    378:   </table></div>
    379:   <p class="note">Small ones still waiting: the old man's fangs (I'd remove them), and allowing the VRoid driver through Windows (#1105), which any mature face needs.</p>
    380:

agent

+33:46
reasoning

Initial assessment: ~/out/index.html offers an opportunity for improved design. The existing lowmarch.html provides a strong stylistic foundation with its CSS variables and clean structure. The goal is to extend that aesthetic.

Running the Pass 2 battle frame build and headless WebGL render now; I will inspect the output as soon as the task completes.

  • resultCommand exited with code 0.
    Command exited with code 0.
    
    Command output:
    wrote ~/work/lowmarch/review/out/slice/battle_frame.png (build 239.1s, render 15.1s, total 254.2s)
    
    Log: file://~/.gemini/antigravity-cli/brain/d3ac2d6a-0d1c-453a-9076-391f374ef486/.system_generated/tasks/task-173.log

agent

+37:29
reasoning

The task completed successfully, generating the expected output image. Will now inspect the generated image to verify that the output is as expected.

  • read_file{"Path":"~/work/lowmarch/review/out/slice/battle_frame.png"}

    input

    {
      "Path": "~/work/lowmarch/review/out/slice/battle_frame.png"
    }

    result, 1 line

    Showing binary file of type image/png
    step_183_media_0.jpg
    step_183_media_0.jpg

agent

+37:38
reasoning

Pass 2 is a significant improvement, particularly with the armor details of Valen and Korin. The revised textures and forms are much more appealing. Next, the focus will be on further refining the visual elements.

The initial assessment highlights discrepancies in Valen's cape color and Korin's cape clipping. Examining the rendering process reveals that the cape's material assignment might be incorrect. The export_glb script's handling of roles and palettes will be analyzed to trace the source of the color mismatch. Further investigation is needed to determine how the paint and role attributes are influencing the final output.

Valen's cape color discrepancy stems from the export_glb script's palette handling, specifically the missing "cape" role. Korin's crimson cape is correctly rendered because the "signature" role is present in the palette. This also shows how the model is constructed.

Korin's shoulder poking through the cape suggests that the gambeson_sleeve_L0 component is missing from the cape_under merge, leading to vertex clipping during arm movement. The influence of the phi parameter in O.cape warrants closer inspection to understand how it impacts shoulder wrap. Examining the characters' feet is the next logical step.

Valen's foot issue arises from the sabaton's padding value causing Z-fighting with the underlying boots. The sabaton wraps the foot, intersecting with the boots due to mismatched padding. Adjusting the sabaton padding should resolve the issue, as demonstrated by Korin's clean boot rendering where the padding value provides complete coverage.

Valen's boot issue stems from padding discrepancies between the sabaton and the boots. Matching the padding values, specifically by setting sabaton's padding to match Korin's boot padding, should resolve the Z-fighting. Examining Korin's clean boot rendering provides a valid solution as a reference for Valen's footwear.

The heater shield's concave orientation is the result of the viewing angle and the back face being visible. Rotating the lower arm correctly orients the chevron, but the concave side is still visible because the shield's back face is facing forward.

The heater shield's concave orientation is due to the back face being visible, not a rotation issue. The steel boss is on the opposite side of the shield relative to the arm's lat axis, explaining why it is hidden. The initial forearm's forward-left orientation with a 0° rotation placed the lat axis down-left-backward, showing the shield's back. Adjusting the rotation to -55° positions the convex front, with the steel boss, in front of the arm, fully obscuring the hand.

The shield's orientation relative to the arm can be precisely verified through direct coordinate printing to confirm the shield normal's direction. An examination of Korin's waist reveals that the wing-bar bug is resolved, but the belt is missing. The brigandine_front component is rendered at the hip level, with an offset outside the expected belt placement. The riveted_vest material's name, defaulted to "coat" instead of "brigandine_front", may be the cause of the missing belt.

  • read_file{"EndLine":620,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":560}

    input

    {
      "EndLine": 620,
      "Path": "~/work/lowmarch/tools/outfit.py",
      "StartLine": 560
    }

    result, 62 lines

    Showing lines 560-620 of 1272
    560:     n = np.cross(t0, [0, 1, 0])
    561:     if np.linalg.norm(n) < 1e-6:
    562:         n = np.cross(t0, [1, 0, 0])
    563:     n /= max(np.linalg.norm(n), 1e-9)
    564:     N = np.zeros_like(C)
    565:     for i in range(len(C)):                      # parallel transport: the tube doesn't twist
    566:         n = n - t[i] * (n @ t[i])
    567:         n /= max(np.linalg.norm(n), 1e-9)
    568:         N[i] = n
    569:     B = np.cross(t, N)
    570:     ang = np.linspace(0, 2 * math.pi, seg + 1)
    571:     P = C[:, None] + r * (np.cos(ang)[None, :, None] * N[:, None] + np.sin(ang)[None, :, None] * B[:, None])
    572:     pos, tri = grid_mesh(P)
    573:     nrm = ((P - C[:, None]) / r).reshape(-1, 3)
    574:     if (vertex_normals(pos, tri) * nrm).sum(1).mean() < 0:
    575:         tri = tri[:, ::-1]
    576:     return piece(name, role, pos, tri, nrm=nrm)
    577: 
    578: 
    579: def limb_surface(fit, bones, side=None):
    580:     """The skin of one limb (bones matched by name), optionally only one side of the body, so ray
    581:     casts out of a bone can't reach the torso or the other limb."""
    582:     T = fit.tris_for(bones, min_w=0.35)
    583:     if side:
    584:         cx = fit.pos[T][:, :, 0].mean(1)
    585:         T = T[cx < 0.01] if side == "L" else T[cx > -0.01]
    586:     return Surface(fit.pos, T)
    587: 
    588: 
    589: def side_of(pc, side):
    590:     """A piece's triangles on one side of the body (the character's left is -x)."""
    591:     cx = pc["pos"][pc["tri"]][:, :, 0].mean(1)
    592:     return Surface(pc["pos"], pc["tri"][cx < 0.0] if side == "L" else pc["tri"][cx > 0.0])
    593: 
    594: 
    595: def limb_lames(fit, name, role, over, top, bottom, lames, arc=(-180, 180), front=(0, 0, -1), thickness=0.0035,
    596:                seg=30, rows=5, rmax=0.13):
    597:     """Bands of plate around a limb: each lame covers fractions (s0, s1) of the segment top->bottom
    598:     and sits off `over` (ray cast out of the bone axis) by an offset that grows toward its lower
    599:     rim. Lames are stacked like roof tiles: the upper one's rim sits outside the next one's top.
    600:     arc: degrees around the limb that the plate covers (0 = front, + toward the character's right)."""
    601:     top, bottom = np.asarray(top, float), np.asarray(bottom, float)
    602:     ax = bottom - top
    603:     L = np.linalg.norm(ax)
    604:     ax /= L
    605:     f = np.asarray(front, float) - ax * (np.asarray(front, float) @ ax)
    606:     f /= np.linalg.norm(f)
    607:     sd = np.cross(ax, f)
    608:     ph = np.radians(np.linspace(arc[0], arc[1], seg))
    609:     out, rims = [], []
    610:     for k, (s0, s1, o0, o1) in enumerate(lames):
    611:         rows = max(rows, int(L * (s1 - s0) / 0.015) + 1)     # sparse rows let the limb bulge through between them
    612:         G = np.zeros((seg, rows, 3))
    613:         for j, t in enumerate(np.linspace(s0, s1, rows)):
    614:             o = top + ax * L * t
    615:             D = np.outer(np.cos(ph), f) + np.outer(np.sin(ph), sd)
    616:             r = np.array([over.cast(o, d, rmax=rmax, far=True) for d in D])
    617:             r = np.where(np.isnan(r), np.nanmedian(r) if np.isfinite(r).any() else 0.05, r)
    618:             r = np.convolve(np.pad(r, 2, mode="wrap" if arc[1] - arc[0] >= 359 else "edge"), np.ones(5) / 5, "valid")
    619:             G[:, j] = o + D * (r + o0 + (o1 - o0) * j / (rows - 1))[:, None]
    620:         pos, tri, outer = thick_grid(G, thickness, outward_from=top, axis=ax)
  • read_file{"EndLine":270,"Path":"~/work/lowmarch/tools/gear.py","StartLine":230}

    input

    {
      "EndLine": 270,
      "Path": "~/work/lowmarch/tools/gear.py",
      "StartLine": 230
    }

    result, 42 lines

    Showing lines 230-270 of 984
    230:     cone = ConeChart(lambda u, v: np.vectorize(r0)(u) + flare * np.clip((y_waist - v) / (y_waist - y_hem), 0, 1.2), cz=cz)
    231:     hem = lambda u: y_hem + 0.006 * abs(math.sin(math.radians(u) * 18))   # small scallops: a ragged mail edge
    232:     skirt, _ = outline_plate(f"{name}_skirt", role, cone, -178, 178, hem, lambda u: y_waist + 0.01, offset=0.004,
    233:                              thickness=0.004, nu=120, nv=10, roll=0, pattern=rings)
    234:     out.append(skirt)
    235:     fit.bind(body, allow=("Spine", "Chest", "UpperChest", "Bust", "Hips", "Neck", "Shoulder"), fallback="J_Bip_C_Chest")
    236:     fit.bind(skirt, allow=("Hips", "UpperLeg"), fallback="J_Bip_C_Hips")
    237:     stiffen(skirt, fit, share=0.5)
    238:     for side in ("L", "R"):
    239:         a, b = f"J_Bip_{side}_UpperArm", f"J_Bip_{side}_LowerArm"
    240:         arm = O.limb_surface(fit, (f"{side}_UpperArm",), side)
    241:         lc = LimbChart(arm, B[a], B[b], front=(0, 0, -1))
    242:         sl, _ = outline_plate(f"{name}_sleeve_{side}", role, lc, -180, 180, lambda u: sleeve, lambda u: -0.08,
    243:                               offset=0.018, thickness=0.004, nu=40, nv=8, roll=0, pattern=rings)
    244:         fit.bind(sl, allow=(f"{side}_UpperArm", f"{side}_Shoulder"), fallback=a)
    245:         out.append(sl)
    246:     return _group(out, "mail")
    247: 
    248: 
    249: def riveted_vest(fit, under, name="brigandine", role="leather", rivet_role="steel", y_top=None, y_bottom=None):
    250:     """A coat of plates: cloth-covered plates held by rows of rivets, front and back, open at the sides."""
    251:     B = fit.bone
    252:     nk, hips = B["J_Bip_C_Neck"], B["J_Bip_C_Hips"]
    253:     y_top = nk[1] - 0.06 if y_top is None else y_top
    254:     y_bottom = hips[1] + 0.02 if y_bottom is None else y_bottom
    255:     cz = float(hips[2])
    256:     tc = TorsoChart(under, y_bottom - 0.03, y_top + 0.03, cz=cz, du=3.0, dv=0.008)
    257:     out = []
    258:     for nm, (u0, u1) in (("front", (-70, 70)), ("back", (110, 250))):
    259:         rows = [[(u, y_bottom + 0.02), (u, y_top - 0.02)] for u in np.arange(u0 + 14, u1 - 6, 14)]
    260:         top = (lambda u: y_top - 0.05 * max(0.0, 1 - abs(u) / 40)) if nm == "front" else (lambda u: y_top)
    261:         pc, ex = outline_plate(f"{name}_{nm}", role, tc, u0, u1, lambda u: y_bottom, top, offset=0.016, thickness=0.006,
    262:                                nu=48, nv=18, roll=0.003, roll_edges=("bottom", "top", "left", "right"),
    263:                                seams=rows, groove=(0.004, 0.002), panel_crown=0.003,
    264:                                rivets=(0.03, 0.012, 0.0035), rivet_role=rivet_role)
    265:         fit.bind(pc, allow=("Spine", "Chest", "UpperChest", "Bust", "Hips"), fallback="J_Bip_C_Chest")
    266:         for q in ex:
    267:             O.inherit(q, pc)
    268:         out += [pc] + ex
    269:     return _group(out, "plate")
    270:
  • read_file{"EndLine":315,"Path":"~/work/lowmarch/tools/export_glb.py","StartLine":255}

    input

    {
      "EndLine": 315,
      "Path": "~/work/lowmarch/tools/export_glb.py",
      "StartLine": 255
    }

    result, 62 lines

    Showing lines 255-315 of 567
    255:              "steel": dict(kind="steel", base=pc["steel"]), "gold": dict(kind="gold", base=pc["gold"]),
    256:              "grass": dict(kind="world", base="#5a7a3a"), "dirt": dict(kind="world", base="#6a4a32"),
    257:              "stone": dict(kind="world", base="#7c7a86"),
    258:              "motif": dict(kind="cloth", base=pc.get("motif", "#3a44a0"))}       # decal paint on steel (tools/plates.py)
    259:     for role, val in pc.items():                             # extra roles a cast entry names (cloth unless it says)
    260:         if role not in paint and isinstance(val, str) and val.startswith("#"):
    261:             paint[role] = dict(kind="cloth", base=val)
    262:         elif role not in paint and isinstance(val, dict) and "base" in val:
    263:             paint[role] = dict(kind=val.get("kind", "cloth"), base=val["base"])
    264:     for role, g in (pc.get("grain") or {}).items():          # optional per-role brush grain (big flat cloth mottles)
    265:         if role in paint:
    266:             paint[role]["grain"] = g
    267:     return dict(roles=roles, light=vp.LIGHT.tolist(), sun=vp.SUN.tolist(), capsules=caps, cloth=cloth, face_marks=marks,
    268:                 paint=paint,
    269:                 mouth_curve=curve, mouth_bone="J_Bip_C_Head", ink=dict(o=hexp("o"), skin=hexp("1"), hair=hexp("A")),
    270:                 skin=[hexp(c) for c in "12345"], depth_gap=0.012)
    271: 
    272: 
    273: # ---- skinned export: one rigged character + animation clips --------------------------------------------------------
    274: F4 = np.diag([-1.0, 1.0, -1.0, 1.0])
    275: 
    276: 
    277: def _quat(R):
    278:     """Rotation matrix -> quaternion (x, y, z, w)."""
    279:     t = np.trace(R)
    280:     if t > 0:
    281:         s = math.sqrt(t + 1.0) * 2
    282:         w, x, y, z = 0.25 * s, (R[2, 1] - R[1, 2]) / s, (R[0, 2] - R[2, 0]) / s, (R[1, 0] - R[0, 1]) / s
    283:     elif R[0, 0] > R[1, 1] and R[0, 0] > R[2, 2]:
    284:         s = math.sqrt(1.0 + R[0, 0] - R[1, 1] - R[2, 2]) * 2
    285:         w, x, y, z = (R[2, 1] - R[1, 2]) / s, 0.25 * s, (R[0, 1] + R[1, 0]) / s, (R[0, 2] + R[2, 0]) / s
    286:     elif R[1, 1] > R[2, 2]:
    287:         s = math.sqrt(1.0 + R[1, 1] - R[0, 0] - R[2, 2]) * 2
    288:         w, x, y, z = (R[0, 2] - R[2, 0]) / s, (R[0, 1] + R[1, 0]) / s, 0.25 * s, (R[1, 2] + R[2, 1]) / s
    289:     else:
    290:         s = math.sqrt(1.0 + R[2, 2] - R[0, 0] - R[1, 1]) * 2
    291:         w, x, y, z = (R[1, 0] - R[0, 1]) / s, (R[0, 2] + R[2, 0]) / s, (R[1, 2] + R[2, 1]) / s, 0.25 * s
    292:     q = np.array([x, y, z, w])
    293:     return q / np.linalg.norm(q)
    294: 
    295: 
    296: def _trs(m):
    297:     t = m[:3, 3].copy()
    298:     sc = np.linalg.norm(m[:3, :3], axis=0)
    299:     return t, _quat(m[:3, :3] / sc), sc
    300: 
    301: 
    302: def fill_line_specks(rgba, most=400):
    303:     """A line texture's specks filled: pale or clear texels enclosed by the painted (dark, opaque) line, up to `most`
    304:     texels a speck, take the line's colour. VRoid paints small highlights inside its lash lines; the painted
    305:     renderer drops pale texels, so they showed as skin-coloured specks, plainest in a closed lid."""
    306:     from scipy import ndimage
    307:     dark = (rgba[..., 3] >= 128) & (rgba[..., :3].mean(-1) < 0.42 * 255)
    308:     holes = ndimage.binary_fill_holes(dark) & ~dark
    309:     lab, n = ndimage.label(holes)
    310:     if not n:
    311:         return rgba
    312:     size = ndimage.sum(holes, lab, np.arange(1, n + 1))
    313:     fill = np.isin(lab, np.nonzero(size <= most)[0] + 1)
    314:     out = rgba.copy()
    315:     out[fill] = np.append(np.median(rgba[dark][:, :3], 0), 255).astype(rgba.dtype)
  • read_file{"EndLine":256,"Path":"~/work/lowmarch/tools/export_glb.py","StartLine":235}

    input

    {
      "EndLine": 256,
      "Path": "~/work/lowmarch/tools/export_glb.py",
      "StartLine": 235
    }

    result, 23 lines

    Showing lines 235-256 of 567
    235:     if getattr(portrait, "marks", None):
    236:         m = next(iter(portrait.marks.values()))
    237:         img = Image.fromarray(np.where(m == 1, 128, 0).astype(np.uint8), "L")     # nose mark only; the mouth is a line
    238:         b = io.BytesIO()
    239:         img.save(b, "PNG", optimize=True)
    240:         import base64
    241:         marks = base64.b64encode(b.getvalue()).decode()
    242:     # painted renderer: a material kind and one base colour per role; the shader builds the ramp
    243:     pc = dict(signature="#7d1e2c", doublet="#2a2d3d", heraldry="#dfe2e8", leather="#5f3e2b", boot="#4a3326", glove="#5f3e2b",
    244:               steel="#a6adbb", gold="#b08b3f", hair=hexp("C"), trim="#b08b3f")
    245:     pc.update(getattr(portrait, "paint", None) or {})
    246:     skin = dict(kind="skin", base=pc.get("skin") or "#f8e1d5")                       # light skin unless a tone is set
    247:     skin["ramp"] = skin_ramp(skin["base"])                                              # its lit, shade and deep shade
    248:     paint = {"face": dict(skin), "body": dict(skin), "shadow": dict(skin, shade=True),   # shadow cards: skin in shade
    249:              "hair": dict(kind="hair", base=pc["hair"]),
    250:              "coat": dict(kind="cloth", base=pc["signature"]), "cape": dict(kind="cloth", base=pc["signature"]),
    251:              "signature": dict(kind="cloth", base=pc["signature"]), "doublet": dict(kind="cloth", base=pc["doublet"]),
    252:              "cloth": dict(kind="cloth", base=pc["doublet"]), "heraldry": dict(kind="cloth", base=pc["heraldry"]),
    253:              "leather": dict(kind="leather", base=pc["leather"]), "boot": dict(kind="leather", base=pc["boot"]),
    254:              "glove": dict(kind="leather", base=pc["glove"]), "metal": dict(kind="steel", base=pc["steel"]),
    255:              "steel": dict(kind="steel", base=pc["steel"]), "gold": dict(kind="gold", base=pc["gold"]),
    256:              "grass": dict(kind="world", base="#5a7a3a"), "dirt": dict(kind="world", base="#6a4a32"),
  • read_file{"EndLine":1015,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":950}

    input

    {
      "EndLine": 1015,
      "Path": "~/work/lowmarch/tools/outfit.py",
      "StartLine": 950
    }

    result, 67 lines

    Showing lines 950-1015 of 1272
    950: 
    951:     def grouped(pcs, g):
    952:         for pc in pcs:
    953:             if pc is not None:
    954:                 pc["group"] = g
    955:         return [pc for pc in pcs if pc is not None]
    956: 
    957:     def rolled(name, pc, rims, r=0.0024, role="metal"):
    958:         return [inherit(pipe(f"{name}_roll{k}", role, rim, r=r), pc) for k, rim in enumerate(rims)]
    959: 
    960:     def cuff_plane(side):
    961:         a, hd = B[f"J_Bip_{side}_LowerArm"], B[f"J_Bip_{side}_Hand"]
    962:         n = (hd - a) / np.linalg.norm(hd - a)
    963:         return n, n @ (hd - n * 0.035)
    964: 
    965:     torso = ("Spine", "Chest", "UpperChest", "Bust", "Shoulder", "UpperArm", "LowerArm", "Neck", "Hips")
    966:     bodice = wrap(fit, "bodice", "signature", torso, offset=0.006, exclude=("UpperLeg",),
    967:                   y_min=hips[1] + 0.02, y_max=nk[1] + 0.012, hems=[cuff_plane("L"), cuff_plane("R")])
    968:     tights = wrap(fit, "tights", "doublet", ("Hips", "UpperLeg", "LowerLeg"), offset=0.004, y_max=hips[1] + 0.03, subdiv=1)
    969:     boots = wrap(fit, "boots", "metal", ("LowerLeg", "Foot"), offset=0.014, y_max=knee - 0.06, exclude=("ToeBase",),
    970:                  subdiv=1, hems=[((0, 1, 0), knee - 0.065)])
    971:     gloves = wrap(fit, "gloves", "metal", ("Hand", "Thumb", "Index", "Middle", "Ring", "Little"),
    972:                   offset=0.0035, min_w=0.3, smooth=4)
    973:     out += grouped([bodice], "dress") + grouped([tights], "trousers") + grouped([boots], "boots") + grouped([gloves], "gloves")
    974:     out += grouped(sabaton(fit, "sabaton_L", "L") + sabaton(fit, "sabaton_R", "R"), "boots")
    975:     col, rim, _ = collar(fit, "collar", "signature", height_back=0.034, height_front=0.022)
    976:     out += grouped([col, inherit(pipe("collar_trim", "gold", rim, r=0.0022), col)], "dress")
    977: 
    978:     # steel breastplate, fitted, ending at the natural waist; gold line along the neckline
    979:     cuirass = wrap(fit, "breastplate", "steel", ("Spine", "Chest", "UpperChest", "Bust"), offset=0.010,   # the female
    980:                    # base weights the chest to its own Bust bones: leave them out and the plate has two holes
    981:                    exclude=("Shoulder", "UpperArm", "Neck"), y_min=hips[1] + 0.085, y_max=nk[1] - 0.065,
    982:                    base=Surface(bodice["pos"], bodice["tri"]), smooth=70,      # a rigid shell, not a moulded bust
    983:                    hems=[((0, 1, 0), hips[1] + 0.095), ((0, 1, 0), nk[1] - 0.075)])
    984:     loops = sorted([cuirass["pos"][L] for L in cuirass["loops"] if len(L) > 12], key=lambda Lp: -Lp[:, 1].mean())
    985:     out += grouped([cuirass] + [inherit(pipe(f"breastplate_roll{k}", "gold" if k == 0 else "metal", Lp, r=0.003,
    986:                                              closed=True), cuirass) for k, Lp in enumerate(loops)], "plate")
    987: 
    988:     # the skirt from the waist to the ankle, white petticoat edge (the viewer's border band)
    989:     legs = merge_surfaces((tights["pos"], tights["tri"]), (boots["pos"], boots["tri"]))
    990:     # the waist ring is cast onto the bodice without its sleeves: with them, the hanging arms beside
    991:     # the hips held the ring out at the sides, a shelf the user saw once the arms moved
    992:     waist = merge_surfaces(without(bodice, ("Shoulder", "UpperArm", "LowerArm", "Hand")), (tights["pos"], tights["tri"]))
    993:     ytop = hips[1] + 0.08
    994:     sk, grid = skirt(fit, "skirt", "signature", waist, legs, ytop, ytop - 0.24, flare=0.17)   # hem above the ankle
    995:     sk["group"] = "dress"
    996:     out.append(sk)
    997:     out += grouped([inherit(ribbon("skirt_hem", "heraldry", np.concatenate([grid[:, -1], grid[:1, -1]]), width=0.03,
    998:                                    lift=0.0015, normals=near_normals(sk, np.concatenate([grid[:, -1], grid[:1, -1]]))), sk)],
    999:                    "dress")
    1000:     out += grouped([inherit(pipe("waist_trim", "gold", grid[:, 0], r=0.0035, closed=True), sk)], "dress")
    1001: 
    1002:     plate_body = merge_surfaces((cuirass["pos"], cuirass["tri"]), (bodice["pos"], bodice["tri"]), (fit.pos, fit.tri))
    1003:     for side in ("L", "R"):
    1004:         ll, ft = B[f"J_Bip_{side}_LowerLeg"], B[f"J_Bip_{side}_Foot"]
    1005:         la, hd = B[f"J_Bip_{side}_LowerArm"], B[f"J_Bip_{side}_Hand"]
    1006:         sp, rims = pauldron(fit, f"spaulder_{side}", "steel", plate_body, side=side,
    1007:                             lames=((0, 54, 0.016, 0.022), (46, 76, 0.014, 0.020)), spread=105)
    1008:         out += grouped(sp, "plate") + grouped(sum((rolled(f"spaulder_{side}{k}", pc, [r_]) for k, (pc, r_) in
    1009:                                                    enumerate(zip(sp, rims))), []), "plate")
    1010:         fore = limb_surface(fit, (f"{side}_LowerArm",), side)
    1011:         vb, rims = limb_lames(fit, f"vambrace_{side}", "steel", fore, la, hd, ((0.10, 0.97, 0.014, 0.017),), rmax=0.11)
    1012:         fit.bind(vb[0], rigid=f"J_Bip_{side}_LowerArm")
    1013:         out += grouped(vb + rolled(f"vambrace_{side}", vb[0], rims[0]), "plate")
    1014:         arm = limb_surface(fit, (f"{side}_LowerArm", f"{side}_UpperArm"), side)
    1015:         jg, jr = joint_guard(fit, f"couter_{side}", f"J_Bip_{side}_LowerArm", f"J_Bip_{side}_Hand", (0, 0, 1), side,