-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.0] VRM0.xのマテリアルの表情アニメーションに対応する #1020
Conversation
vrm0.xのマテリアルアニメーションに対応するためにrenameMaterialPropertyを移動する。 使用すると考えられる場所はvrm0.xでのマテリアルアニメーションをバインドする箇所だけだと考えられる
読み込み時にVRM0.xの場合でもマテリアルを表情で変化させることが出来るようにする。 MaterialColor - color - emissionColor - shadeColor - rimColor - outlineColor TextureTransform - scale - offset RotationはVRMの仕様として表情に紐づけることが出来ない。
packages/three-vrm-core/src/expressions/VRMExpressionLoaderPlugin.ts
Outdated
Show resolved
Hide resolved
const expressionType = renameMaterialProperty( | ||
materialValue.propertyName!, | ||
) as VRMExpressionMaterialColorType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これで正しいexpressionTypeが取れる確証はありますか?
targetValue: new THREE.Color(...materialValue.targetValue!.slice(0, 3)), | ||
}), | ||
); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここはelseで弾くよりかは、 _MainTex_ST
と等価比較をしたくありませんか?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
および、ここがハズレた場合は、「このパラメータは対応してないよ」Warningを出すのが親切かなと思っています
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color, emissionColor, shadeColor, rimColor, outlineColor
すべてお名前は揃っていそうですね。
ただ、以下のようなmapを用意してやったほうがより良さそうと思います (i.e. renameMaterialPropert
を用いない):
{
'_Color': 'color',
'_ShadeColor': 'shadeColor',
...
}
VRM0のMaterialColorTypeの名前からVRM1用に変換するMapを追加する '_Color': 'color'
- OutlineColorのアニメーション対応 - _propertyNameMapMapの名前修正 - shadeTextureのUVアニメーションの修正
color: 'color', | ||
emissionColor: 'emissive', | ||
outlineColor: 'outlineFactor', | ||
rimColor: 'rimFactor', | ||
shadeColor: 'shadeFactor', | ||
outlineColor: 'outlineColorFactor', | ||
rimColor: 'parametricRimColorFactor', | ||
shadeColor: 'shadeColorFactor', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
materialBindが対象とするMToonMaterialのプロパティがお名前がズレていたため、それの修正です
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
今回、こんな感じで4つほどお名前ステークホルダーがいたのですが:
- VRM0.xのmaterial bindのお名前(undocumented): [1.0] VRM0.xのマテリアルの表情アニメーションに対応する #1020 (comment)
- VRM1.0のmaterial bindのお名前: https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0-beta/expressions.ja.md#materialcolorbind
- VRMC_materials_mtoonのプロパティ名: https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_materials_mtoon-1.0-beta/README.ja.md
- three-vrmのMToonMaterialのプロパティ名: https://github.com/pixiv/three-vrm/blob/1.0/packages/three-vrm-materials-mtoon/src/MToonMaterial.ts
ここのObjectは、このうちVRM1.0のmaterialBindの名前をthree-vrmのMToonMaterialのプロパティ名へマップするObjectです。
vec2 shadeMultiplyTextureUv = ( shadeMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy; | ||
#if THREE_VRM_THREE_REVISION >= 137 | ||
material.shadeColor *= texture2D( shadeMultiplyTexture, uv ).rgb; | ||
material.shadeColor *= texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv ).rgb; | ||
#else | ||
// COMPAT: pre-r137 | ||
material.shadeColor *= shadeMultiplyTextureTexelToLinear( texture2D( shadeMultiplyTexture, uv ) ).rgb; | ||
material.shadeColor *= shadeMultiplyTextureTexelToLinear( texture2D( shadeMultiplyTexture, shadeMultiplyTextureUv) ).rgb; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
もともと shadeMultiplyTextureUvTransform
が全く機能していなかったので(今回の趣旨と関連はするが直交するバグ)、それの修正です。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM。ありがとうございました。
Description
1.0でVRM0.xのモデルを読み込んだ際も表情アニメーションでマテリアルを変化できるように実装する.
MaterialColor に対応
TextureTransform に対応
TextureTransform.RotationはVRMの仕様として表情に紐づけることが出来ない。