mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-27 21:34:38 -05:00
texture_manipulation.md
This commit is contained in:
@@ -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
|
||||
|
||||
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,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
|
||||
|
||||
Reference in New Issue
Block a user