diff --git a/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs b/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs index 73e8e946e..6276f97b3 100644 --- a/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs +++ b/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs @@ -231,21 +231,9 @@ namespace UniVRM10 { {"Standard", new string[]{ "_MainTex_ST", - "_BumpMap_ST", - "_EmissionMap_ST", - "_MetallicGlossMap_ST", - "_ParallaxMap_ST", }}, {"VRM10/MToon10", new string[]{ "_MainTex_ST", - "_ShadeTexture_ST", - "_BumpMap_ST", - "_EmissionMap_ST", - "_OutlineWidthTexture_ST", - "_ReceiveShadowTexture_ST", - "_RimTexture_ST", - "_ShadingGradeTexture_ST", - "_UvAnimMaskTexture_ST", }}, }; static string[] DefaultProps = { "_MainTex_ST" }; diff --git a/Assets/VRM10/Runtime/IO/Vrm10Data.cs b/Assets/VRM10/Runtime/IO/Vrm10Data.cs index fa5c493b3..f2a29f429 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Data.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Data.cs @@ -34,7 +34,7 @@ namespace UniVRM10 } /// - /// + /// /// /// /// @@ -80,21 +80,21 @@ namespace UniVRM10 { // migration 失敗 vrm1Data = default; - migration = new MigrationData(ex.Message, oldMeta); + migration = new MigrationData(ex.ToString(), oldMeta); return null; } catch (Exception ex) { // その他のエラー vrm1Data = default; - migration = new MigrationData(ex.Message, oldMeta); + migration = new MigrationData(ex.ToString(), oldMeta); return null; } byte[] debugCopy = null; if (VRMShaders.Symbols.VRM_DEVELOP) { - // load 時の右手左手座標変換でバッファが破壊的変更されるので、コピーを作っている + // load 時の右手左手座標変換でバッファが破壊的変更されるので、コピーを作っている debugCopy = migrated.Select(x => x).ToArray(); } diff --git a/Assets/VRM10/Runtime/Migration/MigrationVrmExpression.cs b/Assets/VRM10/Runtime/Migration/MigrationVrmExpression.cs index 5317a78e7..3352b1d72 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationVrmExpression.cs +++ b/Assets/VRM10/Runtime/Migration/MigrationVrmExpression.cs @@ -10,7 +10,7 @@ namespace UniVRM10 { /// /// preset 名の文字列から ExpressionPreset を確定させる。 - /// + /// /// 0.x の特殊な挙動として、 /// preset名が "unknown" の場合に、 /// "name" を preset 名として解釈を試みる。 @@ -82,7 +82,7 @@ namespace UniVRM10 } bind.Node = nodeIndex; bind.Index = morphTargetIndex; - // https://github.com/vrm-c/vrm-specification/issues/209 + // https://github.com/vrm-c/vrm-specification/issues/209 bind.Weight = weight * 0.01f; yield return bind; @@ -95,7 +95,7 @@ namespace UniVRM10 public const string OUTLINE_COLOR_PROPERTY = "_OutlineColor"; public const string SHADE_COLOR_PROPERTY = "_ShadeColor"; - static UniGLTF.Extensions.VRMC_vrm.MaterialColorType ToMaterialType(string src) + static UniGLTF.Extensions.VRMC_vrm.MaterialColorType? ToMaterialColorType(string src) { switch (src) { @@ -115,17 +115,17 @@ namespace UniVRM10 return UniGLTF.Extensions.VRMC_vrm.MaterialColorType.outlineColor; } - throw new NotImplementedException(); + return default; } /// /// MaterialValue の仕様変更 - /// + /// /// * MaterialColorBind /// * TextureTransformBind - /// + /// /// の2種類になった。 - /// + /// /// /// /// @@ -151,57 +151,70 @@ namespace UniVRM10 } var propertyName = x["propertyName"].GetString(); var targetValue = x["targetValue"].ArrayItems().Select(y => y.GetSingle()).ToArray(); - if (propertyName.EndsWith("_ST")) + if (propertyName == "_MainTex_ST") { // VRM-0 は無変換 var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset( new UnityEngine.Vector2(targetValue[0], targetValue[1]), new UnityEngine.Vector2(targetValue[2], targetValue[3])); - expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex)) { - Material = materialIndex, - Scale = new float[] { scale.x, scale.y }, - Offset = new float[] { offset.x, offset.y } - }); + expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + { + Material = materialIndex, + Scale = new float[] {scale.x, scale.y}, + Offset = new float[] {offset.x, offset.y} + }); + } } - else if (propertyName.EndsWith("_ST_S")) + else if (propertyName == "_MainTex_ST_S") { // VRM-0 は無変換 var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset( new UnityEngine.Vector2(targetValue[0], 1), new UnityEngine.Vector2(targetValue[2], 0)); - expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex)) { - Material = materialIndex, - Scale = new float[] { scale.x, scale.y }, - Offset = new float[] { offset.x, offset.y } - }); + expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + { + Material = materialIndex, + Scale = new float[] {scale.x, scale.y}, + Offset = new float[] {offset.x, offset.y} + }); + } } - else if (propertyName.EndsWith("_ST_T")) + else if (propertyName == "_MainTex_ST_T") { // VRM-0 は無変換 var (scale, offset) = UniGLTF.TextureTransform.VerticalFlipScaleOffset( new UnityEngine.Vector2(1, targetValue[1]), new UnityEngine.Vector2(0, targetValue[3])); - expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + if (!expression.TextureTransformBinds.Exists(bind => bind.Material == materialIndex)) { - Material = materialIndex, - Scale = new float[] { scale.x, scale.y }, - Offset = new float[] { offset.x, offset.y } - }); + expression.TextureTransformBinds.Add(new UniGLTF.Extensions.VRMC_vrm.TextureTransformBind + { + Material = materialIndex, + Scale = new float[] {scale.x, scale.y}, + Offset = new float[] {offset.x, offset.y} + }); + } } else { - // color - expression.MaterialColorBinds.Add(new UniGLTF.Extensions.VRMC_vrm.MaterialColorBind + var materialColorType = ToMaterialColorType(propertyName); + if (materialColorType.HasValue) { - Material = materialIndex, - Type = ToMaterialType(propertyName), - TargetValue = targetValue, - }); + // color + expression.MaterialColorBinds.Add(new UniGLTF.Extensions.VRMC_vrm.MaterialColorBind + { + Material = materialIndex, + Type = materialColorType.Value, + TargetValue = targetValue, + }); + } } } }