[PR #7880] [MERGED] fix(avatars): mesh avatar mouths fit the drawing and close between words #7979

Closed
opened 2026-10-24 04:09:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7880
Author: @SpicyMarinara
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/mesh-painted-mouth-fit-20261020


📝 Commits (1)

  • 7c1c262 fix(avatars): fit painted mesh mouths and follow speech openness

📊 Changes

12 files changed (+371 additions, -48 deletions)

View changed files

📝 docs/agents/avatars.md (+1 -1)
📝 packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-face.ts (+2 -1)
📝 packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-renderer.ts (+6 -1)
📝 packages/server/src/services/avatars/generation/mesh-layer-builder.ts (+68 -1)
📝 packages/server/src/services/avatars/generation/mesh-rig-layout.ts (+14 -4)
📝 packages/server/src/services/avatars/generation/mesh-rig.ts (+24 -14)
➕ patches/mesh-avatar@0.1.1.patch (+13 -0)
📝 pnpm-lock.yaml (+5 -2)
📝 pnpm-workspace.yaml (+2 -0)
📝 scripts/regressions/avatar-2d-renderers.regression.ts (+87 -1)
📝 scripts/regressions/avatar-backgrounds.regression.ts (+11 -16)
📝 scripts/regressions/avatar-generation.regression.ts (+138 -7)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7878

Why this change

Small sprites produce an oversized painted mesh mouth. Vision-model corners can place that opening below the drawn lip line, creating a double mouth. During text-driven speech, holding a vowel also holds its fixed openness through consonants and word gaps. These three problems were reproduced on Maukie's saved mesh and on synthetic artwork.

What changed

  • Send the original sprite to vision, then resample it once toward a 1254-pixel short side. The existing 2048-pixel long-side limit and eye-work cap still take priority.
  • Fit closed lip ink near the reported corners and measure its bow before building the rig. Short highlights are allowed; missing ink, open mouths, thick or inconsistent candidates keep the original corners and default bow. A provider-supplied bow cannot bypass the pixel measurement.
  • Keep the held vowel shape and override its openness with the speech clock only in hold mode. Voice mode and idle motions retain their existing behavior.
  • Apply the explicitly approved, one-guard mesh-avatar@0.1.1 patch: an explicit mouthOpen parameter must survive the runtime's lip-sync composition. Without this guard the client change is overwritten. This is the sole dependency-file exception: patch registration and lockfile hash; no dependency version or client manifest change.
  • Add synthetic maker and installed-runtime regressions, and scale the existing background-preservation regression's sample coordinates with the enlarged base. Keep source pictures and the archive format intact.

Remake Maukie's mesh after this merges

In 2D Avatars, choose Maukie, then Make an avatar from a sprite → Mesh avatar. Choose his original neutral sprite and a chat connection that can see pictures, select Make mesh avatar, check the preview outlines, then select Save as mesh avatar. This saves the corrected size and placement in his mesh. The speech-clock change also applies to existing meshes without remaking them.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Recorded results:

  • pnpm check: passed, including production builds, localization, format, lint and type checks. After the additional background fixture correction, its focused regression and formatting passed; final script type checks also passed.
  • node scripts/run-regressions.mjs --filter avatar-: 21/21 passed, including generation, backgrounds, renderers, voice sync and importer coverage.
  • pnpm smoke:ui: 7/7 passed, one desktop Chromium worker.
  • Container built and ran on Linux arm64 with disposable in-memory data; /api/health and the compiled SPA both returned HTTP200. The frozen installs in both image stages accepted the patch.
  • Frozen-lockfile installation with the scoped patch: passed.
  • Synthetic maker negative control: replacing the maker with staging's old implementation fails the new regression. The unpatched runtime separately fails the clock-openness regression.
  • Real maker/browser proof uses the unchanged saved mesh for before, and an archive made by the actual fixed generator from the original sprite and the original fake vision corners for after. Chromium uses WebGL2 through ANGLE Metal and the actual Engine adapter. There is no hand-edited after rig.
  • Local Maukie measurements: skin strip 1.5 → 0 px; changed opening height 24 → 8.5 original-sprite px (dark interior 20.5 → 6.5 px). Across active speaking frames the mesh mean is 0.589 → 0.368, against the clock's 0.366. Across all 90 frames, including the silent tail, it is 0.491 → 0.306, against 0.305. Frames above 0.6 fall from 41 to 8, matching the clock's 8. Calm-rest retains the resampled drawing; interpolation differences are expected after enlargement.

Manual verification notes

  1. Manually remake Maukie using the steps above. Check the mouth outline sits on his painted line and the talking opening is attached and appropriately sized.
  2. Manually speak a sentence containing gaps and consonants with text animation, then with a TTS voice. Verify text openness changes between syllables and TTS continues to follow audio.
  3. Manually check Calm, nod and greet with Idle motion enabled. Those motions may still open the mouth naturally; this change does not force Calm shut.
  4. Manually check a larger sprite and a drawing with no clear closed lip line. Existing size caps and vision fallback should remain usable.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs for translation: docs/agents/avatars.md (one sentence about enlarging small sprites). Translation is coordinated in the existing release translation work; no new docs-i18n issue. No version or storage-format change.

The drawn-mouth implementation is parked separately on fix/mesh-avatar-drawn-sprites-20261020 for after release, with no PR. It is not part of this fix.

UI evidence (if applicable)

Maukie's before/after mouth and talking sheets were shown locally and remain private under /tmp/marinara-mesh-painted-mouth-proof-20261020/. His art and mesh are not committed or uploaded. Synthetic-only public proof is linked below.

Synthetic before/after mouth and talking sheets: download synthetic-mouth-proof.html and open it to view both embedded PNGs. synthetic-summary.json records actual runtime readings. No real artwork is included.

Summary by CodeRabbit

  • New Features

    • Mesh avatars now support more accurate mouth openness during held speech and text-driven visemes.
    • Avatar generation better detects and fits painted mouths, while preserving existing mouth shapes when detection is uncertain.
    • Generated avatars support improved scaling and consistent visual proportions across output sizes.
  • Bug Fixes

    • Explicit speech mouth states now correctly take precedence over held vowel states.
    • Mouth openness values are constrained to valid ranges for more predictable animation.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7880 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/mesh-painted-mouth-fit-20261020` --- ### 📝 Commits (1) - [`7c1c262`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7c1c262d1943c76da832a2b6863561304cbb8f2e) fix(avatars): fit painted mesh mouths and follow speech openness ### 📊 Changes **12 files changed** (+371 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `docs/agents/avatars.md` (+1 -1) 📝 `packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-face.ts` (+2 -1) 📝 `packages/client/src/features/avatars/renderers/mesh-avatar/mesh-avatar-renderer.ts` (+6 -1) 📝 `packages/server/src/services/avatars/generation/mesh-layer-builder.ts` (+68 -1) 📝 `packages/server/src/services/avatars/generation/mesh-rig-layout.ts` (+14 -4) 📝 `packages/server/src/services/avatars/generation/mesh-rig.ts` (+24 -14) ➕ `patches/mesh-avatar@0.1.1.patch` (+13 -0) 📝 `pnpm-lock.yaml` (+5 -2) 📝 `pnpm-workspace.yaml` (+2 -0) 📝 `scripts/regressions/avatar-2d-renderers.regression.ts` (+87 -1) 📝 `scripts/regressions/avatar-backgrounds.regression.ts` (+11 -16) 📝 `scripts/regressions/avatar-generation.regression.ts` (+138 -7) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7878 ## Why this change Small sprites produce an oversized painted mesh mouth. Vision-model corners can place that opening below the drawn lip line, creating a double mouth. During text-driven speech, holding a vowel also holds its fixed openness through consonants and word gaps. These three problems were reproduced on Maukie's saved mesh and on synthetic artwork. ## What changed - Send the original sprite to vision, then resample it once toward a 1254-pixel short side. The existing 2048-pixel long-side limit and eye-work cap still take priority. - Fit closed lip ink near the reported corners and measure its bow before building the rig. Short highlights are allowed; missing ink, open mouths, thick or inconsistent candidates keep the original corners and default bow. A provider-supplied bow cannot bypass the pixel measurement. - Keep the held vowel shape and override its openness with the speech clock only in hold mode. Voice mode and idle motions retain their existing behavior. - Apply the explicitly approved, one-guard `mesh-avatar@0.1.1` patch: an explicit `mouthOpen` parameter must survive the runtime's lip-sync composition. Without this guard the client change is overwritten. This is the sole dependency-file exception: patch registration and lockfile hash; no dependency version or client manifest change. - Add synthetic maker and installed-runtime regressions, and scale the existing background-preservation regression's sample coordinates with the enlarged base. Keep source pictures and the archive format intact. ### Remake Maukie's mesh after this merges In **2D Avatars**, choose Maukie, then **Make an avatar from a sprite → Mesh avatar**. Choose his original neutral sprite and a chat connection that can see pictures, select **Make mesh avatar**, check the preview outlines, then select **Save as mesh avatar**. This saves the corrected size and placement in his mesh. The speech-clock change also applies to existing meshes without remaking them. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Recorded results: - `pnpm check`: passed, including production builds, localization, format, lint and type checks. After the additional background fixture correction, its focused regression and formatting passed; final script type checks also passed. - `node scripts/run-regressions.mjs --filter avatar-`: **21/21 passed**, including generation, backgrounds, renderers, voice sync and importer coverage. - `pnpm smoke:ui`: **7/7 passed**, one desktop Chromium worker. - Container built and ran on Linux arm64 with disposable in-memory data; `/api/health` and the compiled SPA both returned HTTP200. The frozen installs in both image stages accepted the patch. - Frozen-lockfile installation with the scoped patch: passed. - Synthetic maker negative control: replacing the maker with staging's old implementation fails the new regression. The unpatched runtime separately fails the clock-openness regression. - Real maker/browser proof uses the unchanged saved mesh for before, and an archive made by the actual fixed generator from the original sprite and the original fake vision corners for after. Chromium uses WebGL2 through ANGLE Metal and the actual Engine adapter. There is no hand-edited after rig. - Local Maukie measurements: skin strip **1.5 → 0 px**; changed opening height **24 → 8.5 original-sprite px** (dark interior **20.5 → 6.5 px**). Across active speaking frames the mesh mean is **0.589 → 0.368**, against the clock's **0.366**. Across all 90 frames, including the silent tail, it is **0.491 → 0.306**, against **0.305**. Frames above 0.6 fall from **41 to 8**, matching the clock's 8. Calm-rest retains the resampled drawing; interpolation differences are expected after enlargement. ### Manual verification notes 1. Manually remake Maukie using the steps above. Check the mouth outline sits on his painted line and the talking opening is attached and appropriately sized. 2. Manually speak a sentence containing gaps and consonants with text animation, then with a TTS voice. Verify text openness changes between syllables and TTS continues to follow audio. 3. Manually check Calm, nod and greet with Idle motion enabled. Those motions may still open the mouth naturally; this change does not force Calm shut. 4. Manually check a larger sprite and a drawing with no clear closed lip line. Existing size caps and vision fallback should remain usable. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs for translation: `docs/agents/avatars.md` (one sentence about enlarging small sprites). Translation is coordinated in the existing release translation work; no new docs-i18n issue. No version or storage-format change. The drawn-mouth implementation is parked separately on `fix/mesh-avatar-drawn-sprites-20261020` for after release, with no PR. It is not part of this fix. ## UI evidence (if applicable) Maukie's before/after mouth and talking sheets were shown locally and remain private under `/tmp/marinara-mesh-painted-mouth-proof-20261020/`. His art and mesh are not committed or uploaded. Synthetic-only public proof is linked below. [Synthetic before/after mouth and talking sheets](https://gist.github.com/SpicyMarinara/d441157c09d3cd184821429ef17aa2a4): download `synthetic-mouth-proof.html` and open it to view both embedded PNGs. `synthetic-summary.json` records actual runtime readings. No real artwork is included. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Mesh avatars now support more accurate mouth openness during held speech and text-driven visemes. - Avatar generation better detects and fits painted mouths, while preserving existing mouth shapes when detection is uncertain. - Generated avatars support improved scaling and consistent visual proportions across output sizes. - **Bug Fixes** - Explicit speech mouth states now correctly take precedence over held vowel states. - Mouth openness values are constrained to valid ranges for more predictable animation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:09:22 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7979
No description provided.