forked from vrm-c/vrm.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from vrm-c/merge/release-vrma
Merge/release vrma
- Loading branch information
Showing
26 changed files
with
893 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# Mesh Bake の実装 | ||
|
||
## Mesh Bake とは | ||
|
||
:::tip この機能を Freeze と呼ぶこともあります | ||
::: | ||
|
||
Unity にはその名もずばり BakeMesh という関数があります。 | ||
|
||
[SkinnedMeshRenderer-BakeMesh - Unity スクリプトリファレンス](https://docs.unity3d.com/jp/current/ScriptReference/SkinnedMeshRenderer.BakeMesh.html) | ||
|
||
SkinnedMesh で bone を動かしてからこの関数を呼ぶと、その状態の mesh を得ることができます。 | ||
|
||
:::warning blendShape の変更も Bake されます | ||
::: | ||
|
||
:::warning mesh に入っている blendshape は変更されません | ||
::: | ||
|
||
## Bake と Mesh.bindposes | ||
|
||
bake された Mesh を SkinnedMeshRenderer で動かすには、 | ||
bake した状態の bone から Mesh.bindposes を計算して置き換える必要があります。 | ||
以下のコードでできます。 | ||
|
||
```cs | ||
SkinnedMeshRenderer smr; | ||
mesh.bindposes = smr.bones.Select(x => x.worldToLocalMatrix).ToArray(); | ||
``` | ||
|
||
:::tip | ||
逆に言うとこの計算で得られる値と異なる bindposes には、 | ||
なんからの mesh 変形が含まれています。 | ||
|
||
- scaling, mirrorring … etc | ||
- A スタンスの T スタンスへの補正 | ||
- Z-UP を Y-UP に回転 | ||
::: | ||
|
||
:::tip クリーンナップする効果があります。 | ||
例えば、mirror を表現する負のスケーリングをクリアする効果があります。 | ||
|
||
mesh が反転して格納されていて、bondpose でミラーリングする手法があった。 | ||
::: | ||
|
||
## bindposes の変更 | ||
|
||
bone の world 位置を維持して回転と拡大縮小を変更してから bindposes を計算した場合でも、 | ||
Skinning が壊れることはありません。 | ||
|
||
:::tip bone の position が関節の回転原点 | ||
::: | ||
|
||
:::tip 回転は自由に設定しても問題ありません | ||
任意の流儀の rig に合わせられます。 | ||
::: | ||
|
||
:::danger スケールは 1 がお勧め | ||
|
||
lossyScale と同じ問題があり、行列では表現できるが scale では表現できないなどのトラブルがあります。 | ||
::: | ||
|
||
## blendshape に対応する | ||
|
||
blendshape を列挙してひとつずつ weight を上げてから bake して、 | ||
元の mesh の vertices を引き算することで blendshape の bake を得ることができます。 | ||
|
||
`Assets\UniGLTF\Runtime\MeshUtility\MeshFreezer.cs` | ||
|
||
:::danger ヒエラルキーに拡大縮小が含まれているとうまくいかない例がある | ||
::: | ||
|
||
:::warning position だけを処理対象にしておくのが無難と思われます | ||
::: | ||
|
||
## vrm-0.x 正規化 | ||
|
||
BakeMesh に対する boneposes 計算前に回転と拡大縮小を変更することが可能であることを利用して、 | ||
無回転、無拡大縮小にするのが vrm-0.x の正規化処理です。 | ||
事前に T-Pose にするという規約が追加されています。 | ||
|
||
`Assets\UniGLTF\Runtime\MeshUtility\MeshFreezer.cs` | ||
|
||
## 関連 | ||
|
||
- https://github.com/vrm-c/UniVRM/issues?q=is%3Aissue+bake+is%3Aclosed | ||
- https://github.com/vrm-c/UniVRM/issues?q=is%3Aissue+freeze+is%3Aclosed | ||
|
||
## bake 処理の改修 | ||
|
||
[v0.116](/release/112/v0.116.0/) | ||
, [v0.117](/release/112/v0.117.0/) | ||
, [v0.119](/release/112/v0.119.0/) | ||
|
||
https://github.com/vrm-c/UniVRM/blob/v0.115.0/Assets/UniGLTF/Runtime/MeshUtility/BoneNormalizer.cs#L226 | ||
|
||
正規化処理を複数のステップに分割して、 | ||
読めるようにする。 | ||
|
||
- Mesh の bake | ||
- Hierarchy の正規化 | ||
- SkinnedMeshRenderer へのアタッチと bindposes の計算 | ||
|
||
### TODO | ||
|
||
- glTF exporter 統合 | ||
- vrm1 exporter 統合 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# import animation | ||
|
||
VRM-1.0 を import します。 | ||
|
||
```cs title="load vrm-1.0" | ||
var vrm10Instance = await Vrm10.LoadPathAsync(path, | ||
canLoadVrm0X: true, | ||
showMeshes: false, | ||
awaitCaller: m_useAsync.enabled | ||
? (IAwaitCaller)new RuntimeOnlyAwaitCaller() | ||
: (IAwaitCaller)new ImmediateCaller(), | ||
materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn), | ||
vrmMetaInformationCallback: m_texts.UpdateMeta, | ||
ct: cancellationToken); | ||
if (cancellationToken.IsCancellationRequested) | ||
{ | ||
UnityObjectDestroyer.DestroyRuntimeOrEditor(vrm10Instance.gameObject); | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
} | ||
|
||
var instance = vrm10Instance.GetComponent<RuntimeGltfInstance>(); | ||
instance.ShowMeshes(); | ||
instance.EnableUpdateWhenOffscreen(); | ||
``` | ||
|
||
VRM-Animation を import します。 | ||
|
||
```cs title="load vrm-animation" | ||
// gltf, glb etc... | ||
using GltfData data = new AutoGltfFileParser(path).Parse(); | ||
using var loader = new VrmAnimationImporter(data); | ||
var instance = await loader.LoadAsync(new ImmediateCaller()); | ||
var vrmAnimation = instance.GetComponent<Vrm10AnimationInstance>(); | ||
instance.GetComponent<Animation>().Play(); | ||
``` | ||
|
||
VRM-1.0 と VRM-Animation を連結します。 | ||
|
||
```cs title="connect model with vrm-animation" | ||
vrm10Instance.Runtime.VrmAnimation = vrmAnimation; | ||
``` | ||
|
||
:::info | ||
以降 Vrm10Instance の Update もしくは LateUpdate で、 | ||
VRM-Animation のポーズが Vrm-1.0 に転送されます。 | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# VRM10Viewer | ||
|
||
![image](./vrm10viewer.jpg) | ||
|
||
vrm-1.0 の Runtime ローダーのサンプルです。 | ||
|
||
以下のフォーマットをロードできます。 | ||
|
||
- (model) vrm-1.0 | ||
- (model) vrm-0.x(vrm-1.0 に動的に変換する) | ||
- (motion) bvh | ||
- (motion) vrm-animation | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
date: 2024-02-09 | ||
--- | ||
|
||
# ShowCase の登録/更新について | ||
|
||
以下の内容を [issues](https://github.com/vrm-c/vrm.dev/issues) に作ってください。 | ||
PullRequest でなくても大丈夫です。 | ||
|
||
## 登録/更新 | ||
|
||
| 項目 | | | ||
| ----------- | ------------------------------------------------- | | ||
| title | 必須 | | ||
| url | 必須 | | ||
| description | オプション | | ||
| preview | オプション | | ||
| tag | オプション[showcase](/showcase)から選んでください | | ||
|
||
- 日本または英語片方だけの場合はコピーします | ||
- description と preview が無い場合は、初回登録時にスクリプトで OGP を取得します | ||
|
||
## 例 | ||
|
||
```md | ||
# ShowCase 登録依頼 | ||
|
||
## title | ||
|
||
ザ・シードオンライン | ||
|
||
## url | ||
|
||
https://virtualcast.jp/store/ | ||
|
||
``` | ||
|
||
## json format | ||
|
||
```json | ||
{ | ||
"tag": "CharacterPlatform", | ||
"ja": { | ||
"title": "ザ・シードオンライン", | ||
"url": "https://virtualcast.jp/store/", | ||
"description": "`1.0` アップロード可。3D viewer は `1.0` 未対応", | ||
"preview": "https://virtualcast.jp/img/common/logo/virtual_cast_570_270_white.png" | ||
}, | ||
"en": { | ||
"title": "The Seed Online", | ||
"url": "https://virtualcast.jp/store/", | ||
"description": "`1.0` can be uploaded. 3D viewer does not support `1.0`", | ||
"preview": "https://virtualcast.jp/img/common/logo/virtual_cast_570_270_white.png" | ||
}, | ||
"vrm": "1.0" | ||
} | ||
``` | ||
|
||
https://github.com/vrm-c/vrm.dev/blob/master/src/data/users.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# VRMC_node_constraint | ||
|
||
https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_node_constraint-1.0 |
Oops, something went wrong.