From f48512a90f06cd15bb96c2ad316f62ba8f4642ec Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 6 Oct 2021 15:00:30 +0900 Subject: [PATCH] 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