A mech game prototype, pushed by Fable 5.2

agent

+57:04
reasoning

v2 is saved to wip.jpg, with facets and chines in. The hip skirt reads as a tutu, the pauldrons as eggs, and the booms as a second pair of arms, so I'm fixing those and adding the detail layer next.

  • Bashtools/log.sh "r2 v2 read: facets work. skirt too big, pauldrons eggs, booms read as arms, too plain. v3: reshape those, add detail layer" && python3 - <<'EOF'

    command

    tools/log.sh "r2 v2 read: facets work. skirt too big, pauldrons eggs, booms read as arms, too plain. v3: reshape those, add detail layer" && python3 - <<'EOF'
    p='kit/blocks/skin.py'; s=open(p).read()
    a='''        role, u0, u1, v0, v1 = spec[:5]
            grow = spec[5] if len(spec) > 5 else 0.0
            by_role.setdefault(role, []).append(thicken(skin.patch(u0, u1, v0, v1, grow), t))'''
    assert a in s
    s=s.replace(a,'''        role, u0, u1, v0, v1 = spec[:5]
            grow = spec[5] if len(spec) > 5 else 0.0
            gap = spec[6] if len(spec) > 6 else None
            by_role.setdefault(role, []).append(thicken(skin.patch(u0, u1, v0, v1, grow, gap), t))''')
    s=s.replace('''    """Cut a skin into shells. specs: (role, u0, u1, v0, v1) or with a sixth value, how far the panel
        stands proud of the surface. Panels of one role become one part."""''','''    """Cut a skin into shells. specs: (role, u0, u1, v0, v1), then optionally how far the panel stands
        proud of the surface, then its own gap (a small one draws a fine secondary line). Panels of one
        role become one part."""''')
    s+='''
    
    def cable(points, r=.05):
        """A hose or cable through some points, as a bmesh."""
        cu = bpy.data.curves.new("_cable", "CURVE")
        cu.dimensions = "3D"
        sp = cu.splines.new("NURBS")
        sp.points.add(len(points) - 1)
        for p, co in zip(sp.points, points):
            p.co = (co[0], co[1], co[2], 1)
        sp.use_endpoint_u = True
        sp.order_u = min(4, len(points))
        cu.resolution_u = 5
        cu.bevel_depth = r
        cu.bevel_resolution = 2
        cu.use_fill_caps = True
        o = link(bpy.data.objects.new("_cable", cu))
        me = bpy.data.meshes.new_from_object(o.evaluated_get(bpy.context.evaluated_depsgraph_get()))
        bm = bmesh.new()
        bm.from_mesh(me)
        bpy.data.meshes.remove(me)
        bpy.data.objects.remove(o, do_unlink=True)
        bpy.data.curves.remove(cu)
        return bm
    '''
    open(p,'w').write(s)
    EOF
    echo done

    result, 2 lines

    19:30:12  r2 v2 read: facets work. skirt too big, pauldrons eggs, booms read as arms, too plain. v3: reshape those, add detail layer
    done
  • Bashpython3 - <<'EOF'

    command

    python3 - <<'EOF'
    p='kit/blocks/zero.py'; s=open(p).read()
    def rep(a,b,count=1):
        global s
        assert s.count(a)>=1, a[:60]
        s=s.replace(a,b)
    rep('from blocks.skin import Skin, blade, chevron, panels, put, slats, sweep, sym','from blocks.skin import Skin, blade, cable, chevron, panels, put, slats, sweep, sym')
    rep('''def P(role, first, last, v0, v1, grow=0.0):
        """A panel from the start of one flat to the end of another, going round by way of the back."""
        return (role, first, (last + 45) % 360, v0, v1, grow)''','''FINE = .014  # the gap of a secondary shut line
    
    
    def P(role, first, last, v0, v1, grow=0.0, gap=None):
        """A panel from the start of one flat to the end of another, going round by way of the back."""
        return (role, first, (last + 45) % 360, v0, v1, grow, gap)''')
    # ---- thigh
    a=s.index('                 zs=[6.9, 7.6, 8.7, 9.6, 10.15], rake=sweep(-.3), facet=True)'); b=s.index('    pair("ham_strut"')
    s=s[:a]+'''                 zs=[6.9, 7.35, 7.9, 8.7, 9.3, 9.8, 10.15], rake=sweep(-.3), facet=True)
        put("thigh_core", thigh.core(.09), "frame", TH, bevel=0)
        panels("thigh", thigh, [P("accent", FI, FO, 0, 1), P("main", FI, FO, 1, 4), P("main", FI, FO, 4, 6, 0, FINE), ("main", 255, 285, 2, 5, .05),
                                P("main", O, O, 0, 3), P("main", O, O, 3, 6, 0, FINE), ("accent", 345, 15, 3, 5, .05), ("hazard", 345, 15, 1, 2, .03),
                                P("frame", BO, BO, 1, 3), P("main", BO, BO, 3, 6), P("frame", BI, BI, 1, 3), P("main", BI, BI, 3, 6),
                                P("main", I, I, 0, 6)], TH)
    '''+s[b:]
    rep('''    pair("ham_strut", piston((1.2, .66, 9.3), (1.2, .52, 6.5), r=.09), "joint", *TH, smooth=True)''','''    pair("ham_strut", piston((1.2, .66, 9.3), (1.2, .52, 6.5), r=.09), "joint", *TH, smooth=True)
        pair("ham_hose", cable([(1.02, .62, 9.6), (.98, .74, 8.6), (1.0, .66, 7.4), (1.04, .5, 6.6)], .045), "joint", *TH, smooth=True)''')
    # ---- shin
    a=s.index('                 dict(z=5.85, a=.56, bf=.78, bb=.56, y=0)], zs=[1.85, 2.45, 3.2, 4.5, 5.3, 5.85], rake=sweep(.35), facet=True)'); b=s.index('    put("calf_louvre"')
    s=s[:a]+'''                 dict(z=5.85, a=.56, bf=.78, bb=.56, y=0)], zs=[1.85, 2.3, 2.8, 3.4, 4.2, 4.9, 5.4, 5.85], rake=sweep(.35), facet=True)
        put("shin_core", shin.core(.09), "frame", SH, bevel=0)
        panels("shin", shin, [P("accent", FI, FO, 0, 1), P("main", FI, FO, 1, 4), P("main", FI, FO, 4, 7, 0, FINE), ("main", 255, 285, 3, 7, .06),
                              P("main", O, O, 0, 3), P("main", O, O, 3, 6, 0, FINE), ("accent", 345, 15, 3, 5, .05),
                              P("main", BO, BO, 1, 4), P("main", BO, BO, 4, 7, 0, FINE), P("main", BI, BI, 1, 4), P("main", BI, BI, 4, 7, 0, FINE),
                              P("main", BK, BK, 4, 7, .05), P("frame", I, I, 0, 2), P("main", I, I, 2, 6)], SH)
    '''+s[b:]
    rep('put("calf_louvre", slats(shin, 71.25, 108.75, 3.25, 3.75, 3, grow=-.03), "frame", SH, bevel=.01)','put("calf_louvre", slats(shin, 71.25, 108.75, 3.5, 4.15, 4, grow=-.03), "joint", SH, bevel=.01)')
    rep('put("calf_blade", blade(1.7, .6, .14, (1.2, 1.25, 4.6), (("X", -38),)), "accent", SH, bevel=0)','put("calf_blade", blade(1.5, .56, .14, (1.2, 1.2, 4.9), (("X", -36),)), "accent", SH, bevel=0)')
    # ---- foot
    a=s.index('                 dict(z=2.6, a=.34, bb=.1, bf=.14, y=.26)], zs=[-1.15, -.5, .5, 1.5, 2.2, 2.6]'); b=s.index('    spat = Skin(')
    s=s[:a]+'''                 dict(z=2.6, a=.34, bb=.1, bf=.14, y=.26)], zs=[-1.15, -.5, .1, .8, 1.5, 2.2, 2.6], rake=sweep(-.25), frame=FOOT, facet=True)
        put("foot_core", foot.core(.06), "frame", FT, bevel=0)
        panels("foot", foot, [P("main", O, I, 0, 1), P("main", BO, BI, 1, 2), P("main", BO, BI, 2, 4, 0, FINE), P("accent", O, O, 1, 4), P("main", I, I, 1, 4),
                              P("main", O, I, 4, 5), P("accent", O, I, 5, 6)], FT, t=.07)
    '''+s[b:]
    # ---- pelvis skirt
    a=s.index('    skirt = Skin('); b=s.index('def waist(W):')
    s=s[:a]+'''    # hip armour as separate plates off one cone: narrow front plates, a proud plate on each hip, two tails
        skirt = Skin([dict(z=9.2, a=2.04, bf=1.42, bb=1.36, fx=.5, fy=.5, bx=.5, by=.5), dict(z=10.0, a=2.02, bf=1.3, bb=1.28),
                      dict(z=10.72, a=1.74, bf=1.08, bb=1.1)], zs=[9.25, 9.65, 10.2, 10.7], rake=lambda c, s: .5 * abs(c) - .12, facet=True)
        specs = sym("main", 270, 292.5, 1, 3) + sym("accent", 270, 292.5, 0, 1) + sym("main", 67.5, 90, 0, 3) + sym("frame", 30, 67.5, 1, 3)
        specs += sym("main", 337.5, 22.5, 0, 3, .04) + sym("accent", 345, 15, 1, 2, .09)
        panels("skirt", skirt, specs, P_, t=.09)
    
    
    '''+s[b:]
    rep('''    pair("waist_strut", piston((.5, .6, 10.98), (.58, .68, 11.92), r=.07), "joint", W, W, smooth=True)''','''    pair("waist_strut", piston((.5, .6, 10.98), (.58, .68, 11.92), r=.07), "joint", W, W, smooth=True)
        pair("waist_hose", cable([(.66, -.2, 10.95), (.8, -.32, 11.35), (.76, -.3, 11.75), (.7, -.2, 12.0)], .05), "joint", W, W, smooth=True)
        pair("waist_hose2", cable([(.7, .15, 10.95), (.84, .2, 11.4), (.8, .22, 12.0)], .04), "frame", W, W, smooth=True)''')
    # ---- torso
    a=s.index('             zs=[12.0, 12.55, 13.4, 14.3, 14.95, 15.3], rake=chevron(.3), facet=True)'); b=s.index('    collar = Skin(')
    s=s[:a]+'''             zs=[12.0, 12.3, 12.6, 13.0, 13.4, 13.85, 14.3, 14.65, 14.95, 15.3], rake=chevron(.3), facet=True)
        put("chest_core", t.core(.1), "frame", T, bevel=0)
        specs = [P("main", F, F, 0, 2, .04), P("main", F, F, 2, 4, .04, FINE), P("main", F, F, 4, 6, .07), P("main", F, F, 6, 8, .07, FINE),
                 P("accent", F, F, 8, 9, .04), P("main", BK, BK, 8, 9)]
        specs += sym("main", FO, FO + 45, 0, 2) + sym("frame", FO, FO + 45, 2, 4) + sym("accent", FO, FO + 45, 6, 8) + sym("main", FO, FO + 45, 8, 9, .03)
        specs += sym("main", O, O + 45, 2, 4) + sym("main", O, O + 45, 4, 6, 0, FINE)
        specs += sym("frame", BO, BO + 45, 0, 2) + sym("main", BO, BO + 45, 2, 5) + sym("main", BO, BO + 45, 5, 9, 0, FINE)
        panels("chest", t, specs, T)
        put("intake.L", slats(t, 296.25, 333.75, 13.46, 14.24, 5, grow=-.04), "joint", T, bevel=.01)
        put("intake.R", slats(t, 206.25, 243.75, 13.46, 14.24, 5, grow=-.04), "joint", T, bevel=.01)
        pair("neck_hose", cable([(.36, .3, 15.25), (.5, .42, 15.55), (.34, .3, 15.9)], .045), "joint", T, T, smooth=True)
    '''+s[b:]
    # ---- pauldron
    a=s.index('    p = Skin([dict(z=1.85, a=.72'); b=s.index('    ua = Skin(')
    s=s[:a]+'''    p = Skin([dict(z=1.7, a=.78, bb=.42, bf=.5, bx=.75, by=.6, fx=.25, fy=.3, x=0, y=14.75), dict(z=2.6, a=1.05, bb=.78, bf=.62, x=.05, y=14.9),
                  dict(z=3.5, a=.95, bb=.7, bf=.5, x=.3, y=15.0), dict(z=4.2, a=.6, bb=.4, bf=.3, x=.7, y=15.05),
                  dict(z=4.8, a=.12, bb=.1, bf=.08, x=1.25, y=15.05)], zs=[1.75, 2.5, 3.4, 4.15, 4.8], rake=sweep(.25), frame=OUT, facet=True)
        put("pauldron_core", p.core(.12), "frame", S, bevel=0)
        panels("pauldron", p, [P("main", BI, I, 0, 2), P("main", O, BO, 0, 2), P("main", BI, I, 2, 3, 0, FINE), P("main", O, BO, 2, 3, 0, FINE),
                               P("main", BK, BK, 0, 3, .04), P("accent", O, I, 3, 4)], S, t=.09)
    '''+s[b:]
    rep('''    panels("upperarm", ua, [P("main", FI, FO, 0, 2), P("main", BO, BI, 0, 2), ("accent", 345, 15, 0, 1, .04)], U, t=.07)''',
        '''    panels("upperarm", ua, [P("main", FI, FO, 0, 2), P("main", BO, BI, 0, 2), ("accent", 345, 15, 0, 1, .04), ("frame", 345, 15, 1, 2, .02)], U, t=.07)''')
    a=s.index('               dict(z=11.5, a=.56, bf=.7, bb=.46), dict(z=12.0, a=.5, bf=.56, bb=.44)], zs=[9.7, 10.3, 11.3, 11.95]'); b=s.index('    put("forearm_blade"')
    s=s[:a]+'''               dict(z=11.5, a=.56, bf=.7, bb=.46), dict(z=12.0, a=.5, bf=.56, bb=.44)], zs=[9.7, 10.1, 10.6, 11.3, 11.95], rake=sweep(-.2), spin=90, facet=True)
        put("forearm_core", fa.core(.08), "frame", F_, bevel=0)
        panels("forearm", fa, [P("accent", FI, FO, 0, 1, .03), P("main", FI, FO, 1, 4), ("main", 255, 285, 2, 4, .05), P("main", O, O, 0, 4), P("main", I, I, 0, 4),
                               P("frame", BO, BO, 1, 4), P("frame", BI, BI, 1, 4)], F_, t=.07)
    '''+s[b:]
    # ---- booms -> tail fins
    a=s.index('    # tail booms on the binder joints')
    s=s[:a]+'''    pair("drive_hose", cable([(.62, 1.9, 14.2), (.9, 2.2, 13.9), (1.05, 2.0, 13.5)], .06), "joint", B, B, smooth=True)
        # tail fins on the binder joints: a long faceted blade each side, splayed out and back, a drive pod on its root
        piv = Vector((.9, 2.25, 14.7))
        pair("fin_hinge", cylinder(.26, piv.x - .32, piv.x + .32, 16, axis="x", at=(piv.y, piv.z)), "joint", *BN, smooth=True)
        bf = Matrix.Translation(piv + Vector((.2, .35, .25))) @ Matrix.Rotation(-.3840, 4, "Y") @ Matrix.Rotation(3.5954, 4, "X")
        fin = Skin([dict(z=0, a=.34, bf=.16, bb=.2, fx=.85, fy=.8, bx=.85, by=.8), dict(z=.9, a=.72, bf=.2, bb=.26), dict(z=3.4, a=.5, bf=.15, bb=.18),
                    dict(z=6.3, a=.1, bf=.05, bb=.06)], zs=[0, .8, 2.0, 3.4, 4.8, 6.3], rake=sweep(.3), frame=bf, facet=True, crown=.02)
        put("fin_core", fin.core(.03), "frame", BN, bevel=0)
        panels("fin", fin, [P("frame", FI, FO, 0, 1), P("main", FI, FO, 1, 3), P("accent", FI, FO, 3, 4), P("main", FI, FO, 4, 5),
                            P("main", BO, BI, 1, 5), P("main", O, O, 1, 5), P("main", I, I, 1, 5)], BN, t=.04)
        pf = bf @ Matrix.Translation((0, -.42, .25))
        pod = Skin([dict(z=0, a=.22, bf=.22, bb=.22), dict(z=.5, a=.36, bf=.34, bb=.34), dict(z=1.3, a=.34, bf=.32, bb=.32), dict(z=1.6, a=.28, bf=.27, bb=.27)],
                   zs=[0, .5, 1.25, 1.6], m=32, frame=pf)
        put("fin_pod_core", pod.core(.05), "frame", BN, bevel=0)
        panels("fin_pod", pod, [("main", 0, 360, 0, 2), ("accent", 0, 360, 2, 3, .03)], BN, t=.05)
        tip = pf @ Vector((0, 0, 1.5))
        along = (pf.to_3x3() @ Vector((0, 0, 1))).normalized()
        nozzle_pair("main_tip", tuple(tip), tuple(along), .24, .5, *BN, housing=False)
    '''
    open(p,'w').write(s)
    EOF
    (npm run -s kit -- block_zero 2>&1 | grep -E "^kit:|Error|Traceback|error|File \"|line [0-9]+" | head -20) && node tools/look.mjs block_zero --out review/out/fable52/r2/z3 --zoom 1.25 && cd review/out/fable52/r2/z3 && ffmpeg -loglevel error -y -i f01.jpg -i f00.jpg -i f05.jpg -i f02.jpg -filter_complex hstack=inputs=4 -q:v 2 m1.jpg && cp m1.jpg [redacted: private path]/fable52-sortie/wip.jpg && cd - >/dev/null && tools/log.sh "r2 v3 built and shot"

    result, 3 lines

    kit: block_zero -> ~/Projects/sortie-wt/fable52/public/assets/block_zero.glb (5018 KB, 5.3s)
    look: ~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3/sheet.jpg, 16 frames, 32 s
    19:32:09  r2 v3 built and shot
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3/m1.jpg

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3/m1.jpg"
    }

    result

    no output

    m1_3.jpg
    m1_3.jpg

agent

+59:14

v3 is on wip.jpg: reshaped pauldrons, tail fins, chest intakes, dark plates and hoses are in. Now checking it close up and in the flight pose with plumes.

  • Bashcd ~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3 && ffmpeg -loglevel error -y -i f05.jpg -i f10.jpg -i f12.jpg -i f14.jpg -filter_complex hstack=inputs=4 -q:v 2 m2.jpg

    command

    cd ~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3 && ffmpeg -loglevel error -y -i f05.jpg -i f10.jpg -i f12.jpg -i f14.jpg -filter_complex hstack=inputs=4 -q:v 2 m2.jpg

    result, 1 line

    (Bash completed with no output)
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3/m2.jpg

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/z3/m2.jpg"
    }

    result

    no output

    m2.jpg
    m2.jpg
  • Bashcd ~/Projects/sortie-wt/fable52 && sed -n 1,60p src/render/decals.ts | cut -c1-220 && grep -n "STRIKER_DECALS" -A 22 src/render/decals.ts | cut -c1-200 | head -50 && grep -n "apply(pose\|hold(" -A 14 src/render/mech.ts | head -60

    command

    cd ~/Projects/sortie-wt/fable52 && sed -n 1,60p src/render/decals.ts | cut -c1-220 && grep -n "STRIKER_DECALS" -A 22 src/render/decals.ts | cut -c1-200 | head -50 && grep -n "apply(pose\|hold(" -A 14 src/render/mech.ts | head -60

    result, 113 lines

    import * as THREE from 'three';
    import { DecalGeometry } from 'three/addons/geometries/DecalGeometry.js';
    
    // Markings projected onto armour: unit numbers, designations, caution stencils, hazard bands and the
    // company emblem. Each decal is found by casting a ray at the rest pose, projected onto the mesh it
    // hits, and parented to that mesh so it moves with its joint.
    
    export type DecalKind = 'number' | 'stencil' | 'hazard' | 'emblem';
    
    export interface DecalSpec {
      kind: DecalKind;
      text?: string;
      /** A point just off the surface, model space (three.js axes: +X the frame's left, +Z forward). */
      at: [number, number, number];
      /** Direction into the surface. */
      dir: [number, number, number];
      /** Width and height in metres. */
      size: [number, number];
      /** Roll around the surface normal, degrees. */
      roll?: number;
      color?: string;
    }
    
    const textures = new Map<string, THREE.CanvasTexture>();
    
    function texture(spec: DecalSpec): THREE.CanvasTexture {
      const key = `${spec.kind}:${spec.text ?? ''}:${spec.color ?? ''}:${spec.size.join('x')}`;
      const hit = textures.get(key);
      if (hit) return hit;
      const W = 512, H = Math.max(32, Math.round((512 * spec.size[1]) / spec.size[0]));
      const c = document.createElement('canvas');
      c.width = W;
      c.height = H;
      const g = c.getContext('2d')!;
      const ink = spec.color ?? '#20242a';
      g.fillStyle = ink;
      g.strokeStyle = ink;
      g.textAlign = 'center';
      g.textBaseline = 'middle';
      if (spec.kind === 'hazard') {
        g.fillStyle = '#e2b42a';
        g.fillRect(0, 0, W, H);
        g.fillStyle = '#15171a';
        for (let x = -H; x < W + H; x += H * 1.4) {
          g.beginPath();
          g.moveTo(x, H); g.lineTo(x + H * 0.7, H); g.lineTo(x + H * 1.4, 0); g.lineTo(x + H * 0.7, 0);
          g.fill();
        }
      } else if (spec.kind === 'emblem') {
        const r = Math.min(W, H) * 0.42;
        g.lineWidth = r * 0.12;
        g.beginPath();
        g.arc(W / 2, H / 2, r, 0, Math.PI * 2);
        g.stroke();
        g.beginPath();
        g.moveTo(W / 2 - r * 0.55, H / 2 - r * 0.25);
        g.lineTo(W / 2, H / 2 + r * 0.45);
        g.lineTo(W / 2 + r * 0.55, H / 2 - r * 0.25);
        g.lineTo(W / 2 + r * 0.3, H / 2 - r * 0.25);
        g.lineTo(W / 2, H / 2 + r * 0.05);
    127:export const STRIKER_DECALS: DecalSpec[] = [
    128-  { kind: 'number', text: '07', at: [4.8, 15.15, 0], dir: [-1, 0, 0], size: [0.95, 0.7], color: '#e9edf0' },
    129-  { kind: 'emblem', at: [-4.8, 15.15, 0], dir: [1, 0, 0], size: [0.8, 0.8], color: '#e9edf0' },
    130-  { kind: 'number', text: '07', at: [2.6, 3.6, 0.15], dir: [-1, 0, 0], size: [0.55, 0.42], color: '#e9edf0' },
    131-  { kind: 'stencil', text: 'MF-07', at: [1.15, 9.25, 3], dir: [0, 0, -1], size: [0.7, 0.2] },
    132-  { kind: 'stencil', text: 'NO STEP', at: [1.3, 10.05, 3], dir: [0, 0, -1], size: [0.6, 0.15], roll: -20 },
    133-  { kind: 'stencil', text: 'NO STEP', at: [-1.3, 10.05, 3], dir: [0, 0, -1], size: [0.6, 0.15], roll: 20 },
    134-  { kind: 'hazard', at: [1.2, 6.55, 3], dir: [0, 0, -1], size: [0.6, 0.12] },
    135-  { kind: 'hazard', at: [-1.2, 6.55, 3], dir: [0, 0, -1], size: [0.6, 0.12] },
    136-  { kind: 'stencil', text: 'DANGER EXHAUST', at: [0, 12.9, -4], dir: [0, 0, 1], size: [1.1, 0.16] },
    137-  { kind: 'stencil', text: 'STRIKER', at: [-2.6, 3.4, 0.15], dir: [1, 0, 0], size: [0.9, 0.2], roll: 90, color: '#e9edf0' },
    138-];
    121:  apply(pose: Pose) {
    122-    for (const [j, node] of this.joints) {
    123-      const r = pose[j] ?? [0, 0, 0];
    124-      node.quaternion.setFromEuler(tmpE.set(r[0] * D, r[1] * D, r[2] * D));
    125-    }
    126-  }
    127-
    128-  /** Snap to a pose and measure how high its soles sit above the root, in world metres (root
    129-   *  upright). A crouch lifts the feet, so the frame drops by this much to stand on its clamps. */
    130-  soles(pose: Pose): number {
    131:    this.apply(pose);
    132-    this.root.updateMatrixWorld(true);
    133-    const v = new THREE.Vector3();
    134-    let min = Infinity;
    135-    for (const j of ['foot.L', 'foot.R'] as const) {
    136-      this.joints.get(j)?.traverse((o) => {
    137-        const p = (o as THREE.Mesh).isMesh ? (o as THREE.Mesh).geometry.attributes.position : null;
    138-        if (!p) return;
    139-        for (let i = 0; i < p.count; i++) min = Math.min(min, v.fromBufferAttribute(p, i).applyMatrix4(o.matrixWorld).y);
    140-      });
    141-    }
    142-    return Number.isFinite(min) ? min - this.root.getWorldPosition(v).y : 0;
    143-  }
    144-
    145-  /** Ease toward a blend of poses; weights need not sum to 1 (the rest is the rest pose). */
    --
    172:  hold(weapon: THREE.Object3D | null) {
    173-    if (this.held && this.held !== weapon) this.held.removeFromParent();
    174-    this.held = weapon;
    175-    if (!weapon) return;
    176-    this.grip.add(weapon);
    177-    weapon.position.set(0, 0, 0);
    178-    weapon.quaternion.setFromEuler(tmpE.set(Math.PI / 2, 0, 0));
    179-  }
    180-
    181-  /** Step the plumes from this frame's flight reading and draw them. `time` drives the turbulence. */
    182-  thrust(r: ThrustReading, time: number, dt: number) {
    183-    this.exhaust.step(r, dt);
    184-    for (const k of KINDS) setPlume(this.plumeMats[k], this.exhaust.plumes[k], time);
    185-    for (const n of this.nozzles) n.plume.visible = plumeVisible(this.exhaust.plumes[n.kind]);
    186-  }
  • Bashtools/log.sh "r2 v3 read in flight: strong. fixing hands, calf jets, adding verniers, lamps, decals, rifle" && python3 - <<'EOF'

    command

    tools/log.sh "r2 v3 read in flight: strong. fixing hands, calf jets, adding verniers, lamps, decals, rifle" && python3 - <<'EOF'
    p='kit/blocks/zero.py'; s=open(p).read()
    def rep(a,b):
        global s
        assert a in s, a[:70]
        s=s.replace(a,b)
    rep('nozzle_pair("calf", (1.2, .98, 2.9), (0, .55, -.83), .3, .5, *SH, housing=False)','nozzle_pair("calf", (1.2, .74, 3.35), (0, .55, -.83), .26, .4, *SH, housing=False)')
    # hands
    a=s.index('    pair("palm", loft('); b=s.index('def pack(B, lr):')
    s=s[:a]+'''    # hands: a palm, four jointed fingers curled in, a thumb, a plate over the back of the hand
        pair("palm", loft([(8.95, octo(.4, .8, .1, x=2.56)), (9.46, octo(.4, .78, .1, x=2.56))]), "frame", *HD, bevel=.02)
        for i, y in enumerate((-.3, -.1, .1, .3)):
            pair(f"finger{i}a", loft([(8.62, octo(.2, .17, .04, x=2.5, y=y)), (8.98, octo(.22, .18, .04, x=2.52, y=y))]), "frame", *HD, bevel=.015)
            pair(f"finger{i}b", loft([(8.5, octo(.3, .16, .04, x=2.33, y=y)), (8.66, octo(.3, .16, .04, x=2.33, y=y))]), "joint", *HD, bevel=.015)
            pair(f"finger{i}c", loft([(8.6, octo(.16, .15, .03, x=2.2, y=y)), (8.9, octo(.16, .15, .03, x=2.2, y=y))]), "frame", *HD, bevel=.015)
        pair("thumb", loft([(8.86, octo(.2, .2, .05, x=2.34, y=-.5)), (9.3, octo(.24, .24, .06, x=2.42, y=-.47))]), "frame", *HD, bevel=.02)
        pair("hand_plate", loft([(8.9, octo(.12, .84, .04, x=2.82)), (9.3, octo(.14, .9, .04, x=2.84)), (9.56, octo(.12, .7, .04, x=2.8))]), "main", *HD, bevel=.02)
        pair("knuckle", loft([(8.84, octo(.16, .8, .04, x=2.74)), (8.96, octo(.16, .8, .04, x=2.76))]), "accent", *HD, bevel=.015)
        # a vernier on the back of each pauldron
        bell, glow = nozzle(.17, .3)
        pair("vernier", place(bell, (3.0, 1.0, 14.8), (0, 1, -.25)), "frame", *S, smooth=True)
        pair("vernier_glow", place(glow, (3.0, 1.0, 14.8), (0, 1, -.25)), "glow_thruster", *S)
    
    
    '''+s[b:]
    # lamps at the fin tips, red to port and green to starboard
    s=s.rstrip('\n')+'''
        for s_, sx, j, role in (("L", 1, BN[0], "lamp_red"), ("R", -1, BN[1], "lamp_green")):
            c = bf @ Vector((0, -.07, 5.2))
            solid(f"fin_lamp.{s_}", cylinder(.07, c.y - .03, c.y + .03, 8, axis="y", at=(c.x * sx, c.z)), role, j)
    '''
    open(p,'w').write(s)
    
    p='src/view/clip.ts'; s=open(p).read()
    rep("import { STRIKER_DECALS, applyDecals } from '../render/decals';","import { STRIKER_DECALS, ZERO_DECALS, applyDecals } from '../render/decals';")
    rep("  if (name === 'striker') applyDecals(root, STRIKER_DECALS);","  if (name === 'striker') applyDecals(root, STRIKER_DECALS);\n  if ((name as string) === 'block_zero') applyDecals(root, ZERO_DECALS);")
    rep("  const rig = new MechRig(root);\n","  const rig = new MechRig(root);\n  // ?weapon=rifle puts a weapon in the right hand, so the flight pose reads as intended\n  if (q.get('weapon')) rig.hold(await model(q.get('weapon') as ModelName, palette));\n")
    open(p,'w').write(s)
    
    p='src/render/decals.ts'; s=open(p).read()
    s=s.rstrip('\n')+'''
    
    /** Markings for the zero study (kit/blocks/zero.py). Placeholders, like the striker's. */
    export const ZERO_DECALS: DecalSpec[] = [
      { kind: 'number', text: '52', at: [2.9, 15.75, 1.0], dir: [0, -0.707, -0.707], size: [0.85, 0.6] },
      { kind: 'emblem', at: [-2.9, 15.75, 1.0], dir: [0, -0.707, -0.707], size: [0.7, 0.7] },
      { kind: 'stencil', text: 'TYPE 0', at: [2.4, 9.85, -0.05], dir: [-1, 0, 0], size: [0.55, 0.16] },
      { kind: 'stencil', text: 'TYPE 0', at: [-2.4, 9.85, -0.05], dir: [1, 0, 0], size: [0.55, 0.16] },
      { kind: 'number', text: '52', at: [2.4, 3.95, -0.12], dir: [-1, 0, 0], size: [0.46, 0.34], color: '#e9edf0' },
      { kind: 'stencil', text: 'DANGER EXHAUST', at: [0, 12.95, -4], dir: [0, 0, 1], size: [0.95, 0.14] },
      { kind: 'stencil', text: 'NO STEP', at: [0.3, 14.1, 3], dir: [0, 0, -1], size: [0.5, 0.13] },
      { kind: 'hazard', at: [1.2, 5.75, 3], dir: [0, 0, -1], size: [0.5, 0.1] },
      { kind: 'hazard', at: [-1.2, 5.75, 3], dir: [0, 0, -1], size: [0.5, 0.1] },
    ];
    '''
    open(p,'w').write(s)
    p='tools/look.mjs'; s=open(p).read()
    rep("if (flag('look')) params.set('look', flag('look'));","for (const k of ['look', 'weapon']) if (flag(k)) params.set(k, flag(k));")
    open(p,'w').write(s)
    p='tools/clip.mjs'; s=open(p).read()
    rep("for (const k of ['shots', 'look']) if (flag(k)) params.set(k, flag(k));","for (const k of ['shots', 'look', 'zoom', 'weapon']) if (flag(k)) params.set(k, flag(k));")
    open(p,'w').write(s)
    EOF
    (npm run -s kit -- block_zero 2>&1 | grep -E "^kit:|Error|Traceback|error|File \"|line [0-9]+" | head -20) && node tools/look.mjs block_zero --out review/out/fable52/r2/z4 --zoom 1.25 --weapon rifle 2>&1 | tail -3 && cd review/out/fable52/r2/z4 && ffmpeg -loglevel error -y -i f01.jpg -i f05.jpg -i f10.jpg -i f13.jpg -filter_complex hstack=inputs=4 -q:v 2 m1.jpg && cp m1.jpg [redacted: private path]/fable52-sortie/wip.jpg

    result, 3 lines

    19:33:37  r2 v3 read in flight: strong. fixing hands, calf jets, adding verniers, lamps, decals, rifle
    kit: block_zero -> ~/Projects/sortie-wt/fable52/public/assets/block_zero.glb (5163 KB, 6.1s)
    look: ~/Projects/sortie-wt/fable52/review/out/fable52/r2/z4/sheet.jpg, 16 frames, 36 s
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/z4/m1.jpg

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/z4/m1.jpg"
    }

    result

    no output

    m1_4.jpg
    m1_4.jpg
  • Bashcd ~/Projects/sortie-wt/fable52 && tools/log.sh "r2 v4 read: holds up with rifle, decals and lamps. starting final clip render" && sed -i 's|--size "${tile}x${tile}" --out|--size "${tile}x${tile}" ${CLIP_ARGS:-} --out|; s|# TILE=600 FPS=24 COLS=4 to change. REUSE=1 keeps tiles already rendered and their models.|# TILE=600 FPS=24 COLS=4 to change. REUSE=1 keeps tiles already rendered and their models.\n# CLIP_ARGS="--zoom 1.15 --weapon rifle" passes more flags to the clip tool.|' tools/sketch-sheet.sh && grep -n "CLIP_ARGS" tools/sketch-sheet.sh | head -3

    command

    cd ~/Projects/sortie-wt/fable52 && tools/log.sh "r2 v4 read: holds up with rifle, decals and lamps. starting final clip render" && sed -i 's|--size "${tile}x${tile}" --out|--size "${tile}x${tile}" ${CLIP_ARGS:-} --out|; s|#   TILE=600 FPS=24 COLS=4 to change. REUSE=1 keeps tiles already rendered and their models.|#   TILE=600 FPS=24 COLS=4 to change. REUSE=1 keeps tiles already rendered and their models.\n#   CLIP_ARGS="--zoom 1.15 --weapon rifle" passes more flags to the clip tool.|' tools/sketch-sheet.sh && grep -n "CLIP_ARGS" tools/sketch-sheet.sh | head -3

    result, 4 lines

    19:34:40  r2 v4 read: holds up with rifle, decals and lamps. starting final clip render
    7:#   CLIP_ARGS="--zoom 1.15 --weapon rifle" passes more flags to the clip tool.
    26:  (node tools/clip.mjs "$m" --shots orbit,turn --fps "$fps" --size "${tile}x${tile}" ${CLIP_ARGS:-} --out "$out/tiles/$m.mp4" 2>&1 | tail -1) &
    [This command modified 1 file you've previously read: tools/sketch-sheet.sh. Call Read before editing.]
  • Bashcd ~/Projects/sortie-wt/fable52 && TILE=800 COLS=3 CLIP_ARGS="--zoom 1.15 --weapon rifle" tools/sketch-sheet.sh review/out/fable52/r2/final S=striker A=block_zero_slab B=block_zero > review/out/fable52/r2/final.log 2>&1; tail -4 review/out/fable52/r2/final.log

    command

    cd ~/Projects/sortie-wt/fable52 && TILE=800 COLS=3 CLIP_ARGS="--zoom 1.15 --weapon rifle" tools/sketch-sheet.sh review/out/fable52/r2/final S=striker A=block_zero_slab B=block_zero > review/out/fable52/r2/final.log 2>&1; tail -4 review/out/fable52/r2/final.log

    result, 2 lines

    Command running in background with ID: brref8hy7. Output is being written to: [redacted: private path]/tasks/brref8hy7.output. You will be notified when it completes — do not poll that file or sleep while waiting. Read the file only if the user asks for progress, or if you need a line it prints before you can go on, such as a server's ready line or port.
    Session cwd remains ~/Projects/sortie-wt/fable52; directory changes made by the backgrounded command do not apply to subsequent commands.

Final clip is rendering in the background (striker, my slab pass, the skin mech, side by side). While it runs I'm setting up a Cycles hero still of the model in Blender.

  • Bashsed -n 1,40p src/render/palette.ts | cut -c1-200

    command

    sed -n 1,40p src/render/palette.ts | cut -c1-200

    result, 40 lines

    // Material roles are named in the kit (kit/lib.py). A palette paints every role; factions and
    // companies get their own palettes, the models stay the same.
    
    export type Role =
      | 'main' | 'accent' | 'trim' | 'frame' | 'joint' | 'visor' | 'metal' | 'sensor'
      | 'glow_eye' | 'glow_core' | 'glow_thruster' | 'glow_beam' | 'glow_exhaust'
      | 'hull' | 'hull_dark' | 'interior' | 'deck' | 'hazard' | 'light' | 'screen' | 'glass'
      | 'lamp_red' | 'lamp_green' | 'suit' | 'glow_hot'
      // raider salvage: paint from the donor machines, primer patches, bare rust and hand paint
      | 'donor_a' | 'donor_b' | 'donor_c' | 'primer' | 'rust' | 'handpaint' | 'warpaint'
      | 'crystal' | 'crystal_lit' | 'glow_violet'
      // markings on plates: pattern codes, service text, unit codes
      | 'stencil';
    
    export interface Paint {
      color: string;
      /** Emissive roles: brightness multiplier, values above 1 feed the bloom. */
      glow?: number;
      /** Physically based surface: roughness, metalness, clearcoat (paint sheen). */
      rough?: number;
      metal?: number;
      coat?: number;
      /** Rust blotches and streaks over the surface, 0..1 (raider salvage). */
      rust?: number;
      /** A lit surface that also gives off its own colour at this strength (lit from inside). */
      emit?: number;
      /** Painted roles: a lacquered finish, 0..1, kept under every look: roughness no higher than `rough`, less
       *  weathering of the colour, and from 0.5 a clear coat this strong. */
      lacquer?: number;
    }
    
    export type Palette = Record<Role, Paint>;
    
    const paint = (color: string, rough = 0.42, coat = 0.35): Paint => ({ color, rough, metal: 0, coat });
    const metal = (color: string, rough = 0.42, m = 0.85): Paint => ({ color, rough, metal: m });
    
    const base: Palette = {
      main: paint('#d9dce1'),
      accent: paint('#27527a'),
      trim: paint('#c9452f', 0.4),
  • Write~/Projects/sortie-wt/fable52/tools/hero.py

    input

    ~/Projects/sortie-wt/fable52/tools/hero.py
    
    """A hero still of one model, path traced in Blender (Cycles, CPU, headless), in the flight pose with
    its drives lit. The game draws the same model in real time. This is for seeing the form at full quality.
    
        blender -b --factory-startup -P tools/hero.py -- <model> <out.png> [--yaw 150] [--pitch -8] [--size 1600x2000] [--samples 96] [--pose flight]
    
    Colours are the merc palette's (src/render/palette.ts). Poses are the game's (src/render/mech.ts).
    """
    import math
    import os
    import sys
    
    import bpy
    from mathutils import Matrix, Vector
    
    args = sys.argv[sys.argv.index("--") + 1:]
    flag = lambda name, fallback: args[args.index(f"--{name}") + 1] if f"--{name}" in args else fallback
    model, out = args[0], os.path.abspath(args[1])
    W, H = (int(v) for v in flag("size", "1600x2000").split("x"))
    ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "public", "assets")
    
    PAINT = {  # role: colour, roughness, metal, clearcoat
        "main": ("#d9dce1", .42, 0, .35), "accent": ("#27527a", .42, 0, .35), "trim": ("#c9452f", .4, 0, .35),
        "frame": ("#5b6069", .48, .8, 0), "joint": ("#33363c", .55, .9, 0), "visor": ("#06080b", .22, .2, 1),
        "metal": ("#9aa0a8", .3, 1, 0), "sensor": ("#1d6b5c", .2, .3, 1), "hazard": ("#e3b62b", .6, 0, 0),
        "hull_dark": ("#4a4f57", .6, .6, 0), "stencil": ("#22252b", .6, 0, 0),
    }
    GLOW = {"glow_eye": ("#7ef7e6", 14), "glow_core": ("#7ef7e6", 9), "glow_thruster": ("#9cc6ff", 40), "lamp_red": ("#ff3a2e", 30),
            "lamp_green": ("#48ff6c", 30), "light": ("#fff3df", 8), "glow_hot": ("#eafffb", 12)}
    POSES = {
        "stand": {"upperarm.L": (0, 0, 6), "upperarm.R": (0, 0, -6), "forearm.L": (-12, 0, 0), "forearm.R": (-12, 0, 0)},
        "flight": {"pelvis": (6, 0, 0), "torso": (-4, 0, 0), "head": (-2, 0, 0), "thigh.L": (-22, 0, 4), "thigh.R": (6, 0, -3),
                   "shin.L": (42, 0, 0), "shin.R": (30, 0, 0), "foot.L": (8, 0, 0), "foot.R": (18, 0, 0), "upperarm.L": (-22, 0, 16),
                   "forearm.L": (-46, 0, 0), "upperarm.R": (-62, -8, -6), "forearm.R": (-26, 0, 0), "binder.L": (-6, 0, 0), "binder.R": (-6, 0, 0)},
    }
    C = Matrix(((1, 0, 0), (0, 0, -1), (0, 1, 0)))  # glTF axes to Blender axes
    
    
    def rgb(h):
        v = [int(h[i:i + 2], 16) / 255 for i in (1, 3, 5)]
        return [c / 12.92 if c <= .04045 else ((c + .055) / 1.055) ** 2.4 for c in v] + [1]
    
    
    def three_euler(deg):
        """A three.js XYZ Euler rotation in glTF axes, as a Blender quaternion."""
        rx, ry, rz = (math.radians(d) for d in deg)
        m = Matrix.Rotation(rx, 3, "X") @ Matrix.Rotation(ry, 3, "Y") @ Matrix.Rotation(rz, 3, "Z")
        return (C @ m @ C.transposed()).to_quaternion()
    
    
    def load(name):
        before = set(bpy.data.objects)
        bpy.ops.import_scene.gltf(filepath=os.path.join(ROOT, f"{name}.glb"))
        return [o for o in bpy.data.objects if o not in before]
    
    
    def paint(mat):
        role = mat.name.split(".")[0]
        mat.use_nodes = True
        nt = mat.node_tree
        nt.nodes.clear()
        o = nt.nodes.new("ShaderNodeOutputMaterial")
        if role in GLOW:
            e = nt.nodes.new("ShaderNodeEmission")
            e.inputs["Color"].default_value = rgb(GLOW[role][0])
            e.inputs["Strength"].default_value = GLOW[role][1]
            nt.links.new(e.outputs[0], o.inputs["Surface"])
            return
        colour, rough, metal, coat = PAINT.get(role, PAINT["frame"])
        b = nt.nodes.new("ShaderNodeBsdfPrincipled")
        b.inputs["Base Color"].default_value = rgb(colour)
        b.inputs["Metallic"].default_value = metal
        b.inputs["Coat Weight"].default_value = coat * .6
        b.inputs["Coat Roughness"].default_value = .15
        # paint is never one roughness: a soft cloud over it breaks the plastic look
        tex = nt.nodes.new("ShaderNodeTexCoord")
        noise = nt.nodes.new("ShaderNodeTexNoise")
        noise.inputs["Scale"].default_value = 1.4
        noise.inputs["Detail"].default_value = 6
        ramp = nt.nodes.new("ShaderNodeMapRange")
        ramp.inputs["To Min"].default_value = rough - .1
        ramp.inputs["To Max"].default_value = rough + .16
        nt.links.new(tex.outputs["Object"], noise.inputs["Vector"])
        nt.links.new(noise.outputs["Fac"], ramp.inputs["Value"])
        nt.links.new(ramp.outputs["Result"], b.inputs["Roughness"])
        # rounded edges in the shading, so every plate edge catches a line of light
        bev = nt.nodes.new("ShaderNodeBevel")
        bev.samples = 4
        bev.inputs["Radius"].default_value = .018
        nt.links.new(bev.outputs["Normal"], b.inputs["Normal"])
        if role == "hazard":
            wave = nt.nodes.new("ShaderNodeTexWave")
            wave.wave_type = "BANDS"
            wave.bands_direction = "DIAGONAL"
            wave.inputs["Scale"].default_value = 3.2
            step = nt.nodes.new("ShaderNodeMath")
            step.operation = "GREATER_THAN"
            step.inputs[1].default_value = .5
            mix = nt.nodes.new("ShaderNodeMix")
            mix.data_type = "RGBA"
            mix.inputs["A"].default_value = (.01, .01, .012, 1)
            mix.inputs["B"].default_value = rgb(colour)
            nt.links.new(tex.outputs["Object"], wave.inputs["Vector"])
            nt.links.new(wave.outputs["Fac"], step.inputs[0])
            nt.links.new(step.outputs[0], mix.inputs["Factor"])
            nt.links.new(mix.outputs["Result"], b.inputs["Base Color"])
        nt.links.new(b.outputs[0], o.inputs["Surface"])
    
    
    def plume_material():
        mat = bpy.data.materials.new("plume")
        mat.use_nodes = True
        nt = mat.node_tree
        nt.nodes.clear()
        o = nt.nodes.new("ShaderNodeOutputMaterial")
        tex = nt.nodes.new("ShaderNodeTexCoord")
        sep = nt.nodes.new("ShaderNodeSeparateXYZ")
        nt.links.new(tex.outputs["Generated"], sep.inputs[0])
        fall = nt.nodes.new("ShaderNodeMath")  # 1 at the nozzle, 0 at the tail
        fall.operation = "SUBTRACT"
        fall.inputs[0].default_value = 1
        nt.links.new(sep.outputs["Z"], fall.inputs[1])
        sq = nt.nodes.new("ShaderNodeMath")
        sq.operation = "POWER"
        sq.inputs[1].default_value = 2.2
        nt.links.new(fall.outputs[0], sq.inputs[0])
        lw = nt.nodes.new("ShaderNodeLayerWeight")  # bright through the middle, fading at the rim
        lw.inputs["Blend"].default_value = .35
        core = nt.nodes.new("ShaderNodeMath")
        core.operation = "SUBTRACT"
        core.inputs[0].default_value = 1
        nt.links.new(lw.outputs["Facing"], core.inputs[1])
        mul = nt.nodes.new("ShaderNodeMath")
        mul.operation = "MULTIPLY"
        nt.links.new(sq.outputs[0], mul.inputs[0])
        nt.links.new(core.outputs[0], mul.inputs[1])
        col = nt.nodes.new("ShaderNodeMix")
        col.data_type = "RGBA"
        col.inputs["A"].default_value = rgb("#2f6dff")
        col.inputs["B"].default_value = (1, 1, 1, 1)
        nt.links.new(sq.outputs[0], col.inputs["Factor"])
        e = nt.nodes.new("ShaderNodeEmission")
        e.inputs["Strength"].default_value = 30
        nt.links.new(col.outputs["Result"], e.inputs["Color"])
        t = nt.nodes.new("ShaderNodeBsdfTransparent")
        mix = nt.nodes.new("ShaderNodeMixShader")
        nt.links.new(mul.outputs[0], mix.inputs[0])
        nt.links.new(t.outputs[0], mix.inputs[1])
        nt.links.new(e.outputs[0], mix.inputs[2])
        nt.links.new(mix.outputs[0], o.inputs["Surface"])
        return mat
    
    
    def plume(node, mat):
        """A soft cone of light from a nozzle empty, along its exhaust direction."""
        d = node.get("dir")
        r = node.get("radius", .4)
        if d is None or "main" not in node.name:
            return
        length = r * 22
        bpy.ops.mesh.primitive_cone_add(vertices=24, radius1=r * .8, radius2=r * 2.1, depth=length)
        cone = bpy.context.object
        cone.data.materials.append(mat)
        cone.visible_shadow = False
        aim = (C @ Vector(d)).normalized()  # dir is stored in glTF axes, in the node's parent space
        cone.matrix_world = Matrix.Identity(4)
        cone.parent = node.parent
        cone.matrix_parent_inverse = Matrix.Identity(4)
        q = Vector((0, 0, 1)).rotation_difference(aim)
        cone.rotation_mode = "QUATERNION"
        cone.rotation_quaternion = q
        cone.location = node.location + aim * (length / 2)
        for p in cone.data.polygons:
            p.use_smooth = True
    
    
    bpy.ops.wm.read_factory_settings(use_empty=True)
    parts = load(model)
    by_name = {o.name: o for o in parts}
    for joint, deg in POSES[flag("pose", "flight")].items():
        o = by_name.get(joint)
        if o:
            o.rotation_mode = "QUATERNION"
            o.rotation_quaternion = three_euler(deg)
    if flag("weapon", "rifle") != "none" and "grip.R" in by_name:
        for o in load(flag("weapon", "rifle")):
            if o.parent is None:
                o.parent = by_name["grip.R"]
                o.matrix_parent_inverse = Matrix.Identity(4)
                o.rotation_mode = "QUATERNION"
                o.rotation_quaternion = three_euler((90, 0, 0))
                o.location = (0, 0, 0)
    for mat in bpy.data.materials:
        paint(mat)
    pm = plume_material()
    bpy.context.view_layer.update()
    for o in list(bpy.data.objects):
        if o.name.startswith("nozzle") and flag("pose", "flight") == "flight":
            plume(o, pm)
    bpy.context.view_layer.update()
    
    # light: one hard sun, a cold rim from behind, a dark sky with a little fill
    scene = bpy.context.scene
    world = bpy.data.worlds.new("space")
    scene.world = world
    world.use_nodes = True
    bg = world.node_tree.nodes["Background"]
    bg.inputs["Color"].default_value = (.012, .018, .04, 1)
    bg.inputs["Strength"].default_value = 1.0
    
    
    def sun(name, energy, colour, yaw, pitch, angle=1.5):
        d = bpy.data.lights.new(name, "SUN")
        d.energy = energy
        d.color = colour
        d.angle = math.radians(angle)
        o = bpy.data.objects.new(name, d)
        scene.collection.objects.link(o)
        o.rotation_euler = (math.radians(90 - pitch), 0, math.radians(yaw))
        return o
    
    
    yaw = float(flag("yaw", 150))
    sun("key", 5.5, (1, .96, .9), yaw + 70, 38)
    sun("rim", 3.2, (.55, .72, 1), yaw + 205, 12, 4)
    sun("fill", .5, (.6, .7, 1), yaw - 60, -20, 20)
    
    # camera: a long lens from behind and below, as the chase camera sees it but closer
    cam = bpy.data.objects.new("cam", bpy.data.cameras.new("cam"))
    scene.collection.objects.link(cam)
    scene.camera = cam
    cam.data.lens = 85
    cam.data.sensor_fit = "VERTICAL"
    cam.data.sensor_height = 36
    pitch = math.radians(float(flag("pitch", -6)))
    target = Vector((float(flag("tx", 0)), 0.3, float(flag("tz", 9.0))))
    dist = float(flag("dist", 62))
    a = math.radians(yaw)
    # yaw 0 looks at the front (the model faces -Y), 180 at the back
    cam.location = target + Vector((math.sin(a) * math.cos(pitch) * dist, -math.cos(a) * math.cos(pitch) * dist, math.sin(pitch) * dist))
    cam.rotation_euler = (target - cam.location).to_track_quat("-Z", "Y").to_euler()
    cam.data.clip_end = 2000
    
    scene.render.engine = "CYCLES"
    scene.cycles.device = "CPU"
    scene.cycles.samples = int(flag("samples", 96))
    scene.cycles.use_denoising = True
    scene.cycles.max_bounces = 6
    scene.render.resolution_x, scene.render.resolution_y = W, H
    scene.render.threads_mode = "FIXED"
    scene.render.threads = int(flag("threads", 6))
    scene.view_settings.view_transform = "AgX"
    scene.view_settings.look = "AgX - Medium High Contrast"
    scene.render.film_transparent = False
    scene.render.filepath = out
    scene.render.image_settings.file_format = "PNG"
    bpy.ops.render.render(write_still=True)
    print(f"hero: {out}")
    

    result, 1 line

    File created successfully at: ~/Projects/sortie-wt/fable52/tools/hero.py (file state is current in your context — no need to Read it back)
  • Bashmkdir -p review/out/fable52/r2/hero && time (blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t1.png --size 480x600 --samples 24 2>&1 | grep -E "hero:|Error|Traceback|error|line [0-9]+|KeyError|Time:" | tail -12)

    command

    mkdir -p review/out/fable52/r2/hero && time (blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t1.png --size 480x600 --samples 24 2>&1 | grep -E "hero:|Error|Traceback|error|line [0-9]+|KeyError|Time:" | tail -12)

    result, 5 lines

    hero: ~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t1.png
    
    real	0m21.214s
    user	0m26.398s
    sys	0m6.729s
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t1.png

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t1.png"
    }

    result

    no output

    t1.png
    t1.png
reasoning

The Cycles test passed on the first try at low resolution, with pose, drives and lighting all coming through. I'm softening the plumes and darkening the sky now, then rendering the hero still at full size while the clip finishes.

  • Bashpython3 - <<'EOF'

    command

    python3 - <<'EOF'
    p='tools/hero.py'; s=open(p).read()
    def rep(a,b):
        global s
        assert a in s, a[:60]
        s=s.replace(a,b)
    rep('''    e.inputs["Strength"].default_value = 30
        nt.links.new(col.outputs["Result"], e.inputs["Color"])''','''    e.inputs["Strength"].default_value = 16
        nt.links.new(col.outputs["Result"], e.inputs["Color"])
        soft = nt.nodes.new("ShaderNodeMath")  # never fully opaque: the frame shows through its own exhaust
        soft.operation = "MULTIPLY"
        soft.inputs[1].default_value = .6
        nt.links.new(mul.outputs[0], soft.inputs[0])
        mul = soft''')
    rep('''bg.inputs["Color"].default_value = (.012, .018, .04, 1)
    bg.inputs["Strength"].default_value = 1.0''','''bg.inputs["Strength"].default_value = 1.0
    wn = world.node_tree.nodes
    tc = wn.new("ShaderNodeTexCoord")
    vor = wn.new("ShaderNodeTexVoronoi")
    vor.inputs["Scale"].default_value = 260
    star = wn.new("ShaderNodeMath")
    star.operation = "LESS_THAN"
    star.inputs[1].default_value = .03
    sky = wn.new("ShaderNodeMix")
    sky.data_type = "RGBA"
    sky.inputs["A"].default_value = (.004, .006, .015, 1)
    sky.inputs["B"].default_value = (.9, .95, 1.2, 1)
    world.node_tree.links.new(tc.outputs["Generated"], vor.inputs["Vector"])
    world.node_tree.links.new(vor.outputs["Distance"], star.inputs[0])
    world.node_tree.links.new(star.outputs[0], sky.inputs["Factor"])
    world.node_tree.links.new(sky.outputs["Result"], bg.inputs["Color"])''')
    rep('dist = float(flag("dist", 62))','dist = float(flag("dist", 50))')
    open(p,'w').write(s)
    EOF
    blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t2.png --size 480x600 --samples 24 --pitch 4 2>&1 | grep -E "hero:|Error|Traceback|error|line [0-9]+" | tail -5

    result, 1 line

    hero: ~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t2.png
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t2.png

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t2.png"
    }

    result

    no output

    t2.png
    t2.png
  • Bashsed -i 's/ e.inputs\["Strength"\].default_value = 16/ e.inputs["Strength"].default_value = 10/; s/ soft.inputs\[1\].default_value = .6/ soft.inputs[1].default_value = .42/; s/ sq.inputs\[1\].default_value = 2.2/ sq.inputs[1].default_value = 3.0/; s/ length = r \* 22/ length = r * 30/; s/radius1=r \* .8, radius2=r \* 2.1/radius1=r * .75, radius2=r * 2.4/' tools/hero.py && (blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t3.png --size 400x500 --samples 16 --yaw 185 --pitch 6 2>&1 | grep -E "Error|Traceback|line [0-9]+" & blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t4.png --size 400x500 --samples 16 --yaw 32 --pitch 2 2>&1 | grep -E "Error|Traceback|line [0-9]+" & wait) ; cd review/out/fable52/r2/hero && ffmpeg -loglevel error -y -i t3.png -i t4.png -filter_complex hstack -q:v 2 t34.jpg

    command

    sed -i 's/    e.inputs\["Strength"\].default_value = 16/    e.inputs["Strength"].default_value = 10/; s/    soft.inputs\[1\].default_value = .6/    soft.inputs[1].default_value = .42/; s/    sq.inputs\[1\].default_value = 2.2/    sq.inputs[1].default_value = 3.0/; s/    length = r \* 22/    length = r * 30/; s/radius1=r \* .8, radius2=r \* 2.1/radius1=r * .75, radius2=r * 2.4/' tools/hero.py && (blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t3.png --size 400x500 --samples 16 --yaw 185 --pitch 6 2>&1 | grep -E "Error|Traceback|line [0-9]+" & blender -b --factory-startup -P tools/hero.py -- block_zero review/out/fable52/r2/hero/t4.png --size 400x500 --samples 16 --yaw 32 --pitch 2 2>&1 | grep -E "Error|Traceback|line [0-9]+" & wait) ; cd review/out/fable52/r2/hero && ffmpeg -loglevel error -y -i t3.png -i t4.png -filter_complex hstack -q:v 2 t34.jpg

    result, 1 line

    [This command modified 1 file you've previously read: ../../../../../tools/hero.py. Call Read before editing.]
  • Read~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t34.jpg

    input

    {
      "file_path": "~/Projects/sortie-wt/fable52/review/out/fable52/r2/hero/t34.jpg"
    }

    result

    no output

    t34.jpg
    t34.jpg