[PR #7889] [MERGED] fix(avatars): mesh avatar mouths span the whole drawn mouth #7987

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

📋 Pull Request Information

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

Base: staging ← Head: fix/mesh-mouth-width


📝 Commits (2)

  • 6d6c6dc fix(avatars): mesh avatar mouths span the whole drawn mouth
  • 9353232 fix(avatars): project faded lip ends onto the fitted mouth line

📊 Changes

6 files changed (+133 additions, -4 deletions)

View changed files

📝 packages/server/src/services/avatars/generation/mesh-layer-builder.ts (+48 -1)
📝 patches/mesh-avatar@0.1.1.patch (+9 -0)
📝 pnpm-lock.yaml (+3 -3)
📝 pnpm-workspace.yaml (+1 -0)
📝 scripts/regressions/avatar-2d-renderers.regression.ts (+20 -0)
📝 scripts/regressions/avatar-generation.regression.ts (+52 -0)

📄 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

No issue. This follows up #7880. Mari tested Maukie's mesh avatar after making it again on #7880: the eyes work, but the mouth is too short side to side. If an issue is wanted for tracking, it should be opened before this merges.

Closes #

Why this change

When a mesh avatar talks, its open mouth only covers the middle of the drawn mouth line, so the line's ends stick out on both sides.

The rig is not the problem. On Maukie's new file the rig's mouth corners are within about 1 px of the drawn line's ends (611.5–720 on the 1327×1254 base), and halfLen is 53.03, half the line, as the mesh-avatar format defines it ("half length of lip-corner line").

The cause is in the mesh-avatar 0.1.1 runtime. Its painted mouth only opens where |s| < wf, with s measured in halfLens, and wf = mix(0.78, 0.46, form) in dist/index.js, so:

  • "a" opens across 62% of the line;
  • "i" across 76%;
  • "o" across 52%;
  • nod and greet across about 70%.

This affects every avatar that uses the painted mouth: generated ones, and imported .mavatar files without drawn mouth shapes.

What changed

  • Runtime patch (patches/mesh-avatar@0.1.1.patch, pnpm-workspace.yaml, pnpm-lock.yaml): wf is now 1.0, so for every vowel and motion the opening runs from one lip corner to the other and narrows to a point at each corner. Each vowel still keeps its own depth and roundness, teeth and tongue.
  • Drawn-line fit (fitDrawnMouth in mesh-layer-builder.ts): lip lines that fade to lighter ends than the ink threshold now keep those ends. The same applies to a line that runs past corners the vision model placed too far in. A local-contrast check follows the line outward column by column: the line must be darker than the skin just above and below it, so smooth shading doesn't count. This is capped at 30% of the vision mouth's width on each side. The fit itself still uses only the solid ink, and the fitted curve is extended to the point on it nearest where the line visibly ends, so a tilted mouth with a flat faded tail isn't carried past the tail, so #7880's position and bow measurement stay the same. The guards are unchanged: no clear line, an open drawn mouth, or a line much shorter than the vision mouth still keep the vision corners.
  • Regressions:
    • avatar-generation: a tapered line fixture (dark centre, ends lighter than the ink threshold, vision corners placed inside the line) gets corners within 2 built px of the visible ends. Without the fix they land about 15 px short on each side. A 3:4 tilted line with a flat faded tail ends at the point of the line nearest the tail end. All #7880 cases still pass.
    • avatar-2d-renderers: pins the installed runtime's painted width to the whole lip line for every mouth form.

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

Manual verification notes

Ran by the agent:

  • pnpm check
  • node scripts/run-regressions.mjs --filter avatar: all 20 avatar regressions pass.
  • Real-renderer mouth sheets: headless Chromium, the mesh-avatar runtime, head held still, states calm, nod, greet, a, o and i.
    • Before: Maukie's current file with the unpatched runtime. Every opening sits in the middle of the line, and 13–25 px of drawn line sticks out past it on each side at 1254 px.
    • After: Maukie's neutral sprite rebuilt with this branch, using a fake vision answer equal to his current rig's corners, on the patched runtime. Corners land at 611.5 and 719.5, against visible ends at about 611–720. The a, o, i, nod and greet openings reach both ends of the line. Calm looks exactly like the drawing.

To check by hand:

  • After merge, remake the mesh in 2D Avatars → Make an avatar from a sprite → Mesh avatar, then save it.
  • In the setup Preview, select Talk and check that the open mouth reaches both ends of the drawn mouth line for each vowel.
  • In a chat, check that a reply's speech opens the mouth across the whole drawn line and closes back onto it between words.
  • Check an imported .mavatar without drawn mouth shapes. Its painted mouth now also opens to its lip corners.

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] <paths> follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

The docs say simple mouths are drawn when a file has none. That stays true, so no doc text changes.

UI evidence (if applicable)

The before and after sheets are kept locally rather than attached, because they show Mari's character art. Both sheets use the same layout and crop: a row of calm, nod and greet above a row of a, o and i. Blue ticks mark the ends of the drawn line.

Summary by CodeRabbit

  • Improvements

    • Improved avatar mouth rendering for faded or lightly drawn lip lines.
    • Mouth endpoints now better match the full visible lip line, including tapered or faded edges.
    • Standardized painted-mouth width across different mouth forms and vowel shapes.
    • Preserved flatter mouth curves when the source artwork has a flat shape.
  • Bug Fixes

    • Corrected mouth-opening behavior when explicit mouth animation data is available.
  • Tests

    • Added regression coverage for faded lip lines, mouth widths, and curve preservation.

🔄 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/7889 **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-mouth-width` --- ### 📝 Commits (2) - [`6d6c6dc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6d6c6dcf0cd4eb127fb6f4a2d1ee64897c1a8cab) fix(avatars): mesh avatar mouths span the whole drawn mouth - [`9353232`](https://github.com/Pasta-Devs/Marinara-Engine/commit/93532328a5f138dab1626553b67cb8d40ff64f5a) fix(avatars): project faded lip ends onto the fitted mouth line ### 📊 Changes **6 files changed** (+133 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/avatars/generation/mesh-layer-builder.ts` (+48 -1) 📝 `patches/mesh-avatar@0.1.1.patch` (+9 -0) 📝 `pnpm-lock.yaml` (+3 -3) 📝 `pnpm-workspace.yaml` (+1 -0) 📝 `scripts/regressions/avatar-2d-renderers.regression.ts` (+20 -0) 📝 `scripts/regressions/avatar-generation.regression.ts` (+52 -0) </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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue No issue. This follows up #7880. Mari tested Maukie's mesh avatar after making it again on #7880: the eyes work, but the mouth is too short side to side. If an issue is wanted for tracking, it should be opened before this merges. Closes # ## Why this change When a mesh avatar talks, its open mouth only covers the middle of the drawn mouth line, so the line's ends stick out on both sides. The rig is not the problem. On Maukie's new file the rig's mouth corners are within about 1 px of the drawn line's ends (611.5–720 on the 1327×1254 base), and halfLen is 53.03, half the line, as the mesh-avatar format defines it ("half length of lip-corner line"). The cause is in the mesh-avatar 0.1.1 runtime. Its painted mouth only opens where `|s| < wf`, with `s` measured in halfLens, and `wf = mix(0.78, 0.46, form)` in `dist/index.js`, so: - "a" opens across 62% of the line; - "i" across 76%; - "o" across 52%; - nod and greet across about 70%. This affects every avatar that uses the painted mouth: generated ones, and imported `.mavatar` files without drawn mouth shapes. ## What changed - **Runtime patch** (`patches/mesh-avatar@0.1.1.patch`, `pnpm-workspace.yaml`, `pnpm-lock.yaml`): `wf` is now `1.0`, so for every vowel and motion the opening runs from one lip corner to the other and narrows to a point at each corner. Each vowel still keeps its own depth and roundness, teeth and tongue. - **Drawn-line fit** (`fitDrawnMouth` in `mesh-layer-builder.ts`): lip lines that fade to lighter ends than the ink threshold now keep those ends. The same applies to a line that runs past corners the vision model placed too far in. A local-contrast check follows the line outward column by column: the line must be darker than the skin just above and below it, so smooth shading doesn't count. This is capped at 30% of the vision mouth's width on each side. The fit itself still uses only the solid ink, and the fitted curve is extended to the point on it nearest where the line visibly ends, so a tilted mouth with a flat faded tail isn't carried past the tail, so #7880's position and bow measurement stay the same. The guards are unchanged: no clear line, an open drawn mouth, or a line much shorter than the vision mouth still keep the vision corners. - **Regressions:** - `avatar-generation`: a tapered line fixture (dark centre, ends lighter than the ink threshold, vision corners placed inside the line) gets corners within 2 built px of the visible ends. Without the fix they land about 15 px short on each side. A 3:4 tilted line with a flat faded tail ends at the point of the line nearest the tail end. All #7880 cases still pass. - `avatar-2d-renderers`: pins the installed runtime's painted width to the whole lip line for every mouth form. ## 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` ### Manual verification notes Ran by the agent: - `pnpm check` - `node scripts/run-regressions.mjs --filter avatar`: all 20 avatar regressions pass. - Real-renderer mouth sheets: headless Chromium, the mesh-avatar runtime, head held still, states calm, nod, greet, a, o and i. - **Before:** Maukie's current file with the unpatched runtime. Every opening sits in the middle of the line, and 13–25 px of drawn line sticks out past it on each side at 1254 px. - **After:** Maukie's neutral sprite rebuilt with this branch, using a fake vision answer equal to his current rig's corners, on the patched runtime. Corners land at 611.5 and 719.5, against visible ends at about 611–720. The a, o, i, nod and greet openings reach both ends of the line. Calm looks exactly like the drawing. To check by hand: - [ ] After merge, remake the mesh in **2D Avatars → Make an avatar from a sprite → Mesh avatar**, then save it. - [ ] In the setup **Preview**, select **Talk** and check that the open mouth reaches both ends of the drawn mouth line for each vowel. - [ ] In a chat, check that a reply's speech opens the mouth across the whole drawn line and closes back onto it between words. - [ ] Check an imported `.mavatar` without drawn mouth shapes. Its painted mouth now also opens to its lip corners. ## 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] <paths>` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) The docs say simple mouths are drawn when a file has none. That stays true, so no doc text changes. ## UI evidence (if applicable) The before and after sheets are kept locally rather than attached, because they show Mari's character art. Both sheets use the same layout and crop: a row of calm, nod and greet above a row of a, o and i. Blue ticks mark the ends of the drawn line. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Improvements** - Improved avatar mouth rendering for faded or lightly drawn lip lines. - Mouth endpoints now better match the full visible lip line, including tapered or faded edges. - Standardized painted-mouth width across different mouth forms and vowel shapes. - Preserved flatter mouth curves when the source artwork has a flat shape. - **Bug Fixes** - Corrected mouth-opening behavior when explicit mouth animation data is available. - **Tests** - Added regression coverage for faded lip lines, mouth widths, and curve preservation. <!-- 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:26 +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#7987
No description provided.