From b8334ae6453fdd6af73099a08e9bb0a6046483e6 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 14 Apr 2021 17:38:05 +0900 Subject: [PATCH 1/5] pull JsonSchema. debug --- .../Editor/JsonSchema/JsonSchemaParser.cs | 7 ++++++- Assets/VRM10/Editor/GeneratorMenu.cs | 19 +++++++++++++++-- Packages/manifest.json | 21 +++++++++++++------ ProjectSettings/ProjectVersion.txt | 3 ++- vrm-specification | 2 +- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs index 79ef30147..fb9ec2c1b 100644 --- a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs +++ b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs @@ -187,7 +187,12 @@ namespace UniGLTF.JsonSchema // source.properties = new Dictionary(); foreach (var prop in kv.Value.ObjectItems()) { - var propJsonPath = $"{jsonPath}.{prop.Key.GetString()}"; + var key = prop.Key.GetString(); + if (key == "scale") + { + var a = 0; + } + var propJsonPath = $"{jsonPath}.{key}"; var propSchema = Parse(prop.Value, propJsonPath); if (propSchema is null) { diff --git a/Assets/VRM10/Editor/GeneratorMenu.cs b/Assets/VRM10/Editor/GeneratorMenu.cs index 1fb52567f..9224a69aa 100644 --- a/Assets/VRM10/Editor/GeneratorMenu.cs +++ b/Assets/VRM10/Editor/GeneratorMenu.cs @@ -20,7 +20,18 @@ namespace UniVRM10 public static class Menu { [MenuItem(UniVRM10.VRMVersion.MENU + "/Generate from JsonSchema")] - public static void Main() + public static void Generate() + { + Run(false); + } + + [MenuItem(UniVRM10.VRMVersion.MENU + "/Generate from JsonSchema(debug)")] + public static void Parse() + { + Run(true); + } + + static void Run(bool debug) { var projectRoot = new DirectoryInfo(Path.GetFullPath(Path.Combine(Application.dataPath, "../"))); @@ -50,7 +61,11 @@ namespace UniVRM10 var extensionSchemaPath = new FileInfo(Path.Combine(projectRoot.FullName, args[i])); var parser = new UniGLTF.JsonSchema.JsonSchemaParser(gltf.Directory, extensionSchemaPath.Directory); var extensionSchema = parser.Load(extensionSchemaPath, ""); - // extensionSchema.Dump(); + if (debug) + { + extensionSchema.Dump(); + continue; + } var dst = new DirectoryInfo(Path.Combine(projectRoot.FullName, args[i + 1])); Debug.Log(dst); diff --git a/Packages/manifest.json b/Packages/manifest.json index ddf67b40c..e1b6036fa 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,12 +1,21 @@ { "dependencies": { - "com.unity.ads": "2.0.8", - "com.unity.analytics": "3.2.3", - "com.unity.collab-proxy": "1.2.15", - "com.unity.package-manager-ui": "2.0.13", - "com.unity.purchasing": "2.0.3", - "com.unity.textmeshpro": "1.4.1", + "com.unity.2d.sprite": "1.0.0", + "com.unity.2d.tilemap": "1.0.0", + "com.unity.ads": "3.6.1", + "com.unity.analytics": "3.3.5", + "com.unity.collab-proxy": "1.2.16", + "com.unity.ide.rider": "1.1.4", + "com.unity.ide.vscode": "1.2.3", + "com.unity.multiplayer-hlapi": "1.0.8", + "com.unity.purchasing": "3.0.1", + "com.unity.test-framework": "1.1.24", + "com.unity.textmeshpro": "2.1.4", + "com.unity.timeline": "1.2.18", + "com.unity.ugui": "1.0.0", + "com.unity.xr.legacyinputhelpers": "2.1.7", "com.unity.modules.ai": "1.0.0", + "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index ca463ed35..1aeef8d90 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1 +1,2 @@ -m_EditorVersion: 2018.4.27f1 +m_EditorVersion: 2019.4.24f1 +m_EditorVersionWithRevision: 2019.4.24f1 (5da6f0345e82) diff --git a/vrm-specification b/vrm-specification index 068254bdf..e14461555 160000 --- a/vrm-specification +++ b/vrm-specification @@ -1 +1 @@ -Subproject commit 068254bdf1ca0fb8473487073c82164cb97432d0 +Subproject commit e14461555138092921b8b25dddeda12acf2bf069 From 208311164be0e75b16f093acb01b2d181a68c0ab Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 14 Apr 2021 17:45:24 +0900 Subject: [PATCH 2/5] VRMC_constraints to VRMC_node_constraint --- .../Editor/JsonSchema/JsonSchemaSource.cs | 15 +++++++++--- Assets/VRM10/Editor/GeneratorMenu.cs | 23 +++++++++++-------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaSource.cs b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaSource.cs index 5835f4c68..447553bee 100644 --- a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaSource.cs +++ b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaSource.cs @@ -2,6 +2,8 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text; +using UnityEngine; namespace UniGLTF.JsonSchema { @@ -261,14 +263,21 @@ namespace UniGLTF.JsonSchema } } - public void Dump(string indent = "") + public void Dump(StringBuilder sb, string indent = "") { - Console.WriteLine($"{indent}{JsonPath}: {type}"); + sb.AppendLine($"{indent}{JsonPath}: {type}"); foreach (var x in Children()) { - x.Dump(indent + " "); + x.Dump(sb, indent + " "); } } + + public string Dump() + { + var sb = new StringBuilder(); + Dump(sb); + return sb.ToString(); + } } } diff --git a/Assets/VRM10/Editor/GeneratorMenu.cs b/Assets/VRM10/Editor/GeneratorMenu.cs index 9224a69aa..cdc20e1d1 100644 --- a/Assets/VRM10/Editor/GeneratorMenu.cs +++ b/Assets/VRM10/Editor/GeneratorMenu.cs @@ -43,15 +43,15 @@ namespace UniVRM10 "vrm-specification/specification/VRMC_vrm-1.0_draft/schema/VRMC_vrm.schema.json", "Assets/VRM10/Runtime/Format/Vrm", // dst // VRMC_constraints - "vrm-specification/specification/VRMC_constraints-1.0_draft/schema/VRMC_constraints.schema.json", + "vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json", "Assets/VRM10/Runtime/Format/Constraints", // dst - // + // VRMC_materials_mtoon "vrm-specification/specification/VRMC_materials_mtoon-1.0_draft/schema/VRMC_materials_mtoon.schema.json", "Assets/VRM10/Runtime/Format/MaterialsMToon", // dst - // + // VRMC_node_collider "vrm-specification/specification/VRMC_node_collider_1.0_draft/schema/VRMC_node_collider.json", "Assets/VRM10/Runtime/Format/NodeCollider", // dst - // + // VRMC_springBone "vrm-specification/specification/VRMC_springBone-1.0_draft/schema/VRMC_springBone.schema.json", "Assets/VRM10/Runtime/Format/SpringBone", // dst }; @@ -61,15 +61,18 @@ namespace UniVRM10 var extensionSchemaPath = new FileInfo(Path.Combine(projectRoot.FullName, args[i])); var parser = new UniGLTF.JsonSchema.JsonSchemaParser(gltf.Directory, extensionSchemaPath.Directory); var extensionSchema = parser.Load(extensionSchemaPath, ""); - if (debug) - { - extensionSchema.Dump(); - continue; - } var dst = new DirectoryInfo(Path.Combine(projectRoot.FullName, args[i + 1])); Debug.Log(dst); - GenerateUniGLTFSerialization.Generator.GenerateTo(extensionSchema, dst, clearFolder: true); + + if (debug) + { + Debug.Log(extensionSchema.Dump()); + } + else + { + GenerateUniGLTFSerialization.Generator.GenerateTo(extensionSchema, dst, clearFolder: true); + } } } } From 99e2ac8a83d8844ebb67873a2df77e4a31f1550b Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 14:50:27 +0900 Subject: [PATCH 3/5] =?UTF-8?q?vrm-specification=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=97=E3=81=A6=E3=80=81=E3=82=B3=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=82=92=E5=86=8D=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Editor/GeneratorMenu.cs | 2 +- .../Constraint/ConstraintDestination.cs | 2 +- .../Components/Constraint/ConstraintSource.cs | 2 +- .../Constraint/VRM10PositionConstraint.cs | 2 +- .../Constraint/VRM10RotationConstraint.cs | 2 +- .../Format/Constraints/Deserializer.g.cs | 37 ++- .../Runtime/Format/Constraints/Format.g.cs | 36 ++- .../Format/Constraints/Serializer.g.cs | 31 ++- .../Format/MaterialsMToon/Deserializer.g.cs | 263 +++++++++++++++--- .../Runtime/Format/MaterialsMToon/Format.g.cs | 78 ++++-- .../Format/MaterialsMToon/Serializer.g.cs | 261 ++++++++++++++--- Assets/VRM10/Runtime/Format/Vrm/Format.g.cs | 1 + .../VRM10/Runtime/IO/RuntimeUnityBuilder.cs | 3 +- Assets/VRM10/Runtime/IO/Vrm10Exporter.cs | 2 +- .../Runtime/IO/Vrm10MToonMaterialImporter.cs | 32 +-- .../VRM10/Runtime/IO/Vrm10MaterialExporter.cs | 16 +- .../VRM10/Runtime/Migration/MigrationMToon.cs | 23 +- vrm-specification | 2 +- 18 files changed, 623 insertions(+), 172 deletions(-) diff --git a/Assets/VRM10/Editor/GeneratorMenu.cs b/Assets/VRM10/Editor/GeneratorMenu.cs index cdc20e1d1..fa7fd2993 100644 --- a/Assets/VRM10/Editor/GeneratorMenu.cs +++ b/Assets/VRM10/Editor/GeneratorMenu.cs @@ -42,7 +42,7 @@ namespace UniVRM10 // VRMC_vrm "vrm-specification/specification/VRMC_vrm-1.0_draft/schema/VRMC_vrm.schema.json", "Assets/VRM10/Runtime/Format/Vrm", // dst - // VRMC_constraints + // VRMC_node_constraint "vrm-specification/specification/VRMC_node_constraint-1.0_draft/schema/VRMC_node_constraint.schema.json", "Assets/VRM10/Runtime/Format/Constraints", // dst // VRMC_materials_mtoon diff --git a/Assets/VRM10/Runtime/Components/Constraint/ConstraintDestination.cs b/Assets/VRM10/Runtime/Components/Constraint/ConstraintDestination.cs index 57478bba3..54dbb4525 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/ConstraintDestination.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/ConstraintDestination.cs @@ -1,5 +1,5 @@ using System; -using UniGLTF.Extensions.VRMC_constraints; +using UniGLTF.Extensions.VRMC_node_constraint; using UnityEngine; namespace UniVRM10 diff --git a/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs b/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs index 3101adf18..a199b2de4 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs @@ -1,6 +1,6 @@ using UnityEngine; using System; -using UniGLTF.Extensions.VRMC_constraints; +using UniGLTF.Extensions.VRMC_node_constraint; namespace UniVRM10 { diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs index 200222977..614b69d1d 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs @@ -1,4 +1,4 @@ -using UniGLTF.Extensions.VRMC_constraints; +using UniGLTF.Extensions.VRMC_node_constraint; using UnityEngine; namespace UniVRM10 diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs index e360904aa..b747417bd 100644 --- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs +++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs @@ -1,4 +1,4 @@ -using UniGLTF.Extensions.VRMC_constraints; +using UniGLTF.Extensions.VRMC_node_constraint; using UnityEngine; diff --git a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs index c2ef074e1..39c374210 100644 --- a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs +++ b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs @@ -4,18 +4,18 @@ using System; using System.Collections.Generic; using UnityEngine; -namespace UniGLTF.Extensions.VRMC_constraints { +namespace UniGLTF.Extensions.VRMC_node_constraint { public static class GltfDeserializer { -public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_constraints extension) +public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_node_constraint extension) { if(src is UniGLTF.glTFExtensionImport extensions) { foreach(var kv in extensions.ObjectItems()) { - if(kv.Key.GetUtf8String() == VRMC_constraints.ExtensionNameUtf8) + if(kv.Key.GetUtf8String() == VRMC_node_constraint.ExtensionNameUtf8) { extension = Deserialize(kv.Value); return true; @@ -28,9 +28,36 @@ public static bool TryGet(UniGLTF.glTFExtension src, out VRMC_constraints extens } -public static VRMC_constraints Deserialize(JsonNode parsed) +public static VRMC_node_constraint Deserialize(JsonNode parsed) { - var value = new VRMC_constraints(); + var value = new VRMC_node_constraint(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="constraint"){ + value.Constraint = Deserialize_Constraint(kv.Value); + continue; + } + + } + return value; +} + +public static Constraint Deserialize_Constraint(JsonNode parsed) +{ + var value = new Constraint(); foreach(var kv in parsed.ObjectItems()) { diff --git a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs index d998f262a..13a812f1c 100644 --- a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs +++ b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using UniGLTF; using UniJSON; -namespace UniGLTF.Extensions.VRMC_constraints +namespace UniGLTF.Extensions.VRMC_node_constraint { public enum ObjectSpace @@ -94,7 +94,7 @@ namespace UniGLTF.Extensions.VRMC_constraints [JsonSchema(EnumSerializationType = EnumSerializationType.AsString)] public ObjectSpace DestinationSpace; - // An axis which faces the direction of its sources. + // An axis which faces the direction of its source. public float[] AimVector; // An up axis of the constraint. @@ -107,9 +107,27 @@ namespace UniGLTF.Extensions.VRMC_constraints public float? Weight; } - public class VRMC_constraints + public class Constraint { - public const string ExtensionName = "VRMC_constraints"; + // Dictionary object with extension-specific objects. + public glTFExtension Extensions; + + // Application-specific data. + public glTFExtension Extras; + + // A constraint that links the position with a source. + public PositionConstraint Position; + + // A constraint that links the rotation with a source. + public RotationConstraint Rotation; + + // A constraint that rotates the node to face a source. + public AimConstraint Aim; + } + + public class VRMC_node_constraint + { + public const string ExtensionName = "VRMC_node_constraint"; public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName); // Dictionary object with extension-specific objects. @@ -118,13 +136,7 @@ namespace UniGLTF.Extensions.VRMC_constraints // Application-specific data. public glTFExtension Extras; - // A constraint that links the position with sources. - public PositionConstraint Position; - - // A constraint that links the rotation with sources. - public RotationConstraint Rotation; - - // A constraint that rotates the node to face sources. - public AimConstraint Aim; + // Contains position, rotation, or aim + public Constraint Constraint; } } diff --git a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs index 23474e085..baf92073f 100644 --- a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs +++ b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs @@ -4,12 +4,12 @@ using System.Collections.Generic; using System.Linq; using UniJSON; -namespace UniGLTF.Extensions.VRMC_constraints { +namespace UniGLTF.Extensions.VRMC_node_constraint { static public class GltfSerializer { - public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_constraints extension) + public static void SerializeTo(ref UniGLTF.glTFExtension dst, VRMC_node_constraint extension) { if (dst is glTFExtensionImport) { @@ -24,11 +24,34 @@ namespace UniGLTF.Extensions.VRMC_constraints { var f = new JsonFormatter(); Serialize(f, extension); - extensions.Add(VRMC_constraints.ExtensionName, f.GetStoreBytes()); + extensions.Add(VRMC_node_constraint.ExtensionName, f.GetStoreBytes()); } -public static void Serialize(JsonFormatter f, VRMC_constraints value) +public static void Serialize(JsonFormatter f, VRMC_node_constraint value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Constraint!=null){ + f.Key("constraint"); + Serialize_Constraint(f, value.Constraint); + } + + f.EndMap(); +} + +public static void Serialize_Constraint(JsonFormatter f, Constraint value) { f.BeginMap(); diff --git a/Assets/VRM10/Runtime/Format/MaterialsMToon/Deserializer.g.cs b/Assets/VRM10/Runtime/Format/MaterialsMToon/Deserializer.g.cs index 1a5d05a04..3d6714e44 100644 --- a/Assets/VRM10/Runtime/Format/MaterialsMToon/Deserializer.g.cs +++ b/Assets/VRM10/Runtime/Format/MaterialsMToon/Deserializer.g.cs @@ -36,6 +36,16 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) { var key = kv.Key.GetString(); + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + if(key=="version"){ value.Version = kv.Value.GetString(); continue; @@ -51,13 +61,13 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) continue; } - if(key=="shadeFactor"){ - value.ShadeFactor = Deserialize_ShadeFactor(kv.Value); + if(key=="shadeColorFactor"){ + value.ShadeColorFactor = Deserialize_ShadeColorFactor(kv.Value); continue; } if(key=="shadeMultiplyTexture"){ - value.ShadeMultiplyTexture = kv.Value.GetInt32(); + value.ShadeMultiplyTexture = Deserialize_ShadeMultiplyTexture(kv.Value); continue; } @@ -66,13 +76,13 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) continue; } - if(key=="shadingToonyFactor"){ - value.ShadingToonyFactor = kv.Value.GetSingle(); + if(key=="shadingShiftTexture"){ + value.ShadingShiftTexture = Deserialize_ShadingShiftTexture(kv.Value); continue; } - if(key=="lightColorAttenuationFactor"){ - value.LightColorAttenuationFactor = kv.Value.GetSingle(); + if(key=="shadingToonyFactor"){ + value.ShadingToonyFactor = kv.Value.GetSingle(); continue; } @@ -81,18 +91,18 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) continue; } - if(key=="additiveTexture"){ - value.AdditiveTexture = kv.Value.GetInt32(); + if(key=="matcapTexture"){ + value.MatcapTexture = Deserialize_MatcapTexture(kv.Value); continue; } - if(key=="rimFactor"){ - value.RimFactor = Deserialize_RimFactor(kv.Value); + if(key=="parametricRimColorFactor"){ + value.ParametricRimColorFactor = Deserialize_ParametricRimColorFactor(kv.Value); continue; } if(key=="rimMultiplyTexture"){ - value.RimMultiplyTexture = kv.Value.GetInt32(); + value.RimMultiplyTexture = Deserialize_RimMultiplyTexture(kv.Value); continue; } @@ -101,13 +111,13 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) continue; } - if(key=="rimFresnelPowerFactor"){ - value.RimFresnelPowerFactor = kv.Value.GetSingle(); + if(key=="parametricRimFresnelPowerFactor"){ + value.ParametricRimFresnelPowerFactor = kv.Value.GetSingle(); continue; } - if(key=="rimLiftFactor"){ - value.RimLiftFactor = kv.Value.GetSingle(); + if(key=="parametricRimLiftFactor"){ + value.ParametricRimLiftFactor = kv.Value.GetSingle(); continue; } @@ -122,22 +132,12 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) } if(key=="outlineWidthMultiplyTexture"){ - value.OutlineWidthMultiplyTexture = kv.Value.GetInt32(); + value.OutlineWidthMultiplyTexture = Deserialize_OutlineWidthMultiplyTexture(kv.Value); continue; } - if(key=="outlineScaledMaxDistanceFactor"){ - value.OutlineScaledMaxDistanceFactor = kv.Value.GetSingle(); - continue; - } - - if(key=="outlineColorMode"){ - value.OutlineColorMode = (OutlineColorMode)Enum.Parse(typeof(OutlineColorMode), kv.Value.GetString(), true); - continue; - } - - if(key=="outlineFactor"){ - value.OutlineFactor = Deserialize_OutlineFactor(kv.Value); + if(key=="outlineColorFactor"){ + value.OutlineColorFactor = Deserialize_OutlineColorFactor(kv.Value); continue; } @@ -147,7 +147,7 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) } if(key=="uvAnimationMaskTexture"){ - value.UvAnimationMaskTexture = kv.Value.GetInt32(); + value.UvAnimationMaskTexture = Deserialize_UvAnimationMaskTexture(kv.Value); continue; } @@ -170,7 +170,7 @@ public static VRMC_materials_mtoon Deserialize(JsonNode parsed) return value; } -public static float[] Deserialize_ShadeFactor(JsonNode parsed) +public static float[] Deserialize_ShadeColorFactor(JsonNode parsed) { var value = new float[parsed.GetArrayCount()]; int i=0; @@ -181,7 +181,108 @@ public static float[] Deserialize_ShadeFactor(JsonNode parsed) return value; } -public static float[] Deserialize_RimFactor(JsonNode parsed) +public static TextureInfo Deserialize_ShadeMultiplyTexture(JsonNode parsed) +{ + var value = new TextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static ShadingShiftTextureInfo Deserialize_ShadingShiftTexture(JsonNode parsed) +{ + var value = new ShadingShiftTextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + if(key=="scale"){ + value.Scale = kv.Value.GetSingle(); + continue; + } + + } + return value; +} + +public static TextureInfo Deserialize_MatcapTexture(JsonNode parsed) +{ + var value = new TextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static float[] Deserialize_ParametricRimColorFactor(JsonNode parsed) { var value = new float[parsed.GetArrayCount()]; int i=0; @@ -192,7 +293,71 @@ public static float[] Deserialize_RimFactor(JsonNode parsed) return value; } -public static float[] Deserialize_OutlineFactor(JsonNode parsed) +public static TextureInfo Deserialize_RimMultiplyTexture(JsonNode parsed) +{ + var value = new TextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static TextureInfo Deserialize_OutlineWidthMultiplyTexture(JsonNode parsed) +{ + var value = new TextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + +public static float[] Deserialize_OutlineColorFactor(JsonNode parsed) { var value = new float[parsed.GetArrayCount()]; int i=0; @@ -203,5 +368,37 @@ public static float[] Deserialize_OutlineFactor(JsonNode parsed) return value; } +public static TextureInfo Deserialize_UvAnimationMaskTexture(JsonNode parsed) +{ + var value = new TextureInfo(); + + foreach(var kv in parsed.ObjectItems()) + { + var key = kv.Key.GetString(); + + if(key=="extensions"){ + value.Extensions = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="extras"){ + value.Extras = new glTFExtensionImport(kv.Value); + continue; + } + + if(key=="index"){ + value.Index = kv.Value.GetInt32(); + continue; + } + + if(key=="texCoord"){ + value.TexCoord = kv.Value.GetInt32(); + continue; + } + + } + return value; +} + } // GltfDeserializer } // UniGLTF diff --git a/Assets/VRM10/Runtime/Format/MaterialsMToon/Format.g.cs b/Assets/VRM10/Runtime/Format/MaterialsMToon/Format.g.cs index b835241cc..1812ab9cb 100644 --- a/Assets/VRM10/Runtime/Format/MaterialsMToon/Format.g.cs +++ b/Assets/VRM10/Runtime/Format/MaterialsMToon/Format.g.cs @@ -7,6 +7,39 @@ using UniJSON; namespace UniGLTF.Extensions.VRMC_materials_mtoon { + public class TextureInfo + { + // Dictionary object with extension-specific objects. + public glTFExtension Extensions; + + // Application-specific data. + public glTFExtension Extras; + + // The index of the texture. + public int? Index; + + // The set index of texture's TEXCOORD attribute used for texture coordinate mapping. + public int? TexCoord; + } + + public class ShadingShiftTextureInfo + { + // Dictionary object with extension-specific objects. + public glTFExtension Extensions; + + // Application-specific data. + public glTFExtension Extras; + + // The index of the texture. + public int? Index; + + // The set index of texture's TEXCOORD attribute used for texture coordinate mapping. + public int? TexCoord; + + // The scalar multiplier applied to the texture. + public float? Scale; + } + public enum OutlineWidthMode { none, @@ -15,52 +48,52 @@ namespace UniGLTF.Extensions.VRMC_materials_mtoon } - public enum OutlineColorMode - { - fixedColor, - mixedLighting, - - } - public class VRMC_materials_mtoon { public const string ExtensionName = "VRMC_materials_mtoon"; public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName); + // Dictionary object with extension-specific objects. + public glTFExtension Extensions; + + // Application-specific data. + public glTFExtension Extras; + // Meta public string Version; - // enable depth buffer when renderMode is transparent + // enable depth buffer when `alphaMode` is `BLEND` public bool? TransparentWithZWrite; public int? RenderQueueOffsetNumber; - public float[] ShadeFactor; + public float[] ShadeColorFactor; - public int? ShadeMultiplyTexture; + public TextureInfo ShadeMultiplyTexture; // Lighting public float? ShadingShiftFactor; - public float? ShadingToonyFactor; + // Reference to a texture. + public ShadingShiftTextureInfo ShadingShiftTexture; - public float? LightColorAttenuationFactor; + public float? ShadingToonyFactor; public float? GiIntensityFactor; // MatCap - public int? AdditiveTexture; + public TextureInfo MatcapTexture; // Rim - public float[] RimFactor; + public float[] ParametricRimColorFactor; - public int? RimMultiplyTexture; + public TextureInfo RimMultiplyTexture; public float? RimLightingMixFactor; - public float? RimFresnelPowerFactor; + public float? ParametricRimFresnelPowerFactor; - public float? RimLiftFactor; + public float? ParametricRimLiftFactor; // Outline [JsonSchema(EnumSerializationType = EnumSerializationType.AsString)] @@ -68,18 +101,13 @@ namespace UniGLTF.Extensions.VRMC_materials_mtoon public float? OutlineWidthFactor; - public int? OutlineWidthMultiplyTexture; + public TextureInfo OutlineWidthMultiplyTexture; - public float? OutlineScaledMaxDistanceFactor; - - [JsonSchema(EnumSerializationType = EnumSerializationType.AsString)] - public OutlineColorMode OutlineColorMode; - - public float[] OutlineFactor; + public float[] OutlineColorFactor; public float? OutlineLightingMixFactor; - public int? UvAnimationMaskTexture; + public TextureInfo UvAnimationMaskTexture; public float? UvAnimationScrollXSpeedFactor; diff --git a/Assets/VRM10/Runtime/Format/MaterialsMToon/Serializer.g.cs b/Assets/VRM10/Runtime/Format/MaterialsMToon/Serializer.g.cs index 33ad2640a..b6e3369a2 100644 --- a/Assets/VRM10/Runtime/Format/MaterialsMToon/Serializer.g.cs +++ b/Assets/VRM10/Runtime/Format/MaterialsMToon/Serializer.g.cs @@ -33,6 +33,16 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.BeginMap(); + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + if(!string.IsNullOrEmpty(value.Version)){ f.Key("version"); f.Value(value.Version); @@ -48,14 +58,14 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.Value(value.RenderQueueOffsetNumber.GetValueOrDefault()); } - if(value.ShadeFactor!=null&&value.ShadeFactor.Count()>=0){ - f.Key("shadeFactor"); - Serialize_ShadeFactor(f, value.ShadeFactor); + if(value.ShadeColorFactor!=null&&value.ShadeColorFactor.Count()>=3){ + f.Key("shadeColorFactor"); + Serialize_ShadeColorFactor(f, value.ShadeColorFactor); } - if(value.ShadeMultiplyTexture.HasValue){ + if(value.ShadeMultiplyTexture!=null){ f.Key("shadeMultiplyTexture"); - f.Value(value.ShadeMultiplyTexture.GetValueOrDefault()); + Serialize_ShadeMultiplyTexture(f, value.ShadeMultiplyTexture); } if(value.ShadingShiftFactor.HasValue){ @@ -63,34 +73,34 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.Value(value.ShadingShiftFactor.GetValueOrDefault()); } + if(value.ShadingShiftTexture!=null){ + f.Key("shadingShiftTexture"); + Serialize_ShadingShiftTexture(f, value.ShadingShiftTexture); + } + if(value.ShadingToonyFactor.HasValue){ f.Key("shadingToonyFactor"); f.Value(value.ShadingToonyFactor.GetValueOrDefault()); } - if(value.LightColorAttenuationFactor.HasValue){ - f.Key("lightColorAttenuationFactor"); - f.Value(value.LightColorAttenuationFactor.GetValueOrDefault()); - } - if(value.GiIntensityFactor.HasValue){ f.Key("giIntensityFactor"); f.Value(value.GiIntensityFactor.GetValueOrDefault()); } - if(value.AdditiveTexture.HasValue){ - f.Key("additiveTexture"); - f.Value(value.AdditiveTexture.GetValueOrDefault()); + if(value.MatcapTexture!=null){ + f.Key("matcapTexture"); + Serialize_MatcapTexture(f, value.MatcapTexture); } - if(value.RimFactor!=null&&value.RimFactor.Count()>=0){ - f.Key("rimFactor"); - Serialize_RimFactor(f, value.RimFactor); + if(value.ParametricRimColorFactor!=null&&value.ParametricRimColorFactor.Count()>=3){ + f.Key("parametricRimColorFactor"); + Serialize_ParametricRimColorFactor(f, value.ParametricRimColorFactor); } - if(value.RimMultiplyTexture.HasValue){ + if(value.RimMultiplyTexture!=null){ f.Key("rimMultiplyTexture"); - f.Value(value.RimMultiplyTexture.GetValueOrDefault()); + Serialize_RimMultiplyTexture(f, value.RimMultiplyTexture); } if(value.RimLightingMixFactor.HasValue){ @@ -98,14 +108,14 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.Value(value.RimLightingMixFactor.GetValueOrDefault()); } - if(value.RimFresnelPowerFactor.HasValue){ - f.Key("rimFresnelPowerFactor"); - f.Value(value.RimFresnelPowerFactor.GetValueOrDefault()); + if(value.ParametricRimFresnelPowerFactor.HasValue){ + f.Key("parametricRimFresnelPowerFactor"); + f.Value(value.ParametricRimFresnelPowerFactor.GetValueOrDefault()); } - if(value.RimLiftFactor.HasValue){ - f.Key("rimLiftFactor"); - f.Value(value.RimLiftFactor.GetValueOrDefault()); + if(value.ParametricRimLiftFactor.HasValue){ + f.Key("parametricRimLiftFactor"); + f.Value(value.ParametricRimLiftFactor.GetValueOrDefault()); } if(true){ @@ -118,24 +128,14 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.Value(value.OutlineWidthFactor.GetValueOrDefault()); } - if(value.OutlineWidthMultiplyTexture.HasValue){ + if(value.OutlineWidthMultiplyTexture!=null){ f.Key("outlineWidthMultiplyTexture"); - f.Value(value.OutlineWidthMultiplyTexture.GetValueOrDefault()); + Serialize_OutlineWidthMultiplyTexture(f, value.OutlineWidthMultiplyTexture); } - if(value.OutlineScaledMaxDistanceFactor.HasValue){ - f.Key("outlineScaledMaxDistanceFactor"); - f.Value(value.OutlineScaledMaxDistanceFactor.GetValueOrDefault()); - } - - if(true){ - f.Key("outlineColorMode"); - f.Value(value.OutlineColorMode.ToString()); - } - - if(value.OutlineFactor!=null&&value.OutlineFactor.Count()>=0){ - f.Key("outlineFactor"); - Serialize_OutlineFactor(f, value.OutlineFactor); + if(value.OutlineColorFactor!=null&&value.OutlineColorFactor.Count()>=3){ + f.Key("outlineColorFactor"); + Serialize_OutlineColorFactor(f, value.OutlineColorFactor); } if(value.OutlineLightingMixFactor.HasValue){ @@ -143,9 +143,9 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.Value(value.OutlineLightingMixFactor.GetValueOrDefault()); } - if(value.UvAnimationMaskTexture.HasValue){ + if(value.UvAnimationMaskTexture!=null){ f.Key("uvAnimationMaskTexture"); - f.Value(value.UvAnimationMaskTexture.GetValueOrDefault()); + Serialize_UvAnimationMaskTexture(f, value.UvAnimationMaskTexture); } if(value.UvAnimationScrollXSpeedFactor.HasValue){ @@ -166,7 +166,7 @@ public static void Serialize(JsonFormatter f, VRMC_materials_mtoon value) f.EndMap(); } -public static void Serialize_ShadeFactor(JsonFormatter f, float[] value) +public static void Serialize_ShadeColorFactor(JsonFormatter f, float[] value) { f.BeginList(); @@ -178,7 +178,96 @@ public static void Serialize_ShadeFactor(JsonFormatter f, float[] value) f.EndList(); } -public static void Serialize_RimFactor(JsonFormatter f, float[] value) +public static void Serialize_ShadeMultiplyTexture(JsonFormatter f, TextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + f.EndMap(); +} + +public static void Serialize_ShadingShiftTexture(JsonFormatter f, ShadingShiftTextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + if(value.Scale.HasValue){ + f.Key("scale"); + f.Value(value.Scale.GetValueOrDefault()); + } + + f.EndMap(); +} + +public static void Serialize_MatcapTexture(JsonFormatter f, TextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + f.EndMap(); +} + +public static void Serialize_ParametricRimColorFactor(JsonFormatter f, float[] value) { f.BeginList(); @@ -190,7 +279,63 @@ public static void Serialize_RimFactor(JsonFormatter f, float[] value) f.EndList(); } -public static void Serialize_OutlineFactor(JsonFormatter f, float[] value) +public static void Serialize_RimMultiplyTexture(JsonFormatter f, TextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + f.EndMap(); +} + +public static void Serialize_OutlineWidthMultiplyTexture(JsonFormatter f, TextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + f.EndMap(); +} + +public static void Serialize_OutlineColorFactor(JsonFormatter f, float[] value) { f.BeginList(); @@ -202,5 +347,33 @@ public static void Serialize_OutlineFactor(JsonFormatter f, float[] value) f.EndList(); } +public static void Serialize_UvAnimationMaskTexture(JsonFormatter f, TextureInfo value) +{ + f.BeginMap(); + + + if(value.Extensions!=null){ + f.Key("extensions"); + value.Extensions.Serialize(f); + } + + if(value.Extras!=null){ + f.Key("extras"); + value.Extras.Serialize(f); + } + + if(value.Index.HasValue){ + f.Key("index"); + f.Value(value.Index.GetValueOrDefault()); + } + + if(value.TexCoord.HasValue){ + f.Key("texCoord"); + f.Value(value.TexCoord.GetValueOrDefault()); + } + + f.EndMap(); +} + } // class } // namespace diff --git a/Assets/VRM10/Runtime/Format/Vrm/Format.g.cs b/Assets/VRM10/Runtime/Format/Vrm/Format.g.cs index 039d50570..8650c4b84 100644 --- a/Assets/VRM10/Runtime/Format/Vrm/Format.g.cs +++ b/Assets/VRM10/Runtime/Format/Vrm/Format.g.cs @@ -480,6 +480,7 @@ namespace UniGLTF.Extensions.VRMC_vrm public const string ExtensionName = "VRMC_vrm"; public static readonly Utf8String ExtensionNameUtf8 = Utf8String.From(ExtensionName); + // Specification version of the VRM public string SpecVersion; public Meta Meta; diff --git a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs index 0b63716f2..8afd43fa6 100644 --- a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs +++ b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs @@ -453,8 +453,9 @@ namespace UniVRM10 for (int i = 0; i < Parser.GLTF.nodes.Count; ++i) { var gltfNode = Parser.GLTF.nodes[i]; - if (UniGLTF.Extensions.VRMC_constraints.GltfDeserializer.TryGet(gltfNode.extensions, out UniGLTF.Extensions.VRMC_constraints.VRMC_constraints constraint)) + if (UniGLTF.Extensions.VRMC_node_constraint.GltfDeserializer.TryGet(gltfNode.extensions, out UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint ext)) { + var constraint = ext.Constraint; var node = Nodes[i]; if (constraint.Position != null) { diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index 87b572858..6053448b2 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -25,7 +25,7 @@ namespace UniVRM10 Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_materials_mtoon.VRMC_materials_mtoon.ExtensionName); Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_springBone.VRMC_springBone.ExtensionName); Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_node_collider.VRMC_node_collider.ExtensionName); - Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_constraints.VRMC_constraints.ExtensionName); + Storage.Gltf.extensionsUsed.Add(UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint.ExtensionName); Storage.Gltf.buffers.Add(new glTFBuffer { diff --git a/Assets/VRM10/Runtime/IO/Vrm10MToonMaterialImporter.cs b/Assets/VRM10/Runtime/IO/Vrm10MToonMaterialImporter.cs index 00695284c..d905240bd 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10MToonMaterialImporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10MToonMaterialImporter.cs @@ -76,7 +76,7 @@ namespace UniVRM10 { // var color = mtoon.Color; material.SetColor(MToon.Utils.PropColor, m.pbrMetallicRoughness.baseColorFactor.ToColor4()); - material.SetColor(MToon.Utils.PropShadeColor, mtoon.ShadeFactor.ToColor3()); + material.SetColor(MToon.Utils.PropShadeColor, mtoon.ShadeColorFactor.ToColor3()); material.SetFloat(MToon.Utils.PropCutoff, m.alphaCutoff); } { @@ -87,7 +87,6 @@ namespace UniVRM10 // material.SetFloat(PropShadingGradeRate, mtoon.mix prop.LitAndShadeMixingMultiplierValue); } { - material.SetFloat(MToon.Utils.PropLightColorAttenuation, mtoon.LightColorAttenuationFactor.Value); material.SetFloat(MToon.Utils.PropIndirectLightIntensity, mtoon.GiIntensityFactor.Value); } } @@ -95,15 +94,14 @@ namespace UniVRM10 material.SetColor(MToon.Utils.PropEmissionColor, m.emissiveFactor.ToColor3()); } { - material.SetColor(MToon.Utils.PropRimColor, mtoon.RimFactor.ToColor3()); + material.SetColor(MToon.Utils.PropRimColor, mtoon.ParametricRimColorFactor.ToColor3()); material.SetFloat(MToon.Utils.PropRimLightingMix, mtoon.RimLightingMixFactor.Value); - material.SetFloat(MToon.Utils.PropRimFresnelPower, mtoon.RimFresnelPowerFactor.Value); - material.SetFloat(MToon.Utils.PropRimLift, mtoon.RimLiftFactor.Value); + material.SetFloat(MToon.Utils.PropRimFresnelPower, mtoon.ParametricRimFresnelPowerFactor.Value); + material.SetFloat(MToon.Utils.PropRimLift, mtoon.ParametricRimLiftFactor.Value); } { material.SetFloat(MToon.Utils.PropOutlineWidth, mtoon.OutlineWidthFactor.Value); - material.SetFloat(MToon.Utils.PropOutlineScaledMaxDistance, mtoon.OutlineScaledMaxDistanceFactor.Value); - material.SetColor(MToon.Utils.PropOutlineColor, mtoon.OutlineFactor.ToColor3()); + material.SetColor(MToon.Utils.PropOutlineColor, mtoon.OutlineColorFactor.ToColor3()); material.SetFloat(MToon.Utils.PropOutlineLightingMix, mtoon.OutlineLightingMixFactor.Value); // private // MToon.Utils.SetOutlineMode(material, outline.OutlineWidthMode, outline.OutlineColorMode); @@ -149,29 +147,29 @@ namespace UniVRM10 } // TODO: - if (mtoon.ShadeMultiplyTexture.HasValue) + if (mtoon.ShadeMultiplyTexture != null) { - var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.ShadeMultiplyTexture.Value, Vector2.zero, Vector2.one); + var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.ShadeMultiplyTexture.Index.Value, Vector2.zero, Vector2.one); param.TextureSlots.Add("_ShadeTexture", textureParam); } - if (mtoon.OutlineWidthMultiplyTexture.HasValue) + if (mtoon.OutlineWidthMultiplyTexture != null) { - var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.OutlineWidthMultiplyTexture.Value, Vector2.zero, Vector2.one); + var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.OutlineWidthMultiplyTexture.Index.Value, Vector2.zero, Vector2.one); param.TextureSlots.Add("_OutlineWidthTexture", textureParam); } - if (mtoon.AdditiveTexture.HasValue) + if (mtoon.MatcapTexture != null) { - var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.AdditiveTexture.Value, Vector2.zero, Vector2.one); + var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.MatcapTexture.Index.Value, Vector2.zero, Vector2.one); param.TextureSlots.Add("_SphereAdd", textureParam); } - if (mtoon.RimMultiplyTexture.HasValue) + if (mtoon.RimMultiplyTexture != null) { - var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.RimMultiplyTexture.Value, Vector2.zero, Vector2.one); + var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.RimMultiplyTexture.Index.Value, Vector2.zero, Vector2.one); param.TextureSlots.Add("_RimTexture", textureParam); ; } - if (mtoon.UvAnimationMaskTexture.HasValue) + if (mtoon.UvAnimationMaskTexture != null) { - var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.UvAnimationMaskTexture.Value, Vector2.zero, Vector2.one); + var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.UvAnimationMaskTexture.Index.Value, Vector2.zero, Vector2.one); param.TextureSlots.Add("_UvAnimMaskTexture", textureParam); } diff --git a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs index d74da3003..77d7a7bed 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs @@ -127,7 +127,7 @@ namespace UniVRM10 RenderQueueOffsetNumber = 0, - ShadeFactor = new float[] { 0, 0, 0 }, + ShadeColorFactor = new float[] { 0, 0, 0 }, // ShadeMultiplyTexture; @@ -136,23 +136,21 @@ namespace UniVRM10 ShadingToonyFactor = 0, - LightColorAttenuationFactor = 0, - GiIntensityFactor = 0, // MatCap // AdditiveTexture; // Rim - RimFactor = new float[] { 0, 0, 0 }, + ParametricRimColorFactor = new float[] { 0, 0, 0 }, // public int? RimMultiplyTexture; RimLightingMixFactor = 0, - RimFresnelPowerFactor = 0, + ParametricRimFresnelPowerFactor = 0, - RimLiftFactor = 0, + ParametricRimLiftFactor = 0, // Outline OutlineWidthMode = UniGLTF.Extensions.VRMC_materials_mtoon.OutlineWidthMode.none, @@ -161,11 +159,7 @@ namespace UniVRM10 // public int? OutlineWidthMultiplyTexture; - OutlineScaledMaxDistanceFactor = 0, - - OutlineColorMode = UniGLTF.Extensions.VRMC_materials_mtoon.OutlineColorMode.fixedColor, - - OutlineFactor = new float[] { 0, 0, 0 }, + OutlineColorFactor = new float[] { 0, 0, 0 }, OutlineLightingMixFactor = 0, diff --git a/Assets/VRM10/Runtime/Migration/MigrationMToon.cs b/Assets/VRM10/Runtime/Migration/MigrationMToon.cs index 1c55b1580..f74402795 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationMToon.cs +++ b/Assets/VRM10/Runtime/Migration/MigrationMToon.cs @@ -332,23 +332,21 @@ namespace UniVRM10 (value[2], value[3]) ); } - dst.ShadeFactor = mtoon.Definition.Color.ShadeColor.ToFloat3(); + dst.ShadeColorFactor = mtoon.Definition.Color.ShadeColor.ToFloat3(); if (mtoon.TextureIndexMap.ShadeTexture.HasValue) { - dst.ShadeMultiplyTexture = mtoon.TextureIndexMap.ShadeTexture.Value; + dst.ShadeMultiplyTexture = new TextureInfo { Index = mtoon.TextureIndexMap.ShadeTexture.Value }; } gltfMaterial.alphaCutoff = mtoon.Definition.Color.CutoutThresholdValue; // Outline - dst.OutlineColorMode = (UniGLTF.Extensions.VRMC_materials_mtoon.OutlineColorMode)mtoon.Definition.Outline.OutlineColorMode; - dst.OutlineFactor = ToFloat3(mtoon.Definition.Outline.OutlineColor); + dst.OutlineColorFactor = ToFloat3(mtoon.Definition.Outline.OutlineColor); dst.OutlineLightingMixFactor = mtoon.Definition.Outline.OutlineLightingMixValue; - dst.OutlineScaledMaxDistanceFactor = mtoon.Definition.Outline.OutlineScaledMaxDistanceValue; dst.OutlineWidthMode = (UniGLTF.Extensions.VRMC_materials_mtoon.OutlineWidthMode)mtoon.Definition.Outline.OutlineWidthMode; dst.OutlineWidthFactor = mtoon.Definition.Outline.OutlineWidthValue; if (mtoon.TextureIndexMap.OutlineWidthTexture.HasValue) { - dst.OutlineWidthMultiplyTexture = mtoon.TextureIndexMap.OutlineWidthTexture.Value; + dst.OutlineWidthMultiplyTexture = new TextureInfo { Index = mtoon.TextureIndexMap.OutlineWidthTexture.Value }; } // Emission @@ -369,7 +367,6 @@ namespace UniVRM10 // Light dst.GiIntensityFactor = mtoon.Definition.Lighting.LightingInfluence.GiIntensityValue; - dst.LightColorAttenuationFactor = mtoon.Definition.Lighting.LightingInfluence.LightColorAttenuationValue; dst.ShadingShiftFactor = mtoon.Definition.Lighting.LitAndShadeMixing.ShadingShiftValue; dst.ShadingToonyFactor = mtoon.Definition.Lighting.LitAndShadeMixing.ShadingToonyValue; if (mtoon.TextureIndexMap.BumpMap.HasValue) @@ -390,7 +387,7 @@ namespace UniVRM10 // matcap if (mtoon.TextureIndexMap.SphereAdd.HasValue) { - dst.AdditiveTexture = mtoon.TextureIndexMap.SphereAdd.Value; + dst.MatcapTexture = new TextureInfo { Index = mtoon.TextureIndexMap.SphereAdd.Value }; } // rendering @@ -416,19 +413,19 @@ namespace UniVRM10 dst.RenderQueueOffsetNumber = mtoon.Definition.Rendering.RenderQueueOffsetNumber; // rim - dst.RimFactor = mtoon.Definition.Rim.RimColor.ToFloat3(); + dst.ParametricRimColorFactor = mtoon.Definition.Rim.RimColor.ToFloat3(); if (mtoon.TextureIndexMap.RimTexture.HasValue) { - dst.RimMultiplyTexture = mtoon.TextureIndexMap.RimTexture.Value; + dst.RimMultiplyTexture = new TextureInfo { Index = mtoon.TextureIndexMap.RimTexture.Value }; } - dst.RimLiftFactor = mtoon.Definition.Rim.RimLiftValue; - dst.RimFresnelPowerFactor = mtoon.Definition.Rim.RimFresnelPowerValue; + dst.ParametricRimLiftFactor = mtoon.Definition.Rim.RimLiftValue; + dst.ParametricRimFresnelPowerFactor = mtoon.Definition.Rim.RimFresnelPowerValue; dst.RimLightingMixFactor = mtoon.Definition.Rim.RimLightingMixValue; // texture option if (mtoon.TextureIndexMap.UvAnimMaskTexture.HasValue) { - dst.UvAnimationMaskTexture = mtoon.TextureIndexMap.UvAnimMaskTexture.Value; + dst.UvAnimationMaskTexture = new TextureInfo { Index = mtoon.TextureIndexMap.UvAnimMaskTexture.Value }; } dst.UvAnimationRotationSpeedFactor = mtoon.Definition.TextureOption.UvAnimationRotationSpeedValue; dst.UvAnimationScrollXSpeedFactor = mtoon.Definition.TextureOption.UvAnimationScrollXSpeedValue; diff --git a/vrm-specification b/vrm-specification index e14461555..a69067518 160000 --- a/vrm-specification +++ b/vrm-specification @@ -1 +1 @@ -Subproject commit e14461555138092921b8b25dddeda12acf2bf069 +Subproject commit a690675180a91ec2bb2b5bceaf6cb1777d43421f From c508465ccd3cf65ff88504b7c51e0199836a9836 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 17:17:35 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=E9=96=93=E9=81=95=E3=81=88=E3=81=A6=20Unit?= =?UTF-8?q?y-2019=20=E3=81=A7=E6=9B=B4=E6=96=B0=E3=81=97=E3=81=9F=20Packag?= =?UTF-8?q?es/manifest.json=20=E3=82=92=E5=85=83=E3=81=AB=E6=88=BB?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Packages/manifest.json | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Packages/manifest.json b/Packages/manifest.json index e1b6036fa..ddf67b40c 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,21 +1,12 @@ { "dependencies": { - "com.unity.2d.sprite": "1.0.0", - "com.unity.2d.tilemap": "1.0.0", - "com.unity.ads": "3.6.1", - "com.unity.analytics": "3.3.5", - "com.unity.collab-proxy": "1.2.16", - "com.unity.ide.rider": "1.1.4", - "com.unity.ide.vscode": "1.2.3", - "com.unity.multiplayer-hlapi": "1.0.8", - "com.unity.purchasing": "3.0.1", - "com.unity.test-framework": "1.1.24", - "com.unity.textmeshpro": "2.1.4", - "com.unity.timeline": "1.2.18", - "com.unity.ugui": "1.0.0", - "com.unity.xr.legacyinputhelpers": "2.1.7", + "com.unity.ads": "2.0.8", + "com.unity.analytics": "3.2.3", + "com.unity.collab-proxy": "1.2.15", + "com.unity.package-manager-ui": "2.0.13", + "com.unity.purchasing": "2.0.3", + "com.unity.textmeshpro": "1.4.1", "com.unity.modules.ai": "1.0.0", - "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", From caf61c27857339120bd833cdf9a60a37da7d7728 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 17:18:26 +0900 Subject: [PATCH 5/5] remove debug code --- Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs index fb9ec2c1b..933b393b5 100644 --- a/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs +++ b/Assets/UniGLTF/Editor/JsonSchema/JsonSchemaParser.cs @@ -188,10 +188,6 @@ namespace UniGLTF.JsonSchema foreach (var prop in kv.Value.ObjectItems()) { var key = prop.Key.GetString(); - if (key == "scale") - { - var a = 0; - } var propJsonPath = $"{jsonPath}.{key}"; var propSchema = Parse(prop.Value, propJsonPath); if (propSchema is null)