diff --git a/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs b/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs index f1d8218a0d..857eff7f9d 100644 --- a/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs +++ b/Assets/VRM10/Runtime/Components/Expression/MaterialValueBindingMerger.cs @@ -79,6 +79,7 @@ void InitializeMaterialMap(Dictionary clipMap, T item = new PreviewMaterialItem(material); m_materialMap.Add(binding.MaterialName, item); } + // color default value var propName = GetProperty(binding.BindType); if (!item.PropMap.ContainsKey(binding.BindType)) { @@ -148,8 +149,6 @@ public int GetHashCode(MaterialColorBinding obj) /// Dictionary m_materialUVMap = new Dictionary(); - static readonly Vector4 DefaultUVScaleOffset = new Vector4(1, 1, 0, 0); - public void AccumulateValue(VRM10Expression clip, float value) { // material color @@ -169,14 +168,20 @@ public void AccumulateValue(VRM10Expression clip, float value) // maetrial uv foreach (var binding in clip.MaterialUVBindings) { - Vector4 acc; - if (!m_materialUVMap.TryGetValue(binding.MaterialName, out acc)) + if (m_materialMap.TryGetValue(binding.MaterialName, out PreviewMaterialItem item)) { - acc = DefaultUVScaleOffset; - } + var delta = binding.ScalingOffset - item.DefaultUVScaleOffset; - var delta = binding.ScalingOffset - DefaultUVScaleOffset; - m_materialUVMap[binding.MaterialName] = acc + delta * value; + Vector4 acc; + if (m_materialUVMap.TryGetValue(binding.MaterialName, out acc)) + { + m_materialUVMap[binding.MaterialName] = acc + delta * value; + } + else + { + m_materialUVMap[binding.MaterialName] = item.DefaultUVScaleOffset + delta * value; + } + } } } diff --git a/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs b/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs index 20af729b4a..1cecedf22d 100644 --- a/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs +++ b/Assets/VRM10/Runtime/Components/Expression/PreviewMaterialItem.cs @@ -56,10 +56,15 @@ public sealed class PreviewMaterialItem public PreviewMaterialItem(Material material) { Material = material; + + // uv default value + DefaultUVScaleOffset = material.GetVector(UV_PROPERTY); } public Dictionary PropMap = new Dictionary(); + public Vector4 DefaultUVScaleOffset = new Vector4(1, 1, 0, 0); + public string[] PropNames { get; diff --git a/Assets/VRM10/Samples/VRM10Viewer/VRM10AutoExpression.cs b/Assets/VRM10/Samples/VRM10Viewer/VRM10AutoExpression.cs index de1a565eb5..ddedd1a2f1 100644 --- a/Assets/VRM10/Samples/VRM10Viewer/VRM10AutoExpression.cs +++ b/Assets/VRM10/Samples/VRM10Viewer/VRM10AutoExpression.cs @@ -53,7 +53,7 @@ IEnumerator Routine() { yield return new WaitForSeconds(1.0f); - var velocity = 0.1f; + var velocity = 0.01f; yield return RoutineNest(ExpressionPreset.happy, velocity, m_wait); yield return RoutineNest(ExpressionPreset.angry, velocity, m_wait);