mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-22 18:45:06 -05:00
Merge pull request #875 from vrm-c/feature10/update_jsonschema
Feature10/update jsonschema
This commit is contained in:
@@ -187,7 +187,8 @@ namespace UniGLTF.JsonSchema
|
||||
// source.properties = new Dictionary<string, JsonSchemaSource>();
|
||||
foreach (var prop in kv.Value.ObjectItems())
|
||||
{
|
||||
var propJsonPath = $"{jsonPath}.{prop.Key.GetString()}";
|
||||
var key = prop.Key.GetString();
|
||||
var propJsonPath = $"{jsonPath}.{key}";
|
||||
var propSchema = Parse(prop.Value, propJsonPath);
|
||||
if (propSchema is null)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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, "../")));
|
||||
|
||||
@@ -31,16 +42,16 @@ 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
|
||||
"vrm-specification/specification/VRMC_constraints-1.0_draft/schema/VRMC_constraints.schema.json",
|
||||
// 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
|
||||
"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
|
||||
};
|
||||
@@ -50,11 +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, "");
|
||||
// extensionSchema.Dump();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using UniGLTF.Extensions.VRMC_constraints;
|
||||
using UniGLTF.Extensions.VRMC_node_constraint;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UniGLTF.Extensions.VRMC_constraints;
|
||||
using UniGLTF.Extensions.VRMC_node_constraint;
|
||||
|
||||
namespace UniVRM10
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UniGLTF.Extensions.VRMC_constraints;
|
||||
using UniGLTF.Extensions.VRMC_node_constraint;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniVRM10
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using UniGLTF.Extensions.VRMC_constraints;
|
||||
using UniGLTF.Extensions.VRMC_node_constraint;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
|
||||
@@ -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())
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -457,8 +457,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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
|
||||
@@ -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).Param;
|
||||
var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.ShadeMultiplyTexture.Index.Value, Vector2.zero, Vector2.one).Param;
|
||||
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).Param;
|
||||
var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.OutlineWidthMultiplyTexture.Index.Value, Vector2.zero, Vector2.one).Param;
|
||||
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).Param;
|
||||
var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.MatcapTexture.Index.Value, Vector2.zero, Vector2.one).Param;
|
||||
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).Param;
|
||||
var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.RimMultiplyTexture.Index.Value, Vector2.zero, Vector2.one).Param;
|
||||
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).Param;
|
||||
var textureParam = GltfTextureImporter.CreateSRGB(parser, mtoon.UvAnimationMaskTexture.Index.Value, Vector2.zero, Vector2.one).Param;
|
||||
param.TextureSlots.Add("_UvAnimMaskTexture", textureParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
m_EditorVersion: 2018.4.27f1
|
||||
m_EditorVersion: 2019.4.24f1
|
||||
m_EditorVersionWithRevision: 2019.4.24f1 (5da6f0345e82)
|
||||
|
||||
Submodule vrm-specification updated: 068254bdf1...a690675180
Reference in New Issue
Block a user