{"record":{"id":"026a21c1aac548ee","repo":"moeru-ai/airi","slug":"airi-failed-to-patch-built-in-mtoon-outline-shad","errorCode":null,"errorMessage":"[AIRI] Failed to patch built-in MToon outline shader: expected shader anchors were not found.","messagePattern":"\\[AIRI\\] Failed to patch built-in MToon outline shader: expected shader anchors were not found\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui-three/src/composables/vrm/outline.ts","lineNumber":369,"sourceCode":"  if (!hasCommonAnchor || !hasBeginNormalAnchor || !hasOutlineBlockAnchor)\n    return undefined\n\n  return replaceOutlineExtrusionBlock(\n    replaceOutlineNormalSource(\n      injectOutlineNormalAttribute(vertexShader),\n    ),\n  )\n}\n\nfunction patchBuiltInOutlineMaterial(material: MToonMaterial) {\n  if (!material.isOutline || isOutlineMaterialPatched(material))\n    return false\n\n  const originalCustomProgramCacheKey = material.customProgramCacheKey.bind(material)\n  const patchedVertexShader = patchOutlineVertexShader(material.vertexShader)\n\n  if (!patchedVertexShader) {\n    console.warn(\n      '[AIRI] Failed to patch built-in MToon outline shader: expected shader anchors were not found.',\n      material.name,\n    )\n    return false\n  }\n\n  // NOTICE: Three's WebGL program cache includes material.customProgramCacheKey().\n  // We patch the outline vertex shader below, so the patched outline pass needs a distinct cache key.\n  material.customProgramCacheKey = () => {\n    const baseKey = originalCustomProgramCacheKey()\n\n    return baseKey\n      ? `${baseKey},${AIRI_OUTLINE_SHADER_PATCH_CACHE_KEY}`\n      : AIRI_OUTLINE_SHADER_PATCH_CACHE_KEY\n  }\n\n  // NOTICE: @pixiv/three-vrm-materials-mtoon@3.5.1 hardcodes the MToon shader strings in\n  // `lib/three-vrm-materials-mtoon.module.js`. The current patch depends on three stable anchors:","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui-three/src/composables/vrm/outline.ts#L351-L387","documentation":"AIRI patches the built-in MToon outline pass by string-anchored replacements on the vertex shader source (patchOutlineVertexShader). If the expected anchor substrings are not present in material.vertexShader — i.e. @pixiv/three-vrm changed its GLSL — the patch is abandoned with this warn and the material is left unpatched (returns false). It is cosmetic robustness: outlines render with stock behavior instead of AIRI's.","triggerScenarios":"Upgrading @pixiv/three-vrm (or three) to a release whose MToon vertex shader was refactored; using a custom MToonMaterial subclass whose shader differs; shader caches serving a stale variant.","commonSituations":"Dependency bump without re-checking anchor strings in outline.ts; three-vrm nightly/beta versions; forks that override MToon shaders.","solutions":["Pin @pixiv/three-vrm / @pixiv/three-vrm-core to the version the anchors were written against (check package.json).","Update the anchor strings in patchOutlineVertexShader to match the new MToon vertex shader source of your three-vrm version.","Accept the fallback: unpatched outline rendering is intentional degradation, not a crash."],"exampleFix":"// before\n// anchors target three-vrm v2.x MToon vertex shader\nconst patched = patchOutlineVertexShader(material.vertexShader)\n\n// after\n// update anchor literals to the new shader, e.g.\n// '#include <beginnormal_vertex>' -> '#include <defaultnormal_vertex>'\n// after inspecting node_modules/@pixiv/three-vrm*/types/shaders/MToonVertexShader.gsl","handlingStrategy":"fallback","validationCode":"if (!patchOutlineVertexShader(material.vertexShader)) { /* stock outline rendering; acceptable */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin @pixiv/three-vrm versions; treat upgrades as needing anchor re-verification.","Add a unit test asserting the anchors exist in the installed MToon vertex shader string.","Design outline patching as best-effort so failure is cosmetic, as it already is."],"tags":["vrm","mtoon","shader","outline","three-vrm","version-drift"],"backgroundTag":"shader-patch-anchor-mismatch","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}