Skip to content

Commit 870432f

Browse files
authored
Merge pull request #60 from vrm-c/release/v0_129_0
Release/v0 129 0
2 parents bc77674 + 5a74270 commit 870432f

15 files changed

Lines changed: 429 additions & 214 deletions

File tree

docs/api/gltf/format.md

Lines changed: 0 additions & 99 deletions
This file was deleted.
Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,31 @@
11
# IMaterialDescriptorGenerator
22

3-
glTF から unity の material を作成します。
4-
5-
```cs title="Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/IMaterialDescriptorGenerator.c"
6-
namespace UniGLTF
7-
{
8-
/// <summary>
9-
/// generate a unity Material from a glTFMaterial.
10-
/// </summary>
11-
public interface IMaterialDescriptorGenerator
12-
{
13-
/// <summary>
14-
/// Generate the MaterialDescriptor generated from the index i.
15-
/// </summary>
16-
MaterialDescriptor Get(GltfData data, int i);
17-
18-
/// <summary>
19-
/// Generate the MaterialDescriptor for the non-specified glTF material.
20-
/// </summary>
21-
MaterialDescriptor GetGltfDefault(string materialName = null);
22-
}
23-
}
243
```
4+
glTF => IMaterialDescriptorGenerator => MaterialDescriptor => UnityEngine.Material
5+
```
6+
7+
`IMaterialDescriptorGenerator` を実装して importer に渡すことで, Material の生成をカスタマイズできます。
8+
9+
<UniVRMSource path="UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/IMaterialDescriptorGenerator.cs" />
10+
11+
<UniVRMSource path="UniGLTF/Runtime/UniGLTF/IO/MaterialIO/Import/MaterialDescriptor.cs" />
12+
13+
## IMaterialDescriptorGenerator.Get の実装
2514

26-
## IMaterialDescriptorGenerator の分岐
15+
`IMaterialDescriptorGenerator.Get` は glTF の material 情報から MaterialDescriptor を生成する責務があります。
16+
以下の2stepを実装します。
2717

28-
`IMaterialDescriptorGenerator.Get` で分岐します。
18+
### MToon, unlit, pbr のどれを生成するのか判断する
2919

3020
1. VRM material であれば MToon を作る
3121
2. unlit であれば Unlit を作る
3222
3. PBR であれば PBR を作る
33-
4. その他であれば デフォルトのマテリアル を作る( `GetGltfDefault` )
23+
4. その他であれば null を反す。
3424

3525
:::note
3626
前ページのサンプルは、分岐せずに PBR を作成しました。
3727
:::
3828

39-
## 分岐の書き方
29+
### MaterialGenerateAsyncFunc による Material 構築を記述する
4030

41-
```cs
42-
43-
// VRM default を使う
44-
45-
// WEBGL のときはカスタムのシェーダーが必要です
46-
47-
// unlit を使う。これは得に代える必要がありません
48-
49-
// PBR を使う。ビルド問題のためカスタムシェーダーが必要です
50-
```
31+
<UniVRMSource path="VRM10_Samples/VRM10Viewer/MaterialImporter/TinyPbrMaterialImporter.cs" />

docs/release/128/v0.129.0.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# v0.129.0 Memory usage
2+
3+
<GitHubMilestone milestone="99" closed />
4+
5+
<GitHubRelease tag="v0.129.0" />
6+
7+
## Performance Improvements
8+
9+
- <GitHubIssue issue="2606" title="SpanによるUniGLTF.NativeArrayManager.CreateNativeArray(ArraySegment)の改善" />
10+
- <GitHubIssue issue="2610" title="Add: UnitySupportedImageTypeDeserializer に MarkNonReadable プロパティを追加" />
11+
- <GitHubIssue issue="2625" title="ImporterContextSettings に引数追加。runtime のデフォルト値を MarkNonReadable = true に変更" />
12+
13+
## Constraint
14+
15+
- <GitHubIssue issue="2644" title="[constraint] 初期化バグ" />
16+
17+
## SpringBone
18+
19+
- <GitHubIssue issue="2604" title="[1.0][SpringBone] 複数のモデルがあるときの Reconstruct で index ずれ" />
20+
- <GitHubIssue issue="2609" title="[SpringBone] CurrentTails の初期値。CurrentTails は center local " />
21+
- <GitHubIssue issue="2629" title="[SpringBone] dispose function can now be executed again" />
22+
- <GitHubIssue issue="2630" title="[0.x][SpringBone] Avoid resetting indexmaps causing exceptions" />
23+
24+
## Package dependency
25+
26+
- <GitHubIssue issue="2624" title="add dependency to com.unity.timeline" />
27+
28+
## Bone name force unique
29+
30+
- <GitHubIssue issue="2642" title="node rename 作り直し。parse 終了時に rename が完了している方がよい" />

docs/release/128/v_next.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# 🚧 v0.128.4
2-
3-
https://github.com/vrm-c/UniVRM/milestone/99
1+
# 🚧 v0.129.1 planned 2025-05-15
42

3+
<GitHubMilestone milestone="100" />

docs/release/128/v_nextnext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# 🚧 nextnext
22

3-
https://github.com/vrm-c/UniVRM/milestone/100
3+
<GitHubMilestone milestone="101" />
44

docs/release/next/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ■v0.xxx.0~ ■
2+
3+
- `0.xxx.0` からサポートする Unity の最低バージョンを `2023.3LTS` に更新しました。

docs/vrm/gltf/format.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# VRMフォーマット
2+
3+
VRM は、[Khronos](https://www.khronos.org/) の開発している 3D Format である [glTF](https://www.khronos.org/Gltf) の version `2.0` をベースにしています。
4+
5+
:::note VRM file
6+
VRM は、glTF の バイナリーバージョンである glb のファイル拡張子を `.vrm` に変更します。
7+
8+
`.vrm``.glb` に戻すことで `vrm` 未対応の `glTF` 対応アプリケーションでも、3D Model としてロードできることが期待できます。
9+
:::
10+
11+
- https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html
12+
13+
## vrm-0.x
14+
15+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/0.0
16+
17+
## vrm-1.0
18+
19+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_vrm-1.0
20+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_materials_mtoon-1.0
21+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_springBone-1.0
22+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_node_constraint-1.0
23+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_springBone_extended_collider-1.0
24+
25+
VRM と 並用することが想定される他の glTF extension
26+
27+
- [KHR_materials_unlit](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md)
28+
- KHR_texture_transform
29+
- KHR_materials_emissive_strength
30+
31+
## vrma
32+
33+
- https://github.com/vrm-c/vrm-specification/tree/master/specification/VRMC_vrm_animation-1.0
34+
35+
## glb フォーマット概説
36+
37+
:::note 仕様
38+
https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#glb-file-format-specification
39+
:::
40+
41+
シーンヒエラルキーをJSONで記述するテキスト部と、画像や頂点配列を記録するバイナリ部の2つの部分からなります。
42+
43+
`glTFヘッダ + JSON CHUNk + BINARY CHUNK`という構成です。
44+
45+
### glTFヘッダ部
46+
47+
| 長さ | 内容 |||
48+
| :--- | :------------- | :---- | :----- |
49+
| 4 | | ascii | "glTF" |
50+
| 4 | gltfバージョン | int32 | 2 |
51+
| 4 | file size | int32 | |
52+
53+
### チャンク部
54+
55+
| 長さ | 内容 |||
56+
| :--------- | :--------- | :------- | :------------------ |
57+
| 4 | chunk size | int32 | |
58+
| 4 | chunk type | ascii | "JSON" or "BIN\x00" |
59+
| chunk size | chunk body | バイト列 | |
60+
61+
```python title="python3によるパース例"
62+
import struct
63+
import json
64+
65+
class Reader:
66+
def __init__(self, data: bytes)->None:
67+
self.data = data
68+
self.pos = 0
69+
70+
def read_str(self, size):
71+
result = self.data[self.pos: self.pos + size]
72+
self.pos += size
73+
return result.strip()
74+
75+
def read(self, size):
76+
result = self.data[self.pos: self.pos + size]
77+
self.pos += size
78+
return result
79+
80+
def read_uint(self):
81+
result = struct.unpack('I', self.data[self.pos:self.pos + 4])[0]
82+
self.pos += 4
83+
return result
84+
85+
86+
def parse_glb(data: bytes):
87+
reader = Reader(data)
88+
magic = reader.read_str(4)
89+
if magic != b'glTF':
90+
raise Exception(f'magic not found: #{magic}')
91+
92+
version = reader.read_uint()
93+
if version != 2:
94+
raise Exception(f'version:#{version} is not 2')
95+
96+
size = reader.read_uint()
97+
size -= 12
98+
99+
json_str = None
100+
body = None
101+
while size > 0:
102+
#print(size)
103+
104+
chunk_size = reader.read_uint()
105+
size -= 4
106+
107+
chunk_type = reader.read_str(4)
108+
size -= 4
109+
110+
chunk_data = reader.read(chunk_size)
111+
size -= chunk_size
112+
113+
if chunk_type == b'BIN\x00':
114+
body = chunk_data
115+
elif chunk_type == b'JSON':
116+
json_str = chunk_data
117+
else:
118+
raise Exception(f'unknown chunk_type: {chunk_type}')
119+
120+
return json.loads(json_str), body
121+
122+
123+
with open('AliciaSolid.vrm', 'rb') as f:
124+
parsed, body = parse_glb(f.read())
125+
```
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# gltf 格納詳細
1+
# vrm-1.0 glTF 格納詳細
22

33
:::warning
44
import, export の実装で注意が必要です。

docs/vrm/material/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# VRM マテリアル概説
2+
3+
VRMでは3つのMaterialをサポートします。
4+
glTF標準のpbr, glTF本家拡張の KHR_materials_unlit, VRM拡張の VRMC_materials_mtoon です。
5+
6+
また、 KHR_texture_transform と KHR_materials_emissive_strength の並用を想定しています。
7+

docs/vrm/meta/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# meta
2+
3+
VRMに格納できるモデル情報
4+
5+
## 仕様
6+
7+
https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0/meta.ja.md

0 commit comments

Comments
 (0)