From 29ba36e1ad4dd115bc2b17478e64899accc11778 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 6 Oct 2021 14:54:13 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E8=A8=80=E8=AA=9E=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/_templates/layout.html | 13 +++++++++++++ docs/conf.py | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 docs/_templates/layout.html diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html new file mode 100644 index 000000000..d25a78edd --- /dev/null +++ b/docs/_templates/layout.html @@ -0,0 +1,13 @@ +{% extends "!layout.html" %} + +{% block sidebarlogo %} + +{{ super() }} +{% endblock %} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 7f68b1455..e0c2c1b85 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -56,3 +56,5 @@ html_static_path = ['_static'] locale_dirs = ['locale/'] gettext_compact = False + +html_context = {"language": language} From f48512a90f06cd15bb96c2ad316f62ba8f4642ec Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 6 Oct 2021 15:00:30 +0900 Subject: [PATCH 2/4] texture_manipulation.md --- .../UniGLTF/doc/DepthFirstScheduler.README.md | 2 +- Assets/UniGLTF/doc/UniJSON.README.md | 14 ++-- docs/implementation/texture_manipulation.md | 65 +++++++++++++++++++ docs/index.md | 38 ++++++----- 4 files changed, 93 insertions(+), 26 deletions(-) create mode 100644 docs/implementation/texture_manipulation.md diff --git a/Assets/UniGLTF/doc/DepthFirstScheduler.README.md b/Assets/UniGLTF/doc/DepthFirstScheduler.README.md index f62408945..8c41bb7a3 100644 --- a/Assets/UniGLTF/doc/DepthFirstScheduler.README.md +++ b/Assets/UniGLTF/doc/DepthFirstScheduler.README.md @@ -8,7 +8,7 @@ Asynchronous task scheduler for Unity-5.6 or later # 使い方 -```cs +```csharp var schedulable = new Schedulable(); schedulable diff --git a/Assets/UniGLTF/doc/UniJSON.README.md b/Assets/UniGLTF/doc/UniJSON.README.md index 89136662f..a66d8b737 100644 --- a/Assets/UniGLTF/doc/UniJSON.README.md +++ b/Assets/UniGLTF/doc/UniJSON.README.md @@ -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 msgpack = f.GetStoreBytes(); @@ -95,7 +95,7 @@ var x = parsed["X"].GetInt32(); WIP -```cs +```csharp var toml =@" X = 1 Y = 2 diff --git a/docs/implementation/texture_manipulation.md b/docs/implementation/texture_manipulation.md new file mode 100644 index 000000000..d6c124b61 --- /dev/null +++ b/docs/implementation/texture_manipulation.md @@ -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(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(assetPath); +``` diff --git a/docs/index.md b/docs/index.md index 9e9cbc0ff..d7e601012 100644 --- a/docs/index.md +++ b/docs/index.md @@ -9,8 +9,8 @@ UnityでVRMをエクスポートする方法などについては [manual](https ```{toctree} :maxdepth: 1 -package.md -history.md +package +history ``` ## glTF @@ -18,9 +18,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 +28,22 @@ 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 ``` ### Samples @@ -56,11 +58,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 From d92f30b8bbab77139316a44cd43b0b3a54dd2435 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 6 Oct 2021 15:25:46 +0900 Subject: [PATCH 3/4] coordinate --- docs/implementation/coordinate.md | 63 +++++++++++++++++++++++++++++++ docs/index.md | 1 + 2 files changed, 64 insertions(+) create mode 100644 docs/implementation/coordinate.md diff --git a/docs/implementation/coordinate.md b/docs/implementation/coordinate.md new file mode 100644 index 000000000..6a84cd14d --- /dev/null +++ b/docs/implementation/coordinate.md @@ -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軸を反転します。 diff --git a/docs/index.md b/docs/index.md index d7e601012..66a5b36c5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,6 +44,7 @@ vrm0/firstperson implementation/runtime_resource_management implementation/texture_manipulation +implementation/univrm_coordinate ``` ### Samples From b261ca2a0ce01d24e88f261da6c305c653df0eab Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 6 Oct 2021 15:52:56 +0900 Subject: [PATCH 4/4] =?UTF-8?q?build=20=E3=81=AB=E3=82=B7=E3=82=A7?= =?UTF-8?q?=E3=83=BC=E3=83=80=E3=83=BC=E5=90=AB=E3=82=81=E3=82=8B=E8=AA=AC?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/build.md | 19 +++++++++++++++++++ docs/implementation/coordinate.md | 6 +++--- docs/index.md | 10 +++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 docs/build.md diff --git a/docs/build.md b/docs/build.md new file mode 100644 index 000000000..944c24bd3 --- /dev/null +++ b/docs/build.md @@ -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` diff --git a/docs/implementation/coordinate.md b/docs/implementation/coordinate.md index 6a84cd14d..8737c1670 100644 --- a/docs/implementation/coordinate.md +++ b/docs/implementation/coordinate.md @@ -21,7 +21,7 @@ V^{\prime} = 1 - V Z軸を反転します。 -### Vector3(Position, Normalなど) +### Vector3: Position, Normalなど ```csharp public static Vector3 ReverseZ(this Vector3 v) @@ -30,7 +30,7 @@ public static Vector3 ReverseZ(this Vector3 v) } ``` -### Quaternion(Rotation) +### Quaternion: Rotation ```csharp public static Quaternion ReverseZ(this Quaternion q) @@ -42,7 +42,7 @@ public static Quaternion ReverseZ(this Quaternion q) } ``` -### Matrix(BindMatrices) +### Matrix: BindMatrices スケール値が入っているとうまくいきません diff --git a/docs/index.md b/docs/index.md index 66a5b36c5..c35471bcf 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,6 +13,14 @@ package history ``` +## build + +UniVRMを使うアプリケーションのビルドに関する注意事項 + +```{toctree} +build +``` + ## glTF ```{toctree} @@ -44,7 +52,7 @@ vrm0/firstperson implementation/runtime_resource_management implementation/texture_manipulation -implementation/univrm_coordinate +implementation/coordinate ``` ### Samples