Implement Material.textureOffset & Material.textureScaling read/write

This commit is contained in:
ousttrue 2018-04-20 19:21:52 +09:00
parent 670c95d30a
commit 2f8fbb4f59
2 changed files with 18 additions and 3 deletions

View File

@ -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)
{

View File

@ -19,7 +19,6 @@ namespace VRM
public Dictionary<string, float> floatProperties = new Dictionary<string, float>();
public Dictionary<string, float[]> vectorProperties = new Dictionary<string, float[]>();
public Dictionary<string, int> textureProperties = new Dictionary<string, int>();
public Dictionary<string, bool> keywordMap = new Dictionary<string, bool>();
public Dictionary<string, string> tagMap = new Dictionary<string, string>();
@ -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;