diff --git a/design/astral-projection/three/assets/makehuman-height-female-young-maxheight.target.gz b/design/astral-projection/three/assets/makehuman-height-female-young-maxheight.target.gz new file mode 100644 index 000000000..d5729aa69 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-height-female-young-maxheight.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-averageweight-idealproportions.target.gz b/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-averageweight-idealproportions.target.gz new file mode 100644 index 000000000..cffad7d5a Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-averageweight-idealproportions.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-minweight-idealproportions.target.gz b/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-minweight-idealproportions.target.gz new file mode 100644 index 000000000..33f794db1 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-proportions-female-young-averagemuscle-minweight-idealproportions.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-averageweight-idealproportions.target.gz b/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-averageweight-idealproportions.target.gz new file mode 100644 index 000000000..667f73b82 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-averageweight-idealproportions.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-minweight-idealproportions.target.gz b/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-minweight-idealproportions.target.gz new file mode 100644 index 000000000..5956ad563 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-proportions-female-young-minmuscle-minweight-idealproportions.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-source.json b/design/astral-projection/three/assets/makehuman-source.json index be44242cb..80f970ad5 100644 --- a/design/astral-projection/three/assets/makehuman-source.json +++ b/design/astral-projection/three/assets/makehuman-source.json @@ -7,11 +7,19 @@ "weights": "makehuman/data/rigs/default_weights.mhw", "weights_sha256": "0f3641d651ae3d00ad6b4ccee43142edb109d3bd909d27d9e4139ef1beed8625", "weights_licence": "CC0-1.0 (declared in the file header)", - "shape": "young adult female: makehuman/data/targets/macrodetails/{african,asian,caucasian}-female-young.target, one third each", + "shape": "slender young adult female: makehuman/data/targets/macrodetails/{african,asian,caucasian}-female-young.target, one third each; macro weight 0.25, muscle 0.35, height 0.65 and ideal proportions mixed as MakeHuman mixes them from macrodetails/universal-female-young-*, macrodetails/height/female-young-*-maxheight (the four are one file) and macrodetails/proportions/female-young-*-idealproportions; then smaller hands and feet and a slightly longer neck in Breeze scripts/prepare-practice-human.py", "shape_files": { - "makehuman-african-female-young.target.gz": "92d61eeb3c164b421fd5a7c3537ee45e7e1a51de4d49bf312e19c3df2be1d8fc", - "makehuman-asian-female-young.target.gz": "095fe79694fa19e1fe98d93009ec116199bd524e081c640351a10eccf2cca1eb", - "makehuman-caucasian-female-young.target.gz": "118379f6e8ba9266247fdb8788a20e1df40a239f97ced0b9905bcbcc74f6e820" + "makehuman-african-female-young.target.gz": "cb57ae84a34b9ed0cf2c4e65909337827ab3da40663c0aa6524f5fe345c4f182", + "makehuman-asian-female-young.target.gz": "47067a1afcaea462d751f1b8ad30e465b54dd22b3f28c8d8e7fc7344ddd7e02a", + "makehuman-caucasian-female-young.target.gz": "09559da0d7e7936b94f4898063620650e1e7489fa8459f859e67a70646482c62", + "makehuman-height-female-young-maxheight.target.gz": "db4021e632faa65c4a9b735fafe8bd2c84476047234557490985f6550e528071", + "makehuman-proportions-female-young-averagemuscle-averageweight-idealproportions.target.gz": "862192427280d8695e7a212ce5b73ced42d8d469ff822781c07066149467d952", + "makehuman-proportions-female-young-averagemuscle-minweight-idealproportions.target.gz": "0d80f8a42a0ecefe9bea6fe63808973dcb71db0b0717d50e9ad6247d1e60cac3", + "makehuman-proportions-female-young-minmuscle-averageweight-idealproportions.target.gz": "6cfa5b6c82ad68a0255f8e567162b15edc225d41cfbac3a632cf5308c02cb3dd", + "makehuman-proportions-female-young-minmuscle-minweight-idealproportions.target.gz": "304bb6ffb59e167d9a38d230336bea0996b12b27c3c76778f72257437f2eda08", + "makehuman-universal-female-young-averagemuscle-minweight.target.gz": "1c16fee7ff8a5f3e7fd746fc3a400fb6139ec8bba8ecb8d28397f469bdccc629", + "makehuman-universal-female-young-minmuscle-averageweight.target.gz": "1da31baecbf8b98430d8e6dca8000afe56d1063d112057d559c97f57a1b7eb7a", + "makehuman-universal-female-young-minmuscle-minweight.target.gz": "1a29b433bae8304b9254242226526799561eb2d25c691441cea599ebe6a04def" }, "shape_licence": "CC0-1.0 (declared in each target file header)" } diff --git a/design/astral-projection/three/assets/makehuman-universal-female-young-averagemuscle-minweight.target.gz b/design/astral-projection/three/assets/makehuman-universal-female-young-averagemuscle-minweight.target.gz new file mode 100644 index 000000000..08f37ba78 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-universal-female-young-averagemuscle-minweight.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-averageweight.target.gz b/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-averageweight.target.gz new file mode 100644 index 000000000..687bd30ea Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-averageweight.target.gz differ diff --git a/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-minweight.target.gz b/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-minweight.target.gz new file mode 100644 index 000000000..309f0b098 Binary files /dev/null and b/design/astral-projection/three/assets/makehuman-universal-female-young-minmuscle-minweight.target.gz differ diff --git a/design/figure-preview/figure_preview.zi b/design/figure-preview/figure_preview.zi index 68e43e6eb..a29d28787 100644 --- a/design/figure-preview/figure_preview.zi +++ b/design/figure-preview/figure_preview.zi @@ -65,10 +65,11 @@ PreviewState :: struct { edge: float32 contour: float32 granulation: float32 + colour: float32 } preview_state: PreviewState = .{playing = true, speed = 1.0, watercolor = true, zoom = 1.0, - bleed = 0.6, edge = 0.6, contour = 0.75, granulation = 0.55}; + bleed = 0.6, edge = 0.6, contour = 0.75, granulation = 0.55, colour = 0.6}; preview_media: FigureMedia; preview_backdrops: PreviewBackdrops; preview_library: PreviewLibrary; @@ -204,14 +205,14 @@ PreviewDraw :: (session: Session, viewport: Rectangle) -> s32 { } y += 54.0 preview_page = 1 - preview_page - at := Slider.Draw(session, Slider.Props.{.key = cast(u64)(15 + preview_page * 1000), .bounds = .{x, y, width, 64.0}, + at := Slider.Draw(session, Slider.Props.{.key = cast(u64)(15 + preview_page * 1000), .bounds = .{x, y, width, 56.0}, .label = "Time", .value_text = PreviewSeconds(state.seconds, duration, preview_time_text[preview_page][:]), .value = cast(float32)state.seconds, .min = 0.0, .max = cast(float32)duration}) if at.changed { state.seconds = cast(float64)at.value state.playing = false } - y += 72.0 + y += 62.0 speed_digits: [32]u8 speed := Slider.Draw(session, Slider.Props.{.key = 16, .bounds = .{x, y, width, 64.0}, .label = "Speed", .value_text = FormatDecimal(state.speed, 2, speed_digits[:]), .value = cast(float32)state.speed, @@ -219,7 +220,7 @@ PreviewDraw :: (session: Session, viewport: Rectangle) -> s32 { if speed.changed { state.speed = cast(float64)speed.value } - y += 72.0 + y += 62.0 state.watercolor = Toggle.Draw(session, Toggle.Props.{.key = 17, .bounds = .{x, y, width, 40.0}, .label = "Watercolor finish", .value = state.watercolor}).value y += 46.0 @@ -237,6 +238,9 @@ PreviewDraw :: (session: Session, viewport: Rectangle) -> s32 { y += 60.0 state.granulation = Slider.Draw(session, Slider.Props.{.key = 20, .bounds = .{x, y, width, 56.0}, .label = "Granulation", .value = state.granulation, .max = 1.0}).value + y += 60.0 + state.colour = Slider.Draw(session, Slider.Props.{.key = 26, .bounds = .{x, y, width, 56.0}, + .label = "Colour strength", .value = state.colour, .max = 1.0}).value y += 66.0 status := "CPU" if preview_failed { @@ -267,6 +271,7 @@ PreviewStyle :: () -> FigureStyle { style.wash.edge = cast(float64)preview_state.edge style.wash.contour = cast(float64)preview_state.contour style.wash.granulation = cast(float64)preview_state.granulation + style.wash.saturation = cast(float64)preview_state.colour return style } @@ -324,10 +329,11 @@ PreviewPaintFigure :: (session: Session, area: Rectangle) { PreviewKey :: (width: s32, height: s32) -> u64 { state := *preview_state digest: u64 = 1469598103934665603 - values: [14]float64 = .[cast(float64)state.practice, cast(float64)state.item, state.seconds, + values: [15]float64 = .[cast(float64)state.practice, cast(float64)state.item, state.seconds, state.turn, state.lift, state.zoom, ifx state.watercolor then 1.0 else 0.0, ifx state.current then 1.0 else 0.0, cast(float64)state.bleed, cast(float64)state.edge, - cast(float64)state.contour, cast(float64)state.granulation, cast(float64)width, cast(float64)height] + cast(float64)state.contour, cast(float64)state.granulation, cast(float64)state.colour, + cast(float64)width, cast(float64)height] for value: values { bits := cast(u64)(value * 1000003.0 + 0.5) digest = digest * 1099511628211 + bits diff --git a/design/figure-preview/preview_capture.zi b/design/figure-preview/preview_capture.zi index efd551ba7..9f77aec18 100644 --- a/design/figure-preview/preview_capture.zi +++ b/design/figure-preview/preview_capture.zi @@ -63,7 +63,7 @@ PreviewCompose :: (body: *FigurePainter, twin: *FigurePainter, media: *FigureMed // The lying astral body needs the bedroom floor raised to her. zoom := ifx practice == PREVIEW_ASTRAL then 1.5 else 1.0 focus := ifx practice == PREVIEW_ASTRAL then 0.85 else 0.62 - if !FigureBackdropCover(out, backdrop, width, height, zoom, focus) { + if !FigureBackdropCover(out, backdrop, width, height, zoom, focus, FigureVivid(style.wash)) { return false } } else { diff --git a/design/figure-preview/ziran.lock b/design/figure-preview/ziran.lock index 71b71e84a..b0abc4911 100644 --- a/design/figure-preview/ziran.lock +++ b/design/figure-preview/ziran.lock @@ -81,15 +81,6 @@ "ref": "360553150917f352e49e1beb78917370792ccaef", "url": "https://github.com/ziranlang/image-codec.git" }, - { - "commit": "b0464fdd00e2225836363de7a12efaa769070065", - "dependencies": {"kryon": "p1e41122208040e0f"}, - "dependency_refs": {"kryon": "199b51c97c2aba67367308c3dc98126692b476a8"}, - "id": "p6a12717b013ea028", - "name": "practices", - "ref": "b0464fdd00e2225836363de7a12efaa769070065", - "url": "https://github.com/waozixyz/practices.git" - }, { "commit": "b141d9c45db236335351c8a4b2a14b3ade27c937", "dependencies": {}, @@ -99,6 +90,15 @@ "source": true, "url": "https://aomedia.googlesource.com/aom" }, + { + "commit": "3e7c7bffd2e0021277977e7b15b4ced4683d53c7", + "dependencies": {"kryon": "p1e41122208040e0f"}, + "dependency_refs": {"kryon": "199b51c97c2aba67367308c3dc98126692b476a8"}, + "id": "p79c25fede49784ba", + "name": "practices", + "ref": "3e7c7bffd2e0021277977e7b15b4ced4683d53c7", + "url": "https://github.com/waozixyz/practices.git" + }, { "commit": "2611e727e226a2af22dfb7f10bf224bd2f1a3d30", "dependencies": {"av1": "p5d7d12505a42f7b3", "dav1d": "pb24767b9eb34d961", "image_codec": "p69c0e968ae5735d9", "libaom": "p74ab3cb6eb3b86fa", "libavif": "p57c0272208aae8db"}, @@ -137,8 +137,8 @@ } ], "root": { - "dependencies": {"kryon": "p1e41122208040e0f", "practices": "p6a12717b013ea028"}, - "dependency_refs": {"kryon": "199b51c97c2aba67367308c3dc98126692b476a8", "practices": "b0464fdd00e2225836363de7a12efaa769070065"}, + "dependencies": {"kryon": "p1e41122208040e0f", "practices": "p79c25fede49784ba"}, + "dependency_refs": {"kryon": "199b51c97c2aba67367308c3dc98126692b476a8", "practices": "3e7c7bffd2e0021277977e7b15b4ced4683d53c7"}, "name": "figure_preview" }, "toolchain": { diff --git a/design/figure-preview/ziran.toml b/design/figure-preview/ziran.toml index 0b50558e4..6a02badb5 100644 --- a/design/figure-preview/ziran.toml +++ b/design/figure-preview/ziran.toml @@ -15,4 +15,4 @@ ref = "199b51c97c2aba67367308c3dc98126692b476a8" # The shared figure and its media (anatomy, textures, Tai Chi course). [dependencies.practices] git = "https://github.com/waozixyz/practices.git" -ref = "b0464fdd00e2225836363de7a12efaa769070065" +ref = "3e7c7bffd2e0021277977e7b15b4ced4683d53c7" diff --git a/plans/2026-11-17-astral-projection.md b/plans/2026-11-17-astral-projection.md index a741953b0..e42623ce0 100644 --- a/plans/2026-11-17-astral-projection.md +++ b/plans/2026-11-17-astral-projection.md @@ -3,8 +3,8 @@ The owner wants one perfected character used everywhere: Tai Chi, Sun Salutation, Workout and astral projection, native on Ziran and Kryon without raylib, looking like a hand-painted watercolor illustration. The -character is the practices package's `figure/` (pinned practices b0464fdd: -female MakeHuman CC0 surface in loose cloth shells, dual-quaternion rig, +character is the practices package's `figure/` (pinned practices 3e7c7bff: +slender female MakeHuman CC0 surface in loose cloth shells, dual-quaternion rig, generated painted textures and face, three-wash shaders, painterly finish, painted backdrops, Ziran tests). The style target is practices `figure/design/reference/style-target.webp`. The live tuning tool is @@ -24,8 +24,9 @@ painted backdrops, Ziran tests). The style target is practices `build/practice-compare/side-by-side/` (current flat figure beside the new character, same moments and cameras), then tune from that feedback. - Character work still open: - - The hair still reads close to a cap; give it looser volume and a few - strands at the temples, as in the style target. + - Seen from the front at practice sizes the hair still reads as a close + cap; the style target's loose volume and stray strands need cards or + painted strands that do not read as sideburns. - The skirt swings rigidly from the waist and only by the pelvis's tilt: in a deep squat and a forward fold it bulges. Secondary sway and a simple collision with the thighs would help. @@ -41,7 +42,7 @@ painted backdrops, Ziran tests). The style target is practices - Breeze adoption, after the shared Kryon repin (lane -7, plot, entity, game2d, css and apps on one Kryon; Breeze audio on Ziran std audio): - Make Breeze's `practices` dependency a package pinned at or after - b0464fdd. + 3e7c7bff. - Move `PreviewJoints` (solver joints to `FigureJoints`) beside the solver. - Paint Tai Chi, Sun Salutation, Workout and astral with `FigurePaint` diff --git a/scripts/prepare-practice-human.py b/scripts/prepare-practice-human.py index 6a5b9c493..8e498843a 100644 --- a/scripts/prepare-practice-human.py +++ b/scripts/prepare-practice-human.py @@ -14,8 +14,8 @@ ROOT = Path(__file__).resolve().parents[1] # originals kept in OUTPUT/source (provenance.json there): each swatch is # moved to the style target's palette, made to tile without a seam and # sized for phones. -SWATCHES = {'skin': ('#e8c3a0', 0.45), 'tunic': ('#8fa483', 0.9), 'trousers': ('#6a6a8f', 0.85), - 'hair': ('#76513a', 1.0), 'sash': ('#e3dabd', 0.6)} +SWATCHES = {'skin': ('#efbe96', 0.45), 'tunic': ('#7aa46a', 0.9), 'trousers': ('#4e5090', 0.85), + 'hair': ('#7a4a2a', 1.0), 'sash': ('#ecd6a2', 0.6)} BACKDROPS = ('tai-chi', 'sun-salutation', 'workout', 'astral') def prepare_textures(folder): @@ -30,7 +30,7 @@ def prepare_textures(folder): # Keep the brushwork's light and dark, painted in the target colour, # with a little of the swatch's own colour variation. shade = (light-light.mean())*contrast - tinted = goal+shade[:, :, None]+(picture-mean-(light-light.mean())[:, :, None])*0.25 + tinted = goal+shade[:, :, None]+(picture-mean-(light-light.mean())[:, :, None])*0.45 # A copy offset by half covers the seam at the edges. shifted = np.roll(tinted, (256, 256), axis=(0, 1)) ramp = 1-np.abs(np.arange(512)/511*2-1) @@ -40,7 +40,7 @@ def prepare_textures(folder): # The face painting takes the skin swatch's colour on its cheeks and # brow, keeping its own eyes, brows, lips and blush. face = np.asarray(Image.open(source/'face.webp').convert('RGB').resize((512, 512), Image.LANCZOS), dtype=np.float64) - skin = face[106:155, 196:318].reshape(-1, 3).mean(axis=0) + skin = face[118:155, 230:285].reshape(-1, 3).mean(axis=0) goal = np.array([int(SWATCHES['skin'][0][at:at+2], 16) for at in (1, 3, 5)], dtype=np.float64) face = face*goal/skin # Outside the painted face (its paper, hair and ears) the painting @@ -55,7 +55,11 @@ def prepare_textures(folder): for name in BACKDROPS: picture = Image.open(source/f'backdrop-{name}.webp').convert('RGB') picture.thumbnail((1280, 1280), Image.LANCZOS) - picture.save(folder/'backdrops'/f'{name}.webp', quality=85, method=6) + # Richer washes; the near-white paper barely moves. + pixels = np.asarray(picture, dtype=np.float64) + light = (pixels @ np.array([0.30, 0.59, 0.11]))[:, :, None] + pixels = np.clip(light+(pixels-light)*1.3, 0, 255) + Image.fromarray(pixels.astype(np.uint8)).save(folder/'backdrops'/f'{name}.webp', quality=85, method=6) parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--output', type=Path, required=True) @@ -79,12 +83,68 @@ all_vertices = np.asarray(vertices, dtype=np.float64) # MakeHuman's base mesh is its gender-neutral average. Her body and face take # MakeHuman's own CC0 young-adult female macro shape: the three ethnic # female-young targets in equal shares, as MakeHuman mixes them by default. -for race in ('african', 'asian', 'caucasian'): - target = ROOT / f'design/astral-projection/three/assets/makehuman-{race}-female-young.target.gz' +# She is slender: MakeHuman's weight slider at 0.25, muscle at 0.35, height +# at 0.85 and ideal proportions, mixed as MakeHuman mixes its macro targets +# (each weight-and-muscle pair by the product of their shares). +def apply_target(name, share): + target = ROOT / f'design/astral-projection/three/assets/makehuman-{name}.target.gz' for line in gzip.open(target, 'rt'): if line.strip() and not line.startswith('#'): index, dx, dy, dz = line.split() - all_vertices[int(index)] += np.array([float(dx), float(dy), float(dz)])/3 + all_vertices[int(index)] += np.array([float(dx), float(dy), float(dz)])*share + +for race in ('african', 'asian', 'caucasian'): + apply_target(f'{race}-female-young', 1/3) +BODY_WEIGHT, BODY_MUSCLE, BODY_HEIGHT, BODY_PROPORTIONS = 0.25, 0.35, 0.65, 1.0 +for muscle, muscle_share in (('minmuscle', 1-BODY_MUSCLE/0.5), ('averagemuscle', BODY_MUSCLE/0.5)): + for weight, weight_share in (('minweight', 1-BODY_WEIGHT/0.5), ('averageweight', BODY_WEIGHT/0.5)): + pair = muscle_share*weight_share + if (muscle, weight) != ('averagemuscle', 'averageweight'): + apply_target(f'universal-female-young-{muscle}-{weight}', pair) + apply_target(f'proportions-female-young-{muscle}-{weight}-idealproportions', pair*BODY_PROPORTIONS) +# MakeHuman's four maxheight targets for these pairs are the same file. +apply_target('height-female-young-maxheight', (BODY_HEIGHT-0.5)/0.5) + +# MakeHuman's own CC0 rig weights for this mesh (folded onto this figure's +# bones further on). +weights_file = ROOT / 'design/astral-projection/three/assets/makehuman-default-weights.mhw.gz' +rig = json.loads(gzip.open(weights_file, 'rt').read()) +assert rig['license'] == 'CC0' + +def rig_share(accept): + share = np.zeros(len(all_vertices)) + for name, entries in rig['weights'].items(): + if accept(name): + for vertex, weight in entries: + share[vertex] += weight + return np.clip(share, 0, 1) + +def helpers(prefix): + return sorted({index for group, faces in groups.items() if group.startswith(prefix) for face in faces + for index in face}) + +def group_centre(name): + return all_vertices[sorted({index for face in groups['joint-'+name] for index in face})].mean(axis=0) + +# Graceful hands and feet: each a little smaller about the wrist or ankle, +# with its finger and toe joints, so the rig still fits. +metres = 1.7/np.ptp(all_vertices[sorted({i for f in groups['body'] for i in f})][:, 1]) +for side in ('L', 'R'): + prefix = 'l' if side == 'L' else 'r' + for pivot_name, stems, joint_prefix, factor in ( + ('hand', ('wrist', 'metacarpal', 'finger'), f'joint-{prefix}-finger', 0.90), + ('ankle', ('foot', 'toe'), f'joint-{prefix}-toe', 0.92)): + pivot = group_centre(f'{prefix}-{pivot_name}') + share = rig_share(lambda name: name.endswith('.'+side) and name.split('.')[0].startswith(stems)) + all_vertices += (pivot-all_vertices)*((1-factor)*share)[:, None] + tips = helpers(joint_prefix) + all_vertices[tips] = pivot+(all_vertices[tips]-pivot)*factor +# A longer neck: everything the head carries rises a little, fading in up +# the neck and away from the shoulders. +neck_base, skull = group_centre('neck'), group_centre('head') +rise = np.clip((all_vertices[:, 1]-neck_base[1])/(skull[1]-neck_base[1]), 0, 1) +rise = rise*rise*(3-2*rise)*np.clip(1-(np.abs(all_vertices[:, 0])-0.05/metres)/(0.05/metres), 0, 1) +all_vertices[:, 1] += rise*0.014/metres ids = sorted({index for face in groups['body'] for index in face}) lookup = {old: index for index, old in enumerate(ids)} body = all_vertices[ids] @@ -166,10 +226,6 @@ for index, point in enumerate(positions): # MakeHuman's own CC0 rig weights for this mesh, folded onto these 46 bones. # The procedural weights above remain only for vertices the rig leaves out. -weights_file = ROOT / 'design/astral-projection/three/assets/makehuman-default-weights.mhw.gz' -rig = json.loads(gzip.open(weights_file, 'rt').read()) -assert rig['license'] == 'CC0' - def rig_bones(name): side = 0 if name.endswith('.L') else 1 base = 4 + side*21 @@ -307,7 +363,7 @@ def hairline(points): x, y, z = points[:, 0], points[:, 1], points[:, 2] turn = np.degrees(np.arctan2(np.abs(x), z-0.02)) height = eye_height+np.interp(turn, [0, 20, 45, 65, 85, 105, 125, 180], - [0.064, 0.062, 0.052, 0.034, 0.008, -0.014, -0.045, -0.080]) + [0.064, 0.062, 0.052, 0.034, 0.012, 0.002, -0.022, -0.045]) value = y-height ears = (y < eye_height+0.002) & (np.abs(x) > 0.070) value = np.where(ears, np.minimum(value, 0.070-np.abs(x)), value) @@ -437,17 +493,23 @@ extras = [] hair_faces = triangles[np.all(regions[triangles] == 3, axis=1)] used = np.unique(hair_faces) depth = hairline(positions[used]) -crown = np.clip((positions[used, 1]-eye_height-0.02)/0.08, 0, 1) +# Neat swept-back hair: close over the ears and at the hairline, fuller +# towards the back of the crown where it gathers into the bun. +top = np.clip((positions[used, 1]-eye_height-0.03)/0.07, 0, 1) +back = np.clip((joint('head')[2]+0.01-positions[used, 2])/0.08, 0, 1) sides = np.clip(np.abs(positions[used, 0])/0.07, 0, 1) -thickness = (0.010+0.016*crown+0.005*sides)*np.clip(depth/0.045, 0, 1)**1.1 +above = np.clip((positions[used, 1]-eye_height)/0.03, 0, 1) +thickness = (0.005+0.008*top+0.010*top*back+0.008*sides*above)*np.clip(depth/0.04, 0, 1)**0.9 shell = positions[used]+normals[used]*thickness[:, None] remap = np.full(len(positions), -1, dtype=np.int64) remap[used] = np.arange(len(used)) shell_faces = remap[hair_faces] extras.append((shell, vertex_normals(shell, shell_faces), np.full(len(shell), 3), shell_faces)) rings, segments = 10, 18 -bun_center = np.array([0.0, eye_height+0.078, -0.056]) -bun_radii = np.array([0.040, 0.036, 0.033]) +# A low, round bun at the back of the head. +nape = positions[used][np.abs(positions[used, 1]-(eye_height+0.045)) < 0.01] +bun_center = np.array([0.0, eye_height+0.045, nape[:, 2].min()-0.016]) +bun_radii = np.array([0.046, 0.040, 0.036]) units = np.array([[np.sin(np.pi*ring/rings)*np.cos(2*np.pi*at/segments), np.cos(np.pi*ring/rings), np.sin(np.pi*ring/rings)*np.sin(2*np.pi*at/segments)] for ring in range(rings+1) for at in range(segments)]) @@ -525,6 +587,9 @@ for j, h in enumerate(grid_y): top = int(np.searchsorted(grid_y, armpit_y)) for j in range(top-1, -1, -1): hang[j] = np.maximum(hang[j], hang[j+1]) +# Soft cloth settles part of the way back onto her below the widest place. +hang = 0.65*hang+0.35*np.array([(np.column_stack((s[:, 0], s[:, 2]-trunk_z(h))) @ directions.T).max(axis=0) + for h, s in ((h, slab(h)) for h in grid_y)]) for _ in range(3): hang = 0.5*hang+0.25*np.roll(hang, 1, axis=1)+0.25*np.roll(hang, -1, axis=1) hang[1:-1] = 0.5*hang[1:-1]+0.25*hang[:-2]+0.25*hang[2:] @@ -608,8 +673,8 @@ used = np.unique(top_faces) p, n = positions[used], normals[used] bust_y = slab((waist_y+armpit_y)/2, half=0.06)[:, 1][np.argmax(slab((waist_y+armpit_y)/2, half=0.06)[:, 2])] sleeve = smooth((arm[used]-0.2)/0.6) -lift = np.interp(p[:, 1], [waist_y, bust_y, neck_height-0.04], [0.022, 0.012, 0.005])*(1-sleeve) -lift += (0.010+0.045*arm_progress(p)**1.4)*sleeve +lift = np.interp(p[:, 1], [waist_y, bust_y, neck_height-0.04], [0.016, 0.010, 0.005])*(1-sleeve) +lift += (0.008+0.040*arm_progress(p)**1.6)*sleeve q = p+n*lift[:, None] rel = np.column_stack((q[:, 0], q[:, 2]-trunk_z(p[:, 1]))) theta = np.arctan2(rel[:, 0], rel[:, 1]) @@ -629,7 +694,7 @@ fall = (rows_y[0]-rows_y)/(rows_y[0]-rows_y[-1]) skirt = [] for y, f in zip(rows_y, fall): hem = 0.012*np.sin(3*angles+0.7)*f**4 - r = hanging_radius(angles, np.full(K, y))+0.022+0.035*f**1.5 + r = hanging_radius(angles, np.full(K, y))+0.016+0.028*f**1.5 skirt.append(np.column_stack((np.sin(angles)*r, np.full(K, y)+hem, trunk_z(y)+np.cos(angles)*r))) skirt = np.vstack(skirt) faces_of = facing_out(skirt, grid_faces(len(rows_y), K, True), trunk_axis) @@ -647,7 +712,7 @@ cloth.append((skirt, vertex_normals(skirt, faces_of), rows, shares, 1, faces_of, # The sash round the waist and its two tails hanging in front. band_y = waist_y+np.array([0.035, 0.012, -0.012, -0.035]) band = np.vstack([np.column_stack((np.sin(angles)*r, np.full(K, y), trunk_z(y)+np.cos(angles)*r)) - for y, r in ((y, hanging_radius(angles, np.full(K, y))+0.022+bulge) + for y, r in ((y, hanging_radius(angles, np.full(K, y))+0.016+bulge) for y, bulge in zip(band_y, (0.005, 0.010, 0.010, 0.005)))]) faces_of = facing_out(band, grid_faces(len(band_y), K, True), trunk_axis) rows, shares = strongest(nearest_weights(band)) @@ -659,7 +724,7 @@ for tail, (turn, length) in enumerate(((0.30, 0.30), (0.46, 0.25))): f = np.clip((rows_y[0]-y)/(rows_y[0]-rows_y[-1]), 0, 1) for side in (-1, 1): angle = turn+0.12*step+side*0.022/0.15 - r = hanging_radius(np.array([angle]), np.array([y]))[0]+0.022+0.035*f**1.5+0.008+0.004*tail + r = hanging_radius(np.array([angle]), np.array([y]))[0]+0.016+0.028*f**1.5+0.008+0.004*tail strip.append([np.sin(angle)*r, y, trunk_z(y)+np.cos(angle)*r]) strip = np.array(strip) faces_of = facing_out(strip, grid_faces(9, 2, False), trunk_axis) @@ -673,7 +738,7 @@ leg_faces = triangles[np.all(regions[triangles] == 2, axis=1) & np.all(triangles used = np.unique(leg_faces) p, n = positions[used], normals[used] down = np.clip((hip_height-0.04-p[:, 1])/(hip_height-0.04-np.mean(ankles)), 0, 1) -lift = 0.012+0.042*smooth(down/0.7)-0.028*smooth((down-0.86)/0.14) +lift = 0.010+0.030*smooth(down/0.7)-0.018*smooth((down-0.86)/0.14) q = p+n*lift[:, None] remap = np.full(len(positions), -1, dtype=np.int64) remap[used] = np.arange(len(used)) @@ -743,7 +808,7 @@ for points, vertex_normal, rows, shares, region, faces_of, source, hanging in cl # The face is painted by face.webp, projected from the front onto the # head: its eyes, mouth and the mesh's own match exactly, and the painting # fades out towards the ears, the hairline and under the chin. -FACE = dict(size=(1254, 1254), right_eye=(420, 586), left_eye=(840, 586), mouth=(630, 884)) +FACE = dict(size=(1254, 1254), right_eye=(430, 576), left_eye=(826, 576), mouth=(630, 858)) face_ready = FACE['right_eye'] != (0, 0) mouth_point = np.array([0.0, joint('mouth')[1]-0.027]) mesh_marks = np.array([joint('r-eye')[:2], joint('l-eye')[:2], mouth_point]) @@ -788,4 +853,7 @@ metadata = {'format':'PFIG0002', 'vertices':len(positions), 'triangles':len(tria 'license':'CC0-1.0', 'bone_names':[f"{b['role']}/{b['side']}/{b['finger']}/{b['segment']}" for b in bones]} (output/'anatomy.json').write_text(json.dumps(metadata,indent=2)+'\n') print(f"Prepared {len(positions)} vertices, {len(triangles)} triangles, {len(bones)} bones; {len(blob)} bytes") -print(f"waist {waist_y:.3f} bust {bust_y:.3f} armpit {armpit_y:.3f} hem {hem_y:.3f}") +crown = positions[:body_count, 1].max() +# The eyes sit halfway down the head. +print(f"waist {waist_y:.3f} bust {bust_y:.3f} armpit {armpit_y:.3f} hem {hem_y:.3f}; " + f"{1.7/(2*(crown-eye_height)):.2f} heads tall")