From 5656214f72155306b40c2ddf0215aedd889a367d Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Thu, 22 Sep 2022 21:17:14 +0900 Subject: [PATCH 1/2] Fix uv animation speed unit of vrm-1.0 --- .../VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs | 4 +++- .../VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs index f684739ae..7022c63cd 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs @@ -152,7 +152,9 @@ namespace UniVRM10 const float invertY = -1f; mtoon.UvAnimationScrollYSpeedFactor = context.UvAnimationScrollYSpeedFactor * invertY; } - mtoon.UvAnimationRotationSpeedFactor = context.UvAnimationRotationSpeedFactor; + // Speed unit Conversion + const float rotationPerSecToRadianPerSec = Mathf.PI * 2f; + mtoon.UvAnimationRotationSpeedFactor = context.UvAnimationRotationSpeedFactor * rotationPerSecToRadianPerSec; // Texture Transforms var scale = context.TextureScale; diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs index c0a5420a1..83d4fa9f6 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs @@ -224,7 +224,9 @@ namespace UniVRM10 var uvAnimSpeedRotation = mToon?.UvAnimationRotationSpeedFactor; if (uvAnimSpeedRotation.HasValue) { - yield return (MToon10Prop.UvAnimationRotationSpeedFactor.ToUnityShaderLabName(), uvAnimSpeedRotation.Value); + // Speed unit Conversion + const float radianPerSecToRotationPerSec = 1f / (Mathf.PI * 2f); + yield return (MToon10Prop.UvAnimationRotationSpeedFactor.ToUnityShaderLabName(), uvAnimSpeedRotation.Value * radianPerSecToRotationPerSec); } // UI From 51f80bde73b1fd2c3b4c7e1926d9971516e1ac98 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Mon, 26 Sep 2022 17:34:42 +0900 Subject: [PATCH 2/2] Fix uv animation rotation direction of vrm-1.0 --- .../VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs | 4 +++- .../VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs index 7022c63cd..482bb6154 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs @@ -154,7 +154,9 @@ namespace UniVRM10 } // Speed unit Conversion const float rotationPerSecToRadianPerSec = Mathf.PI * 2f; - mtoon.UvAnimationRotationSpeedFactor = context.UvAnimationRotationSpeedFactor * rotationPerSecToRadianPerSec; + // Coords conversion + const float unityToGltfCoordsConversion = -1f; + mtoon.UvAnimationRotationSpeedFactor = context.UvAnimationRotationSpeedFactor * rotationPerSecToRadianPerSec * unityToGltfCoordsConversion; // Texture Transforms var scale = context.TextureScale; diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs index 83d4fa9f6..aa2ccb4a8 100644 --- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs +++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialImporter.cs @@ -226,7 +226,9 @@ namespace UniVRM10 { // Speed unit Conversion const float radianPerSecToRotationPerSec = 1f / (Mathf.PI * 2f); - yield return (MToon10Prop.UvAnimationRotationSpeedFactor.ToUnityShaderLabName(), uvAnimSpeedRotation.Value * radianPerSecToRotationPerSec); + // Coords conversion + const float gltfToUnityCoordsConversion = -1f; + yield return (MToon10Prop.UvAnimationRotationSpeedFactor.ToUnityShaderLabName(), uvAnimSpeedRotation.Value * radianPerSecToRotationPerSec * gltfToUnityCoordsConversion); } // UI