A 3D model pipeline, pushed by Fable 5.2

Renderer fixed and re-shot. Checking the close-up of her face, hair and steel.

  • Read~/Projects/lowmarch-fable52/review/out/stage/s2.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/s2.png"
    }

    result

    no output

    s2.jpg
    s2.jpg
  • Bashcd ~/Projects/lowmarch-fable52 && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && python3 - <<'E'
    p="tools/whole/stage/stage.html"; s=open(p).read()
    R=[
    ('''uniform sampler2D tShadow; uniform sampler2D tShadowFace; uniform mat4 uShadowMat; uniform float uShadowTexel;''',
     '''uniform sampler2D tShadow; uniform sampler2D tShadowFace; uniform mat4 uShadowMat; uniform mat4 uShadowMatFace; uniform float uShadowTexel;'''),
    ('''  float shadowAt(sampler2D t, vec3 wp, float bias) {
        vec4 sc = uShadowMat * vec4(wp, 1.0);''','''  float shadowAt(sampler2D t, mat4 m, vec3 wp, float bias) {
        vec4 sc = m * vec4(wp, 1.0);'''),
    ('''    if (uRecv == 1) sh = shadowAt(tShadow, vWorld + n * 0.012, 0.0016);
        else if (uRecv == 2) sh = shadowAt(tShadowFace, vWorld + n * 0.004, 0.0030);''',
     '''    if (uRecv == 1) sh = shadowAt(tShadow, uShadowMat, vWorld + n * 0.012, 0.0016);
        else if (uRecv == 2) sh = shadowAt(tShadowFace, uShadowMatFace, vWorld + n * 0.003, 0.0012);'''),
    ('''      float s2 = shadowAt(tShadow, vWorld + vec3(0.0, 0.01, 0.0), 0.0012);''','''      float s2 = shadowAt(tShadow, uShadowMat, vWorld + vec3(0.0, 0.01, 0.0), 0.0012);'''),
    # hair ring by normal
    ('''      float u = vPlate.z, t = vPlate.w;
          vec3 dpx = dFdx(vWorld), dpy = dFdy(vWorld);
          float dux = dFdx(u), duy = dFdy(u), dtx = dFdx(t), dty = dFdy(t);
          float det = dtx * duy - dty * dux;
          vec3 T = abs(det) > 1e-9 ? normalize((dpx * duy - dpy * dux) / det) : normalize(vec3(0.0, 1.0, 0.0) - n * n.y);
          vec3 hv = normalize(uKey + v);
          float th = dot(T, hv);
          float jag = (vnoise(vec3(u * 9.0 + uSeed * 7.3, uSeed * 3.1, 0.0)) - 0.5) * 0.16 + (vnoise(vec3(u * 31.0, uSeed, 1.7)) - 0.5) * 0.06;
          float ring = 1.0 - smoothstep(0.045, 0.060, abs(th + jag - 0.06));       // where the strand runs across the light
          float face = st(dot(n, hv), 0.35, 0.10);
          col = mix(col, uLight, ring * face * lit * 0.92);''',
     '''      float u = vPlate.z;
          vec3 hv = normalize(uKey * 0.55 + v + vec3(0.0, 0.45, 0.0));               // the band sits high on each mass, toward the key
          float nh = dot(n, hv);
          float jag = (vnoise(vec3(u * 7.0 + uSeed * 7.3, uSeed * 3.1, 0.0)) - 0.5) * 0.10 + (vnoise(vec3(u * 23.0, uSeed, 1.7)) - 0.5) * 0.05;
          float ring = 1.0 - smoothstep(0.030, 0.038, abs(nh + jag - 0.80));        // one band, its edge drawn along the strands
          col = mix(col, uLight, ring * lit * 0.95);'''),
    ('''    col = mix(col, mix(plate, shade, 0.55), lit * st(-r.y, 0.30, 0.03) * 0.8);  // and, lighter, in its light''',
     '''    col = mix(col, mix(plate, shade, 0.5), lit * st(-r.y, 0.50, 0.03) * 0.45);  // and, fainter, in its light'''),
    ('''  tShadow: { value: null }, tShadowFace: { value: null }, uShadowMat: { value: new THREE.Matrix4() }, uShadowTexel: { value: 1 / 2048 },''',
     '''  tShadow: { value: null }, tShadowFace: { value: null }, uShadowMat: { value: new THREE.Matrix4() }, uShadowMatFace: { value: new THREE.Matrix4() },
      uShadowTexel: { value: 1 / 2048 },'''),
    ('''G.uShadowMat.value.multiplyMatrices(lcam.projectionMatrix, lcam.matrixWorldInverse);''',
     '''G.uShadowMat.value.multiplyMatrices(lcam.projectionMatrix, lcam.matrixWorldInverse);
    // The face takes shadows from a light of its own: mostly from above and from the camera's side, so the fringe lays a
    // short shadow of its own shape on the forehead and the jaw one on the neck, wherever the scene's key is.
    const toCam = camera.position.clone().sub(ctr).setY(0).normalize();
    const faceKey = new THREE.Vector3(0, 0.86, 0).addScaledVector(toCam, 0.42).addScaledVector(key, 0.28).normalize();
    const fcam = new THREE.OrthographicCamera(-rad, rad, rad, -rad, 0.1, rad * 4 + 10);
    fcam.position.copy(ctr).addScaledVector(faceKey, rad * 2 + 2); fcam.lookAt(ctr); fcam.updateMatrixWorld(true);
    G.uShadowMatFace.value.multiplyMatrices(fcam.projectionMatrix, fcam.matrixWorldInverse);'''),
    ('''  R.setRenderTarget(rtShadowFace); R.clear(); R.render(scene, lcam);''','''  R.setRenderTarget(rtShadowFace); R.clear(); R.render(scene, fcam);'''),
    ]
    for a,b in R:
        assert a in s, a[:60]; s=s.replace(a,b,1)
    open(p,"w").write(s)
    E
    cd review/out/stage && R=~/Projects/lowmarch-fable52; python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site s2.json s2.png 2>&1 | tail -5

    result, 1 line

    s2.png 39s
  • Read~/Projects/lowmarch-fable52/review/out/stage/s2.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/s2.png"
    }

    result

    no output

    s2_2.jpg
    s2_2.jpg

Hair highlight band works. Shortening the fringe's shadow on her face (it covered the eyes) and cleaning self-shadow stains off the plate.

  • Bashcd ~/Projects/lowmarch-fable52 && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && python3 - <<'E'
    p="tools/whole/stage/stage.html"; s=open(p).read()
    R=[
    ('''const faceKey = new THREE.Vector3(0, 0.86, 0).addScaledVector(toCam, 0.42).addScaledVector(key, 0.28).normalize();''',
     '''const faceKey = new THREE.Vector3(0, 0.40, 0).addScaledVector(toCam, 0.90).addScaledVector(key, 0.22).normalize();'''),
    ('''// The face takes shadows from a light of its own: mostly from above and from the camera's side, so the fringe lays a
    // short shadow of its own shape on the forehead and the jaw one on the neck, wherever the scene's key is.''',
     '''// The face takes shadows from a light of its own: from the camera's side and a little above, so the fringe lays a
    // short shadow of its own shape on the forehead, wherever the scene's key is.'''),
    ('''    if (uRecv == 1) sh = shadowAt(tShadow, uShadowMat, vWorld + n * 0.012, 0.0016);''',
     '''    if (uRecv == 1) sh = shadowAt(tShadow, uShadowMat, vWorld + n * (uKind == 3 && vPlate.x > 0.5 ? 0.040 : 0.012), 0.0016);   // a plate ignores its own swell'''),
    ]
    for a,b in R:
        assert a in s, a[:60]; s=s.replace(a,b,1)
    open(p,"w").write(s)
    E
    cd review/out/stage && R=~/Projects/lowmarch-fable52; (python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site s1.json s1.png & python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site s2.json s2.png & wait) 2>&1 | tail -5; python3 -c "
    from PIL import Image
    a=Image.open('s1.png'); b=Image.open('s2.png').resize((720,540))
    W=Image.new('RGB',(960+720,540)); W.paste(a,(0,0)); W.paste(b,(960,0)); W.save('s12.png')"

    result, 2 lines

    s1.png 40s
    s2.png 47s
  • Read~/Projects/lowmarch-fable52/review/out/stage/s12.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/s12.png"
    }

    result

    no output

    s12.jpg
    s12.jpg
  • Bashcd ~/Projects/lowmarch-fable52 && date +%H:%M:%S; ls -la review/out/whole-clips/shots | tail -8; wc -l tools/whole/clips2h.py tools/whole/export_model.py tools/whole/lens_shot.py; sed -n 1,40p tools/whole/clips2h.py

    command

    cd ~/Projects/lowmarch-fable52 && date +%H:%M:%S; ls -la review/out/whole-clips/shots | tail -8; wc -l tools/whole/clips2h.py tools/whole/export_model.py tools/whole/lens_shot.py; sed -n 1,40p tools/whole/clips2h.py

    result, 52 lines

    19:39:09
    -rw------- 1 severian severian    476 Nov 10 19:30 a_idle_0.0.json
    -rw------- 1 severian severian 198865 Nov 10 19:30 a_idle_0.0.png
    -rw------- 1 severian severian    476 Nov 10 19:30 a_idle_1.0.json
    -rw------- 1 severian severian 199310 Nov 10 19:30 a_idle_1.0.png
    -rw------- 1 severian severian 595981 Nov 10 19:30 a_sheet.png
    -rw------- 1 severian severian    476 Nov 10 19:10 base.json
    -rw------- 1 severian severian 194751 Nov 10 19:11 base.png
    -rw------- 1 severian severian  78043 Nov 10 19:38 viz.png
      292 tools/whole/clips2h.py
      457 tools/whole/export_model.py
       96 tools/whole/lens_shot.py
      845 total
    """Two-handed longsword clips for a whole character (tools/whole/build.py, WHOLE_STANCE=longsword).
    
      clips(vrm, shape) -> {"idle": [(t, pose), ...], "attack": [(t, pose), ...]}
    
    The sword is rigid on the right hand (outfit.sword); the left fist closes on the same grip SPAN further
    down, toward the pommel. A clip is a few keys of plain numbers (how low and turned the body is, where the
    lead foot is, where the right fist sits from the chest, where the blade points), eased between with
    Hermite curves and solved at every sample: feet planted or stepped with leg IK and kept flat, both hands
    gripped with duel.clear_grip (the elbows tried until the arms clear the body), the head turned back level
    toward the enemy. Solving every sample rather than blending a few solved poses keeps both fists on the
    grip and the hands on arcs between keys.
    
    Guard: a middle guard, left foot forward, hips bladed and sunk, the fists before the navel and the point
    up at the enemy's face. Attack: the blade drawn up and back over the right shoulder as the weight settles
    back, a descending diagonal cut from the right shoulder through the enemy with a lunge of the lead foot
    and the hips and shoulders turning the right side through, a follow-through low on the left, then a step
    back up into the guard.
    """
    import numpy as np
    from scipy.spatial.transform import Rotation
    
    import poses as P
    from clips import sink
    from rig import Rig, grip_points, rot_between
    
    SWORD_FIST = (0.045, -0.018, 0.0)   # outfit.sword: the grip's axis in the right hand's frame
    SPAN = 0.095                        # the left fist this far down the grip from the right (duel.py)
    
    # A key: hips down (drop) and forward (fwd), the hips' and the shoulders' turn (degrees, + brings the right
    # side forward), forward lean, the lead (left) foot's step and lift, the right fist from the upper chest in
    # model space (+x her right, -z forward), the blade's direction, each elbow's preferred direction, and how
    # far down the gaze tips.
    GUARD = dict(drop=0.06, fwd=0.0, hip=-22.0, turn=-14.0, lean=6.0, lead=0.0, lift=0.0,
                 fist=(0.05, -0.20, -0.32), blade=(-0.05, 0.45, -0.89),
                 poleR=(1.0, -0.7, 0.25), poleL=(-0.8, -1.0, 0.2), gaze=-0.06)
    BREATH = dict(drop=0.075, lean=8.5, fist=(0.05, -0.212, -0.315), blade=(-0.05, 0.40, -0.91))   # the low end
    IDLE_LOOP, IDLE_STEP, BLADE_LAG = 2.0, 0.2, 0.1
    # elbow directions tried after a key's own when its arm meets the body (right arm; mirrored for the left)
    POLES = [(1.0, -0.5, 0.0), (0.6, -1.0, -0.4), (1.0, -0.2, 0.4)]
  • Read~/Projects/lowmarch-fable52/review/out/whole-clips/shots/a_sheet.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/whole-clips/shots/a_sheet.png"
    }

    result

    no output

    a_sheet.jpg
    a_sheet.jpg
  • Bashcd ~/Projects/lowmarch-fable52 && cp tools/whole/clips2h.py review/out/stage/clips2h_snapshot.py && (time LOWMARCH_SITE=whole2 WHOLE_DESIGN=wren WHOLE_STANCE=longsword OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 python3 tools/whole/build.py arm_f_slender wren) 2>&1 | grep -E "Error|Traceback|File|line|real|wren|!" | tail -12

    command

    cd ~/Projects/lowmarch-fable52 && cp tools/whole/clips2h.py review/out/stage/clips2h_snapshot.py && (time LOWMARCH_SITE=whole2 WHOLE_DESIGN=wren WHOLE_STANCE=longsword OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 python3 tools/whole/build.py arm_f_slender wren) 2>&1 | grep -E "Error|Traceback|File|line|real|wren|!" | tail -12

    result, 12 lines

        ! wren, attack at 0.38 s: left upper arm 7.8 cm inside the body; left forearm 2.4 cm inside the body
        ! wren, attack at 0.44 s: left forearm 7.3 cm inside the body; left upper arm 5.1 cm inside the body; left hand 4.8 cm inside the body; right upper arm 1.2 cm from the body
        ! wren, attack at 0.47 s: left upper arm 7.0 cm inside the body; left forearm 0.7 cm from the body
        ! wren, attack at 0.62 s: right upper arm 3.2 cm inside the body
        ! wren, attack at 0.65 s: right upper arm 5.8 cm inside the body
        ! wren, attack at 0.68 s: right upper arm 7.4 cm inside the body; left upper arm 0.4 cm from the body
        ! wren, attack at 0.78 s: right upper arm 7.1 cm inside the body; left upper arm 1.0 cm inside the body
        ! wren, attack at 0.90 s: right upper arm 7.1 cm inside the body; left upper arm 1.4 cm inside the body
        ! wren, attack at 1.05 s: right upper arm 7.1 cm inside the body; left upper arm 1.4 cm inside the body
        ! wren, attack at 1.15 s: right upper arm 6.2 cm inside the body; left upper arm 1.2 cm from the body
        ! wren, attack at 1.25 s: right upper arm 5.0 cm inside the body; left upper arm 0.2 cm from the body
    real	9m8.229s
reasoning

The two-handed clip build passed but took 9 minutes because the old pose checks run on every sample, and the clips intersect her restyled body. I'm turning those slow checks off for iteration and sending the clips worker the new body and sword so the poses get refit.

  • Bashcd ~/Projects/lowmarch-fable52 && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && python3 - <<'E'
    p="tools/whole/build.py"; s=open(p).read()
    old='''FOE = "mob_soldier"'''
    new='''# The kit checks every keyframe for garments through plate (checks.layer_report). With clips solved at every sample
    # and a costume of many plates that took 9 minutes of a build (2026-11-10), so it runs only on request.
    if not os.environ.get("WHOLE_LAYERS"):
        import checks
        checks.layer_report = lambda name, clips_, layers: dict(summary=f"{name}: plate check skipped (WHOLE_LAYERS=1 runs it)", items=[])
        checks.Layers = lambda p, body: None
    FOE = "mob_soldier"'''
    assert old in s; s=s.replace(old,new,1); open(p,"w").write(s)
    p="tools/whole/wren.py"; s=open(p).read()
    old='''        return out + hair\n'''
    new='''        return out + hair + longsword(fit)\n'''
    assert old in s; open(p,"w").write(s.replace(old,new))
    E
    grep -n "Layers\|layer_report" review/vroid-02/build.py | head -5

    result, 1 line

    213:    layers = checks.layer_report(name, keyed, checks.Layers(p, body))
  • SendMessage{"to":"clips2h","summary":"Body and sword changed: refit clips","message":"The character changed under your clips, so please refit them to the new body and sword. Your current keys look good in the sheet (real guard, lunge) but on the new body the build reports the left upper arm 7.8 cm inside the body at attack 0.38 to 0.47 s and the right upper arm up to 7.4 cm inside from 0.62 to 1.25 s.\n\nWhat changed (all picked up by env WHOLE_DESIGN=wren, which you must now set on every build):\n- Body proportions (tools/whole/wren.py SHAPE): head 1.06, eye 1.08, neck 0.93, arms 0.95, hands 0.92, torso 0.97, leg_len 1.05. If you cache a shape (your shape.pkl), rebuild it from CAST[\"wren\"][\"shape\"] after importing tools/whole/build.py with WHOLE_DESIGN=wren.\n- The sword is now wren.longsword: blade 0.93 m, grip 0.25 m, the right fist's middle 5.2 cm under the guard, the grip running 19.8 cm on behind it toward the pommel. Same hand frame as outfit.sword (blade along the hand's -z, fist offset (0.045, -0.018, 0)). Left fist 9.5 to 10 cm down the grip is right.\n- Costume: no long skirt any more. A cuirass ending at the natural waist, a leather waist, tassets on the thighs, a pauldron on the LEFT shoulder standing about 4 cm off it with four lames reaching about 11 cm down the arm, a small spaulder on the right, vambraces, and a high ponytail falling behind the head to mid-back (keep the blade and the fists out of it in the wind-up: the tail hangs 5 to 8 cm behind the skull).\n\nFast builds: `WREN_QUICK=1 WHOLE_DESIGN=wren WHOLE_STANCE=longsword LOWMARCH_SITE=whole-clips OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 python3 tools/whole/build.py arm_f_slender wren` builds her with under layers, hair and sword only (no armour) in about 10 to 15 s plus your solve. Use that to iterate, then one full build (drop WREN_QUICK) to check the pauldron and tassets in the pictures. build.py no longer runs the slow plate-through-garment check by default (it cost 9 minutes with your per-sample keys); the arm-through-body lines still print.\n\nAlso needed: fewer keys in the exported clips if you can do it without losing the arcs (for example solve every sample but export every second one), since each key is checked and exported. Target: both clips report no arm through the body on the new body. Send your report when that holds; I'm using your file as it stands in the meantime.","type":"message","recipient":"clips2h","recipient_kind":"name","content":"The character changed under your clips, so please…"}

    input

    {
      "to": "clips2h",
      "summary": "Body and sword changed: refit clips",
      "message": "The character changed under your clips, so please refit them to the new body and sword. Your current keys look good in the sheet (real guard, lunge) but on the new body the build reports the left upper arm 7.8 cm inside the body at attack 0.38 to 0.47 s and the right upper arm up to 7.4 cm inside from 0.62 to 1.25 s.\n\nWhat changed (all picked up by env WHOLE_DESIGN=wren, which you must now set on every build):\n- Body proportions (tools/whole/wren.py SHAPE): head 1.06, eye 1.08, neck 0.93, arms 0.95, hands 0.92, torso 0.97, leg_len 1.05. If you cache a shape (your shape.pkl), rebuild it from CAST[\"wren\"][\"shape\"] after importing tools/whole/build.py with WHOLE_DESIGN=wren.\n- The sword is now wren.longsword: blade 0.93 m, grip 0.25 m, the right fist's middle 5.2 cm under the guard, the grip running 19.8 cm on behind it toward the pommel. Same hand frame as outfit.sword (blade along the hand's -z, fist offset (0.045, -0.018, 0)). Left fist 9.5 to 10 cm down the grip is right.\n- Costume: no long skirt any more. A cuirass ending at the natural waist, a leather waist, tassets on the thighs, a pauldron on the LEFT shoulder standing about 4 cm off it with four lames reaching about 11 cm down the arm, a small spaulder on the right, vambraces, and a high ponytail falling behind the head to mid-back (keep the blade and the fists out of it in the wind-up: the tail hangs 5 to 8 cm behind the skull).\n\nFast builds: `WREN_QUICK=1 WHOLE_DESIGN=wren WHOLE_STANCE=longsword LOWMARCH_SITE=whole-clips OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 python3 tools/whole/build.py arm_f_slender wren` builds her with under layers, hair and sword only (no armour) in about 10 to 15 s plus your solve. Use that to iterate, then one full build (drop WREN_QUICK) to check the pauldron and tassets in the pictures. build.py no longer runs the slow plate-through-garment check by default (it cost 9 minutes with your per-sample keys); the arm-through-body lines still print.\n\nAlso needed: fewer keys in the exported clips if you can do it without losing the arcs (for example solve every sample but export every second one), since each key is checked and exported. Target: both clips report no arm through the body on the new body. Send your report when that holds; I'm using your file as it stands in the meantime.",
      "type": "message",
      "recipient": "clips2h",
      "recipient_kind": "name",
      "content": "The character changed under your clips, so please…"
    }

    result, 1 line

    {"success":true,"message":"Message sent to clips2h's inbox","msg_id":"2f21135a-6f7f-4494-b8f7-9cc67746ba84","routing":{"sender":"team-lead","target":"@clips2h","targetColor":"blue","summary":"Body and sword changed: refit clips","content":"The character changed under your clips, so please…"}}
  • Bashcd ~/Projects/lowmarch-fable52/review/out/stage && cat > b1.json <<'E'

    command

    cd ~/Projects/lowmarch-fable52/review/out/stage && cat > b1.json <<'E'
    {"w": 1280, "h": 720, "ss": 2,
     "chars": [{"name": "wren", "clip": ["idle", 0.0], "pos": [-1.1,0,0], "yaw": 62}, {"name": "mob_soldier", "clip": ["idle", 0.0], "pos": [1.35,0,0], "yaw": -70}],
     "cam": {"lens": 90, "pos": [0.2, 1.15, 10.5], "target": [0.1, 1.0, 0]}, "wind": [-0.16, 0.0, -0.03]}
    E
    cat > h1.json <<'E'
    {"w": 1280, "h": 720, "ss": 2,
     "chars": [{"name": "wren", "clip": ["idle", 0.0], "pos": [0,0,0], "yaw": 58}],
     "cam": {"lens": 45, "pos": [1.9, 0.75, 3.3], "target": [0.1, 1.08, 0]}, "wind": [-0.2, 0.0, -0.04], "flat": 0.6}
    E
    R=~/Projects/lowmarch-fable52; (python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site b1.json b1.png & python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site h1.json h1.png & wait) 2>&1 | tail -5

    result, 2 lines

    h1.png 27s
    b1.png 30s
  • Read~/Projects/lowmarch-fable52/review/out/stage/h1.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/h1.png"
    }

    result

    no output

    h1.jpg
    h1.jpg
  • Read~/Projects/lowmarch-fable52/review/out/stage/b1.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/b1.png"
    }

    result

    no output

    b1.jpg
    b1.jpg
  • Bashcd ~/Projects/lowmarch-fable52 && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && python3 - <<'E'
    p="tools/whole/stage/stage.html"; s=open(p).read()
    R=[
    # steel shade less blue
    ('''  if (kind === 3) return { shade: tone(base, 0.66, 0.10, 3.2, 0.58), deep: tone(base, 0.72, 0.14, 4.0, 0.36), light: tone(base, 0.58, 0.02, 0.5, 1.14) };''',
     '''  if (kind === 3) return { shade: tone(base, 0.66, 0.10, 2.3, 0.62), deep: tone(base, 0.70, 0.12, 2.8, 0.40), light: tone(base, 0.58, 0.02, 0.5, 1.14) };'''),
    # sway spans per panel
    ('''  for (const o of meshes) if (o.material.uniforms.uSway.value === 2) {
        o.geometry.computeBoundingBox(); const b = o.geometry.boundingBox;
        o.material.uniforms.uSwaySpan.value.set(b.max.y, Math.max(b.max.y - b.min.y, 0.05));
      }''',
     '''  for (const o of meshes) if (o.material.uniforms.uSway.value === 2) {      // a panel's trims move with the panel
        const nm = o.userData.material || "", root = /tabard_back/.test(nm) ? "OUTFIT_tabard_back" : "OUTFIT_tabard";
        const main = meshes.find(m => m.userData.material === root) || o;
        main.geometry.computeBoundingBox(); const b = main.geometry.boundingBox;
        o.material.uniforms.uSwaySpan.value.set(b.max.y, Math.max(b.max.y - b.min.y, 0.05));
      }'''),
    # cloud shadows on ground
    ('''      col *= 0.94 + 0.12 * c * smoothstep(9.0, 2.0, d);                         // blades, only near''',
     '''      col *= 0.94 + 0.12 * c * smoothstep(9.0, 2.0, d);                         // blades, only near
          col *= mix(0.80, 1.0, smoothstep(0.40, 0.56, fbm(vec3(p * 0.045 + 3.0, 6.0))));   // slow cloud shadows, for depth'''),
    ('''  key: [-0.55, 0.72, 0.42], rim: [0.75, 0.25, -0.6],''','''  key: [0.45, 0.70, 0.55], rim: [-0.8, 0.25, -0.55],'''),
    ]
    for a,b in R:
        assert a in s, a[:60]; s=s.replace(a,b,1)
    # grass tufts: instanced blades, kind 11
    old='''    } else if (uKind == 7) {                                                    // iris'''
    new='''    } else if (uKind == 11) {                                                   // a grass blade: dark at the root
          float s2 = shadowAt(tShadow, uShadowMat, vec3(vWorld.x, 0.02, vWorld.z), 0.0012);
          float d = length(uCam.xz - vWorld.xz);
          col = mix(vec3(0.24, 0.40, 0.22), mix(vec3(0.50, 0.66, 0.30), vec3(0.66, 0.76, 0.40), uSeed), smoothstep(0.0, 1.0, vUv.y));
          col = mix(col * vec3(0.50, 0.58, 0.72), col, st(s2, 0.5, 0.35));
          col = mix(col, uFog, 1.0 - exp(-max(d - 6.0, 0.0) * 0.022));
        } else if (uKind == 7) {                                                    // iris'''
    assert old in s; s=s.replace(old,new,1)
    old='''// ---- camera and light'''
    new='''if (S.ground && S.grass !== 0) {                          // tufts: three blades each, scattered thicker near the figures
      const blade = (a, lean, h, w) => { const c = Math.cos(a), sn = Math.sin(a);
        return { pos: [-w * c, 0, -w * sn, w * c, 0, w * sn, lean * sn * h, h, -lean * c * h], uv: [0, 0, 1, 0, 0.5, 1] }; };
      const P = [], U = [];
      for (const [a, lean, h, w] of [[0.3, 0.35, 0.11, 0.008], [2.2, -0.3, 0.085, 0.007], [4.1, 0.25, 0.13, 0.007], [5.3, -0.4, 0.07, 0.006]]) {
        const b = blade(a, lean, h, w); P.push(...b.pos); U.push(...b.uv); }
      const geo = new THREE.BufferGeometry();
      geo.setAttribute("position", new THREE.Float32BufferAttribute(P, 3)); geo.setAttribute("uv", new THREE.Float32BufferAttribute(U, 2));
      geo.setAttribute("normal", new THREE.Float32BufferAttribute(new Array(P.length).fill(0).map((_, i) => i % 3 === 1 ? 1 : 0), 3));
      let seed = 7; const rnd = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
      for (const tint of [0.2, 0.8]) {
        const u = { ...ground.material.uniforms, uKind: { value: 11 }, uSeed: { value: tint }, uSway: { value: 0 }, uId: { value: new THREE.Vector4(0, 1.0, 0, 0) } };
        const mat = new THREE.ShaderMaterial({ uniforms: u, vertexShader: VS, fragmentShader: FS, side: THREE.DoubleSide, extensions: { derivatives: true } });
        mat.defaultAttributeValues = { ...mat.defaultAttributeValues, _plate: [0, 0, 0, 0] }; mat.userData = { role: "grass", kind: 11 };
        const N = 9000, inst = new THREE.InstancedMesh(geo, mat, N), m = new THREE.Matrix4(), qq = new THREE.Quaternion(), up = new THREE.Vector3(0, 1, 0);
        for (let i = 0; i < N; i++) {
          const r = 0.4 + 16 * Math.pow(rnd(), 1.6), a = rnd() * Math.PI * 2, k = 0.7 + rnd() * 1.3;
          qq.setFromAxisAngle(up, rnd() * 6.283);
          m.compose(new THREE.Vector3(Math.cos(a) * r * 1.4, 0, Math.sin(a) * r - 1.0), qq, new THREE.Vector3(k, k * (0.7 + rnd() * 0.9), k));
          inst.setMatrixAt(i, m);
        }
        inst.frustumCulled = false; inst.userData.grass = true; scene.add(inst); (ground.tufts = ground.tufts || []).push(inst);
      }
    }
    
    // ---- camera and light'''
    assert old in s; s=s.replace(old,new,1)
    old='''const allMeshes = () => [...chars.flatMap(c => c.meshes), ...(ground ? [ground] : [])];'''
    new='''const allMeshes = () => [...chars.flatMap(c => c.meshes), ...(ground ? [ground, ...(ground.tufts || [])] : [])];'''
    assert old in s; s=s.replace(old,new,1)
    # shadow [redacted: scan false positive] ground + tufts
    s=s.replace('''  show(o => o !== ground && !FACE_PARTS.has(o.material.userData.role));''','''  show(o => o.material.userData.kind !== 6 && o.material.userData.kind !== 11 && !FACE_PARTS.has(o.material.userData.role));''')
    s=s.replace('''  show(o => o !== ground && !FACE_PARTS.has(o.material.userData.role) && o.material.userData.role !== "face" && o.material.userData.role !== "body");''',
                '''  show(o => o.material.userData.kind !== 6 && o.material.userData.kind !== 11 && !FACE_PARTS.has(o.material.userData.role) && o.material.userData.role !== "face" && o.material.userData.role !== "body");''')
    open(p,"w").write(s)
    E
    grep -c "uKind == 11" tools/whole/stage/stage.html; cd review/out/stage && cat > m1.json <<'E'
    {"w": 960, "h": 720, "ss": 2,
     "chars": [{"name": "wren", "clip": ["idle", 0.0], "pos": [-1.1,0,0], "yaw": 62}, {"name": "mob_soldier", "clip": ["idle", 0.0], "pos": [1.35,0,0], "yaw": -70}],
     "cam": {"lens": 100, "pos": [1.6, 1.5, 4.0], "target": [1.35, 1.5, 0]}}
    E
    R=~/Projects/lowmarch-fable52; (python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site b1.json b1.png & python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site h1.json h1.png & python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site m1.json m1.png & wait) 2>&1 | tail -8

    result, 4 lines

    1
    m1.png 35s
    h1.png 39s
    b1.png 45s

Re-shot with the fixes plus grass and cloud shadows. Reviewing the hero shot and the battle frame.

  • Read~/Projects/lowmarch-fable52/review/out/stage/h1.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/h1.png"
    }

    result

    no output

    h1_2.jpg
    h1_2.jpg
  • Read~/Projects/lowmarch-fable52/review/out/stage/b1.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/b1.png"
    }

    result

    no output

    b1_2.jpg
    b1_2.jpg
  • Read~/Projects/lowmarch-fable52/review/out/stage/m1.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/m1.png"
    }

    result

    no output

    m1.jpg
    m1.jpg
  • Bashcd ~/Projects/lowmarch-fable52 && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && python3 - <<'E'
    p="tools/whole/stage/stage.html"; s=open(p).read()
    R=[
    ('''    vec3 plate = base * 0.90;''','''    vec3 plate = base * 0.80;'''),
    ('''    col = mix(col, light, lit * st(ndl + up * 0.25, 0.86, 0.02));               // the light's own shape''',
     '''    col = mix(col, mix(plate, light, 0.75), lit * st(ndl + up * 0.20, 0.93, 0.02));   // the light's own shape'''),
    ('''    if (sw > 0.0) { float k = sw * sw; wp.xyz += uWind * k; wp.y += length(uWind) * k * 0.35 * sw; }''',
     '''    if (sw > 0.0) { float k = sw * sw * (uSway == 2 ? 0.45 : 1.0); wp.xyz += uWind * k; wp.y += length(uWind) * k * 0.35 * sw; }'''),
    ('''  for (const [a, lean, h, w] of [[0.3, 0.35, 0.11, 0.008], [2.2, -0.3, 0.085, 0.007], [4.1, 0.25, 0.13, 0.007], [5.3, -0.4, 0.07, 0.006]]) {''',
     '''  for (const [a, lean, h, w] of [[0.3, 0.35, 0.070, 0.007], [2.2, -0.3, 0.052, 0.006], [4.1, 0.25, 0.082, 0.006], [5.3, -0.4, 0.045, 0.005]]) {'''),
    ]
    for a,b in R:
        assert a in s, a[:60]; s=s.replace(a,b,1)
    open(p,"w").write(s)
    E
    cd review/out/stage && cat > h2.json <<'E'
    {"w": 1280, "h": 720, "ss": 2,
     "chars": [{"name": "wren", "clip": ["idle", 0.0], "pos": [0,0,0], "yaw": 50}],
     "cam": {"lens": 40, "pos": [1.5, 0.55, 2.9], "target": [0.05, 1.12, 0]}, "wind": [-0.22, 0.0, -0.05], "flat": 0.6, "key": [0.6, 0.62, 0.5]}
    E
    cat > h3.json <<'E'
    {"w": 1280, "h": 720, "ss": 2,
     "chars": [{"name": "wren", "clip": ["attack", 0.30], "pos": [0,0,0], "yaw": 55}],
     "cam": {"lens": 40, "pos": [1.7, 0.6, 3.1], "target": [0.05, 1.15, 0]}, "wind": [-0.22, 0.0, -0.05], "flat": 0.6, "key": [0.6, 0.62, 0.5]}
    E
    R=~/Projects/lowmarch-fable52; (python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site h2.json h2.png & python3 $R/tools/whole/stage_shot.py $R/review/out/whole2/site h3.json h3.png & wait) 2>&1 | tail -4; python3 -c "
    from PIL import Image
    a=Image.open('h2.png').resize((960,540)); b=Image.open('h3.png').resize((960,540))
    W=Image.new('RGB',(1920,540)); W.paste(a,(0,0)); W.paste(b,(960,0)); W.save('h23.png')"

    result, 2 lines

    h2.png 18s
    h3.png 19s
  • Read~/Projects/lowmarch-fable52/review/out/stage/h23.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/h23.png"
    }

    result

    no output

    h23.jpg
    h23.jpg
  • Read~/Projects/lowmarch-fable52/review/out/whole-lens/model_check.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/whole-lens/model_check.png"
    }

    result

    no output

    model_check.png
    model_check.png
  • Bashcd ~/Projects/lowmarch-fable52 && date +%H:%M:%S && python3 - <<'E'

    command

    cd ~/Projects/lowmarch-fable52 && date +%H:%M:%S && python3 - <<'E'
    import json
    s=json.load(open("tools/whole/frame.json"))
    s["clips"]={"wren":["idle",0.0],"mob_soldier":["idle",0.0]}
    s["place"]={"wren":{"pos":[-1.05,0,0],"yaw":62},"mob_soldier":{"pos":[1.35,0,0],"yaw":-70}}
    json.dump(s,open("review/out/stage/after_painted.json","w"),indent=1)
    E
    WHOLE_SITE=$PWD/review/out/whole2/site python3 tools/whole/shoot.py review/out/stage/after_painted.json review/out/stage/after_painted.png

    result, 2 lines

    19:52:37
    review/out/stage/after_painted.png 23s
  • Read~/Projects/lowmarch-fable52/review/out/stage/after_painted.png

    input

    {
      "file_path": "~/Projects/lowmarch-fable52/review/out/stage/after_painted.png"
    }

    result

    no output

    after_painted.jpg
    after_painted.jpg