moc/moc3 and cmo3 analysis tool (moc/moc3 和 cmo3 分析工具)

New not-so-minor update just released which should address some APL2 metadata parsing and more configurable performance tuning for PSD/PSB conversion (add --progress flag to enable live update).

刚刚发布了一次相当重要的更新,主要解决了 APL2 元数据解析方面的问题,并针对 PSD/PSB 转换提供了更灵活的性能调优选项(添加 --progress 标志即可启用实时进度显示)。

3 个赞

Thank you for creating this software! I’d like to ask whether there are any forums or communities outside China that are specifically dedicated to creating or discussing Live2D. Could you share some links with me? I’d love to learn from those communities.QAQ

Honestly not that many I know of beside official Live2D discord and adjacent related discord like Vtube Studio.

hi,I’d like to ask how to resolve the “insufficient memory” error.

like:error: converting models\1.moc3: convert error: cannot reserve retained PNG decode memory: Scratch reservation requests 536870976 bytes with 528482032 available

error: converting models\1.moc3: convert error: cannot reserve alpha component memory: Scratch reservation requests 805502976 bytes with 394264408 available

1 个赞

Thank you so much for the reply! There really aren’t many communities or forums dedicated to this topic, though. Still, I really appreciate your response! OvO
非常感谢回复啦,不过确实,,有关这方面的社团、论坛确实并不多。还是感谢答复啦OvO

Made some library upgrades alongside with fixing handing large png texture. May want to delete old Cargo.lock or move it somewhere just in case.

升级了一些库,并修复了处理大型 PNG 纹理的问题。建议删除旧的 Cargo.lock 文件或将其移至别处,以防万一。

1 个赞

根据我的需求,我使用ai添加了一些处理大型PNG纹理时的新特性,但codeberg的仓库已无法访问,我感到困惑

Quadrism 新增功能:精确纹理裁剪与三角形遮罩

在 ImageExtractionPolicy 中新增两个配置字段,均通过 --conversion-policy JSON 文件启用:


1. strict_dimensions: bool(默认 false)

问题:默认情况下,每个部件的输出纹理尺寸会被上取整到最近的 2 的幂(checked_next_power_of_two()),导致纹理总是正方形且尺寸为 64/128/256/512…。例如一个 300×80 的网格裁剪范围,纹理会被填充为 512×512。

修改:padded_output_dims_with_policy() 函数,当 strict_dimensions 为 true 时,跳过 checked_next_power_of_two() 调用,直接使用裁剪后的实际宽高。

涉及文件:crates/quadrism-lib/src/convert/generic/image.rs


2. mesh_mask: bool(默认 false)

问题:默认的矩形裁剪只取 mesh UV 顶点的轴对齐包围盒,像素逐行整块从贴图复制,包围盒内但不在 mesh 三角形内的像素保留原始贴图内容,而非透明。

修改:

  • ImageExtractionPolicy 结构体新增 mesh_mask: bool 字段(#[serde(default)])
  • 新增函数 apply_mesh_mask():
    • 从 model.mesh_payloads[idx] 读取该 mesh 的 uv_offset 和 index_offset
    • 从 model.uv_pool 获取 UV 坐标,转换为裁剪空间坐标
    • 从 model.index_pool 获取三角形索引,每 3 个 u16 构成一个三角形
    • 使用重心坐标(barycentric)点判法光栅化所有三角形,生成 bool 掩码
    • 将掩码应用于输出 RGBA 缓冲区:三角形外的像素 RGBA 全部置 0
  • build_model_images_from_decoded_with_policy() 中:
    • mesh_mask 开启时,fast_rows 路径自动禁用(因逐行整块复制无法做逐像素判断)
    • 像素复制完成后调用 apply_mesh_mask() 执行三角形遮罩

涉及文件:crates/quadrism-lib/src/convert/generic/image.rs


兼容性

  • 两个字段均 #[serde(default)],未指定时行为与原始版本完全一致
  • compatibility_image_extraction_policy() 中两者均默认 false
  • 对现有的 CLI 参数和策略文件格式无破坏性变更

使用示例

crop_policy.json 中启用:

json

{
  "image_extraction": {
    "strict_dimensions": true,
    "mesh_mask": true,
    ...
  }
}

命令行:

sh

quadexec conv model.moc3 out.cmo3 --crop \
  --conversion-policy crop_policy.json \
  --texture texture_00.png

已提交合并请求 :grinning_face:

Hi, thanks for pull request, but honestly I was in the process of reworking how --crop works anyways but honestly the pull request looks ok so far, but I’ve probably rework your changes a bit.

嗨,谢谢你提交的 pull request。其实我本来就在重构 --crop 功能的实现方式,不过目前看来你的改动还不错,只是我可能会对你的代码做些微调。

Thanks for the reply! Great project by the way — Quadrism is impressive work. Happy for you to rework the changes however fits best with your dev plans.

error

Hi, you may try to pin the package version using Cargo.toml. I have left comments there on what package version make the codebase compile:

anyhow v1.0.104
clap v4.6.4
crc32fast v1.5.0
fdeflate v0.3.7
flate2 v1.1.9
miniz_oxide v0.9.1
png v0.18.1
quick_xml v0.41.0
rayon v1.12.0
serde v1.0.229
serde_json v1.0.151
thiserror v2.0.19

2 个赞

Thx :kissing_face_with_smiling_eyes:

Question, why when i export it to moc3, it gives like this weird thing like the alpha is not working.

and if i redo texture atlas, it shows like multiple atlas of the same artmesh.

1 个赞

That tweet likely mentions live2d moc3转cmo3正式分享_哔哩哔哩_bilibili which is developed way more early than mine and it still private unlike my public version.

那条推文提到的很可能是 视频去哪了呢?_哔哩哔哩_bilibili ; 它的开发时间比我的早得多,而且至今仍处于私密状态,不像我的版本是公开的。

Also Azxiana on X: "No one should be paying to get their Live2D MOC3 files converted to CMO3. Because you can do it for free with Umamo and the code is open source too. If modellers want to protect their work, they will need to make it part of a signed contract." / X have a separate implementation already.

Also there’s existing parser too:

对于此贴文内容而言,我讲出来的话很难守live2dhub社区准则-即使你不同意他人时,尊重他人
因为此X贴文内容做的事与live2d inc.咬下了对它的逆向工程的github代码仓库后果几乎一致.
(躲在Elon Musk那个食言"公开贴文查看"承诺的X/TWITTER里攻击一个找灵感的论坛真好玩 :face_vomiting:)
如果live2d相关的sdk能允许玩家导出个PSD之类的多图层文件参考,谁又专门走逆向工程?(特别指一堆"EOS"的游戏里的live2d动画)
对MOC/MOC3文件的魔改/Moddding本该是一种爱好/乐趣.

ps.大概猜测本论坛主是Live2dviewerEX的开发者,有些商业上的事讲不清,也不想猜后继走向.