Disable vertex color when use legacy unlit.

This commit is contained in:
Masataka SUMI 2021-10-28 22:06:50 +09:00
parent 6c87e1d8d1
commit 2d1921c1f3

View File

@ -12,6 +12,8 @@ namespace UniVRM10
public static void Migrate(glTF gltf, JsonNode vrm0)
{
var needsDisablingVertexColor = false;
for (var materialIdx = 0; materialIdx < gltf.materials.Count; ++materialIdx)
{
try
@ -31,6 +33,8 @@ namespace UniVRM10
if (unlitMaterial != null)
{
gltf.materials[materialIdx] = unlitMaterial;
// NOTE: 古い Unlit である場合、頂点カラー情報を破棄する.
needsDisablingVertexColor = true;
continue;
}
}
@ -49,6 +53,24 @@ namespace UniVRM10
{
Debug.LogException(ex);
}
finally
{
if (needsDisablingVertexColor)
{
DisableVertexColor(gltf);
}
}
}
private static void DisableVertexColor(glTF gltf)
{
foreach (var mesh in gltf.meshes)
{
foreach (var primitive in mesh.primitives)
{
primitive.attributes.COLOR_0 = -1;
}
}
}
}
}