mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 06:20:01 -05:00
@@ -8,7 +8,7 @@ Asynchronous task scheduler for Unity-5.6 or later
|
||||
|
||||
# 使い方
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var schedulable = new Schedulable<Unit>();
|
||||
|
||||
schedulable
|
||||
|
||||
@@ -5,7 +5,7 @@ JSON serializer and deserializer and schema utilities for Unity(.Net3.5)
|
||||
|
||||
### JSON Create
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var f = new JsonFormatter();
|
||||
f.BeginMap();
|
||||
f.Key("X"); f.Value(1);
|
||||
@@ -20,7 +20,7 @@ var json = f.ToString();
|
||||
|
||||
Serialize public fields automatically.
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var f = new JsonFormatter();
|
||||
f.Serialize(new Vector3(1, 2, 3));
|
||||
var json = f.ToString();
|
||||
@@ -29,7 +29,7 @@ var json = f.ToString();
|
||||
|
||||
### JSON Parse
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var json = "{\"X\":1,\"Y\":2,\"Z\":3}";
|
||||
var parsed = json.ParseAsJson();
|
||||
var x = parsed["X"].GetInt32();
|
||||
@@ -37,14 +37,14 @@ var x = parsed["X"].GetInt32();
|
||||
|
||||
### JSON Deserialize
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var v = default(Vector3);
|
||||
json.Deserialize(ref v);
|
||||
```
|
||||
|
||||
### JSON Schema
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
[Serializable]
|
||||
public class glTFSparseIndices
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public void AccessorSparseIndices()
|
||||
|
||||
Same as json interface
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var f = new MsgPackFormatter();
|
||||
f.Serialize(new Vector3(1, 2, 3));
|
||||
ArraySegment<byte> msgpack = f.GetStoreBytes();
|
||||
@@ -95,7 +95,7 @@ var x = parsed["X"].GetInt32();
|
||||
|
||||
WIP
|
||||
|
||||
```cs
|
||||
```csharp
|
||||
var toml =@"
|
||||
X = 1
|
||||
Y = 2
|
||||
|
||||
13
docs/_templates/layout.html
vendored
Normal file
13
docs/_templates/layout.html
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "!layout.html" %}
|
||||
|
||||
{% block sidebarlogo %}
|
||||
<ul>
|
||||
{%- if language != "en" %}
|
||||
<li><a href="{{ pathto('../public/en/html/', 1) }}{{ pathto(pagename, 0, '.') }}">English</a></li>
|
||||
{%- endif %}
|
||||
{%- if language != "ja" %}
|
||||
<li><a href="{{ pathto('../public/ja/html/', 1) }}{{ pathto(pagename, 0, '.') }}">日本語</a></li>
|
||||
{%- endif %}
|
||||
</ul>
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
19
docs/build.md
Normal file
19
docs/build.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# アプリケーションのビルド
|
||||
|
||||
## ビルドに含めるシェーダー
|
||||
|
||||
`Project Settings = Graphics - Always Included Shaders` などに設定して、ビルドに含まれるようにしてください。
|
||||
|
||||
### Unlit
|
||||
|
||||
* `Assets\VRMShaders\GLTF\UniUnlit\Resources\UniGLTF\UniUnlit.shader`
|
||||
|
||||
### MToon
|
||||
|
||||
* `Assets\VRMShaders\VRM\MToon\MToon\Resources\Shaders\MToon.shader`
|
||||
|
||||
### ランタイム import/export 時のテクスチャー変換用のシェーダー
|
||||
|
||||
* `Assets\VRMShaders\GLTF\IO\Resources\UniGLTF\NormalMapExporter.shader`
|
||||
* `Assets\VRMShaders\GLTF\IO\Resources\UniGLTF\StandardMapExporter.shader`
|
||||
* `Assets\VRMShaders\GLTF\IO\Resources\UniGLTF\StandardMapImporter.shader`
|
||||
@@ -56,3 +56,5 @@ html_static_path = ['_static']
|
||||
|
||||
locale_dirs = ['locale/']
|
||||
gettext_compact = False
|
||||
|
||||
html_context = {"language": language}
|
||||
|
||||
63
docs/implementation/coordinate.md
Normal file
63
docs/implementation/coordinate.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# 座標系の変換
|
||||
|
||||
UniVRMは、インポート・エクスポート時に座標変換を実行しています。
|
||||
|
||||
| | 右 | 上 | 前 | 掌性 | UV原点 | |
|
||||
|-------|----|----|----|------|--------|--------------------------------------------------------|
|
||||
| Unity | +X | +Y | +Z | 左手 | 左下 | |
|
||||
| VRM-0 | +X | +Y | -Z | 右手 | 左上 | |
|
||||
| VRM-1 | -X | +Y | +Z | 右手 | 左上 | |
|
||||
| glTF | | +Y | | 右手 | 左上 | デフォルトはVRM-0方式。オプションでVRM-1方式を選べます |
|
||||
|
||||
## UV
|
||||
|
||||
以下のように変換します。
|
||||
|
||||
```{math}
|
||||
V^{\prime} = 1 - V
|
||||
```
|
||||
|
||||
## Unity <-> VRM0
|
||||
|
||||
Z軸を反転します。
|
||||
|
||||
### Vector3: Position, Normalなど
|
||||
|
||||
```csharp
|
||||
public static Vector3 ReverseZ(this Vector3 v)
|
||||
{
|
||||
return new Vector3(v.x, v.y, -v.z);
|
||||
}
|
||||
```
|
||||
|
||||
### Quaternion: Rotation
|
||||
|
||||
```csharp
|
||||
public static Quaternion ReverseZ(this Quaternion q)
|
||||
{
|
||||
float angle;
|
||||
Vector3 axis;
|
||||
q.ToAngleAxis(out angle, out axis);
|
||||
return Quaternion.AngleAxis(-angle, ReverseZ(axis));
|
||||
}
|
||||
```
|
||||
|
||||
### Matrix: BindMatrices
|
||||
|
||||
スケール値が入っているとうまくいきません
|
||||
|
||||
```csharp
|
||||
public static Matrix4x4 ReverseZ(this Matrix4x4 m)
|
||||
{
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
m.SetTRS(m.GetColumn(3).ReverseZ(), m.rotation.ReverseZ(), Vector3.one);
|
||||
#else
|
||||
m.SetTRS(m.ExtractPosition().ReverseZ(), m.ExtractRotation().ReverseZ(), Vector3.one);
|
||||
#endif
|
||||
return m;
|
||||
}
|
||||
```
|
||||
|
||||
## Unity <-> VRM1
|
||||
|
||||
X軸を反転します。
|
||||
65
docs/implementation/texture_manipulation.md
Normal file
65
docs/implementation/texture_manipulation.md
Normal file
@@ -0,0 +1,65 @@
|
||||
# Texture関連
|
||||
|
||||
## Unity の linear の テクスチャーの挙動について
|
||||
|
||||
### Runtime
|
||||
|
||||
new する場合は、
|
||||
|
||||
```csharp
|
||||
var texture = new Texture2D(width, height, format, mipChain, linear = true);
|
||||
```
|
||||
|
||||
とする。
|
||||
|
||||
### Editor(Asset)
|
||||
|
||||
AssetFolder の png/jpg からloadする場合は、
|
||||
事前に設定が必用。
|
||||
|
||||
```csharp
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
||||
textureImporter.sRGBTexture = false; // Linear
|
||||
textureImporter.SaveAndReimport();
|
||||
|
||||
// linear でロードされます
|
||||
var texture =AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath);
|
||||
```
|
||||
|
||||
## Unity の NormalMap の挙動について
|
||||
|
||||
> MToon の NormalMap も同じ
|
||||
|
||||
### Runtime
|
||||
|
||||
new する場合は、
|
||||
|
||||
```csharp
|
||||
var texture = new Texture2D(width, height, format, mipChain, linear = true);
|
||||
```
|
||||
|
||||
とする。
|
||||
また、 `DXT5nm` という仕様で格納する必要があるので変換します。
|
||||
y と w の2要素だけを使います。
|
||||
|
||||
```hlsl
|
||||
half4 normal;
|
||||
normal.x = 1.0;
|
||||
normal.y = col.y;
|
||||
normal.z = 1.0;
|
||||
normal.w = col.x;
|
||||
```
|
||||
|
||||
### Editor(Asset)
|
||||
|
||||
AssetFolder の png/jpg からloadする場合は、
|
||||
ロードする前に設定が必用。
|
||||
|
||||
```csharp
|
||||
var textureImporter = AssetImporter.GetAtPath(assetPath) as TextureImporter;
|
||||
textureImporter.textureType = TextureImporterType.NormalMap; // normalMap
|
||||
textureImporter.SaveAndReimport();
|
||||
|
||||
// DXT5nm でロードされます。
|
||||
var texture =AssetDatabase.LoadAssetAtPath<Texture2D>(assetPath);
|
||||
```
|
||||
@@ -9,8 +9,16 @@ UnityでVRMをエクスポートする方法などについては [manual](https
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
package.md
|
||||
history.md
|
||||
package
|
||||
history
|
||||
```
|
||||
|
||||
## build
|
||||
|
||||
UniVRMを使うアプリケーションのビルドに関する注意事項
|
||||
|
||||
```{toctree}
|
||||
build
|
||||
```
|
||||
|
||||
## glTF
|
||||
@@ -18,9 +26,9 @@ history.md
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
gltf/0_82_glb_import.md
|
||||
gltf/how_to_impl_extension.md
|
||||
gltf/0_36_update.md
|
||||
gltf/0_82_glb_import
|
||||
gltf/how_to_impl_extension
|
||||
gltf/0_36_update
|
||||
```
|
||||
|
||||
## VRM
|
||||
@@ -28,20 +36,23 @@ gltf/0_36_update.md
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
vrm0/0_82_runtime_import.md
|
||||
vrm0/0_79_runtime_import.md
|
||||
vrm0/0_77_runtime_import.md
|
||||
vrm0/0_68_runtime_import.md
|
||||
vrm0/0_44_runtime_import.md
|
||||
vrm0/0_58_blendshape.md
|
||||
vrm0/firstperson.md
|
||||
vrm0/0_82_runtime_import
|
||||
vrm0/0_79_runtime_import
|
||||
vrm0/0_77_runtime_import
|
||||
vrm0/0_68_runtime_import
|
||||
vrm0/0_44_runtime_import
|
||||
vrm0/0_58_blendshape
|
||||
vrm0/firstperson
|
||||
```
|
||||
|
||||
## 実装メモ
|
||||
|
||||
```{toctree}
|
||||
:maxdepth: 1
|
||||
|
||||
implementation/runtime_resource_management.md
|
||||
implementation/runtime_resource_management
|
||||
implementation/texture_manipulation
|
||||
implementation/coordinate
|
||||
```
|
||||
|
||||
### Samples
|
||||
@@ -56,11 +67,11 @@ implementation/runtime_resource_management.md
|
||||
```{toctree}
|
||||
:maxdepth: 2
|
||||
|
||||
vrm1/vrm1_runtime_load.md
|
||||
vrm1/vrm1_get_humanoid.md
|
||||
vrm1/vrm1_expression.md
|
||||
vrm1/vrm1_lookat.md
|
||||
vrm1/vrm1_firstperson.md
|
||||
vrm1/vrm1_runtime_load
|
||||
vrm1/vrm1_get_humanoid
|
||||
vrm1/vrm1_expression
|
||||
vrm1/vrm1_lookat
|
||||
vrm1/vrm1_firstperson
|
||||
```
|
||||
|
||||
### Samples
|
||||
|
||||
Reference in New Issue
Block a user