From 2f8fbb4f599e83100cabcdf6d02749e7e236dbb5 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 20 Apr 2018 19:21:52 +0900 Subject: [PATCH] Implement Material.textureOffset & Material.textureScaling read/write --- Scripts/Format/VRMImporter.cs | 14 ++++++++++++-- Scripts/Format/glTF_VRM_Material.cs | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Scripts/Format/VRMImporter.cs b/Scripts/Format/VRMImporter.cs index 9808ab9d9..248d6bce4 100644 --- a/Scripts/Format/VRMImporter.cs +++ b/Scripts/Format/VRMImporter.cs @@ -127,8 +127,18 @@ namespace VRM } foreach (var kv in item.vectorProperties) { - var v = new Vector4(kv.Value[0], kv.Value[1], kv.Value[2], kv.Value[3]); - material.SetVector(kv.Key, v); + if (item.textureProperties.ContainsKey(kv.Key)) + { + // texture offset & scale + material.SetTextureOffset(kv.Key, new Vector2(kv.Value[0], kv.Value[1])); + material.SetTextureScale(kv.Key, new Vector2(kv.Value[2], kv.Value[3])); + } + else + { + // vector4 + var v = new Vector4(kv.Value[0], kv.Value[1], kv.Value[2], kv.Value[3]); + material.SetVector(kv.Key, v); + } } foreach (var kv in item.textureProperties) { diff --git a/Scripts/Format/glTF_VRM_Material.cs b/Scripts/Format/glTF_VRM_Material.cs index 9825d54a1..8ed73b21f 100644 --- a/Scripts/Format/glTF_VRM_Material.cs +++ b/Scripts/Format/glTF_VRM_Material.cs @@ -19,7 +19,6 @@ namespace VRM public Dictionary floatProperties = new Dictionary(); public Dictionary vectorProperties = new Dictionary(); public Dictionary textureProperties = new Dictionary(); - public Dictionary keywordMap = new Dictionary(); public Dictionary tagMap = new Dictionary(); @@ -145,6 +144,12 @@ namespace VRM material.textureProperties.Add(name, value); } } + + // offset & scaling + var offset = m.GetTextureOffset(name); + var scaling = m.GetTextureScale(name); + material.vectorProperties.Add(name, + new float[] { offset.x, offset.y, scaling.x, scaling.y }); } break;