mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-14 06:19:47 -05:00
Merge pull request #2148 from Santarh/vrm0xBlendshapePreview
[VRM0.x] Fix wrong preview results in editor inspector when a vrm blendshape material target is "*_ST_S" or "*_ST_T"
This commit is contained in:
commit
ebb7ef67c0
|
|
@ -245,24 +245,29 @@ namespace VRM
|
|||
|
||||
foreach (var x in bake.MaterialValueBindings)
|
||||
{
|
||||
MaterialItem item;
|
||||
if (m_materialMap.TryGetValue(x.MaterialName, out item))
|
||||
if (m_materialMap.TryGetValue(x.MaterialName, out var item))
|
||||
{
|
||||
//Debug.Log("set material");
|
||||
PropItem prop;
|
||||
if (item.PropMap.TryGetValue(x.ValueName, out prop))
|
||||
if (item.PropMap.TryGetValue(x.ValueName, out _))
|
||||
{
|
||||
var valueName = x.ValueName;
|
||||
if (valueName.EndsWith("_ST_S")
|
||||
|| valueName.EndsWith("_ST_T"))
|
||||
var offsetValue = x.TargetValue - x.BaseValue;
|
||||
var targetPropName = x.ValueName;
|
||||
if (x.ValueName.EndsWith("_ST_S"))
|
||||
{
|
||||
valueName = valueName.Substring(0, valueName.Length - 2);
|
||||
offsetValue.y = 0;
|
||||
offsetValue.w = 0;
|
||||
targetPropName = targetPropName.Substring(0, targetPropName.Length - 2);
|
||||
}
|
||||
else if (x.ValueName.EndsWith("_ST_T"))
|
||||
{
|
||||
offsetValue.x = 0;
|
||||
offsetValue.z = 0;
|
||||
targetPropName = targetPropName.Substring(0, targetPropName.Length - 2);
|
||||
}
|
||||
|
||||
var value = item.Material.GetVector(valueName);
|
||||
//Debug.LogFormat("{0} => {1}", valueName, x.TargetValue);
|
||||
value += ((x.TargetValue - x.BaseValue) * bake.Weight);
|
||||
item.Material.SetColor(valueName, value);
|
||||
var value = item.Material.GetVector(targetPropName);
|
||||
value += offsetValue * bake.Weight;
|
||||
item.Material.SetColor(targetPropName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user