‹ 首页

vrm-mtoon-outline

@project-n-e-k-o · 收录于 昨天 · 上游提交 昨天

Adjusting VRM MToon material outline thickness in three-vrm. Covers outline width modes, property access, and how to fix outlines that appear too thick when models are scaled.

适合你,如果需要在 three-vrm 中控制 MToon 轮廓粗细

/ 通过 npx 安装 校验哈希
npx oh-my-skill add project-n-e-k-o/n.e.k.o/vrm-mtoon-outline
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- project-n-e-k-o/n.e.k.o/vrm-mtoon-outline
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify project-n-e-k-o/n.e.k.o/vrm-mtoon-outline
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
2258GitHub stars
~819上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 b0c3c15 · 表述以原文为准
它做什么

这个技能让Claude能调整VRM模型的轮廓线厚度,特别是将轮廓宽度模式从“世界坐标”切换到“屏幕坐标”,使轮廓在模型缩放或相机靠近时保持粗细一致。还能诊断并显示轮廓材质的属性。

什么时候触发

当用户处理VRM模型且轮廓线在缩放或相机移动时变得太粗或不一致,或需要以编程方式调整轮廓厚度时触发。

装好后可以这样说
切换后轮廓在缩放时会保持固定像素粗细。
Claude会遍历模型并输出每个轮廓材质的模式、宽度等。
这样轮廓会随模型缩放而变粗。
技能原文 SKILL.md作者撰写 · Apache-2.0 · b0c3c15

VRM MToon Outline Thickness Adjustment

This skill covers how to adjust outline thickness for VRM models using MToon materials in @pixiv/three-vrm.

Common Symptoms
  1. Outline too thick when model is scaled up or camera is close
  2. Outline thickness inconsistent at different zoom levels
  3. Need to adjust outline programmatically at runtime

Key Concepts
Outline Width Modes

MToon materials have two main outline width modes:

| Mode | Description | Behavior | |------|-------------|----------| | 'worldCoordinates' | Outline width is a physical world-space size | Outline appears thicker when model is scaled up or camera is closer | | 'screenCoordinates' | Outline width is relative to screen pixels | Outline stays consistent size regardless of zoom/scale |

Critical Properties
material.outlineWidthMode    // 'none' | 'worldCoordinates' | 'screenCoordinates'
material.outlineWidthFactor  // Number - the actual width value
material.isMToonMaterial     // Boolean - true for MToon materials
material.needsUpdate         // Set to true after modifying properties

Solution: Switch to Screen Coordinates

To make outlines stay consistent regardless of zoom/scale:

function adjustOutlineThickness(vrm, screenFactor = 0.005) {
    vrm.scene.traverse((object) => {
        if (object.isMesh || object.isSkinnedMesh) {
            const materials = Array.isArray(object.material) ? object.material : [object.material];
            
            materials.forEach(material => {
                if (!material || !material.isMToonMaterial) return;
                
                // Check if this material has outlines enabled
                const hasOutline = material.outlineWidthFactor > 0 && 
                                   material.outlineWidthMode !== 'none';
                
                if (hasOutline) {
                    // Switch to screen coordinates mode
                    material.outlineWidthMode = 'screenCoordinates';
                    material.outlineWidthFactor = screenFactor;
                    material.needsUpdate = true;
                }
            });
        }
    });
}
Factor Value Guidelines

For screenCoordinates mode:

| Factor Value | Approximate Effect | |-------------|-------------------| | 0.002 - 0.003 | Very thin outline (1 pixel) | | 0.005 | Thin outline (1-2 pixels) | | 0.01 | Medium outline (2-3 pixels) | | 0.02+ | Thick outline |


Detection Pattern

To diagnose outline issues, log all materials:

function debugOutlineMaterials(vrm) {
    let count = 0;
    vrm.scene.traverse((object) => {
        if (!object.isMesh && !object.isSkinnedMesh) return;
        
        const materials = Array.isArray(object.material) ? object.material : [object.material];
        materials.forEach(material => {
            if (material?.isMToonMaterial || 'outlineWidthFactor' in material) {
                count++;
                console.log({
                    name: material.name || '未命名',
                    type: material.type,
                    isMToonMaterial: material.isMToonMaterial,
                    outlineWidthMode: material.outlineWidthMode,
                    outlineWidthFactor: material.outlineWidthFactor
                });
            }
        });
    });
    console.log(`Found ${count} MToon/Outline materials`);
}

Important Notes
[!IMPORTANT] Call timing matters! The function must be called AFTER currentModel is set. In vrm-core.js, the loadModel() function sets manager.currentModel near line 923. Any function that accesses currentModel must be called after this point.
[!NOTE] Materials named "XXX (Outline)" are outline pass materials automatically created by three-vrm. They share properties with the main material but render the outline effect.

API Reference (three-vrm MToon)

The enum values for outlineWidthMode:

// From three-vrm.module.min.js
{
    None: "none",
    WorldCoordinates: "worldCoordinates", 
    ScreenCoordinates: "screenCoordinates"
}

| Property | Type | Description | |----------|------|-------------| | outlineWidthMode | string | Width calculation mode | | outlineWidthFactor | number | Width value (meaning depends on mode) | | outlineColorFactor | Color | Outline color | | outlineLightingMixFactor | number | How much lighting affects outline | | outlineWidthMultiplyTexture | Texture | Texture to modulate outline width |

按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。