mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-02 22:14:30 -05:00
migration uv offset scale when legacy unlit material.
This commit is contained in:
parent
2d1921c1f3
commit
f73a8233b2
|
|
@ -38,7 +38,7 @@ namespace UniVRM10
|
|||
{
|
||||
throw new Exception("not float4");
|
||||
}
|
||||
return factor.ArrayItems().Select(x => ListTreeNodeExtensions.GetSingle(x)).ToArray();
|
||||
return factor.ArrayItems().Select(x => x.GetSingle()).ToArray();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -51,10 +51,13 @@ namespace UniVRM10
|
|||
{
|
||||
try
|
||||
{
|
||||
return new glTFMaterialBaseColorTextureInfo
|
||||
var textureInfo = new glTFMaterialBaseColorTextureInfo
|
||||
{
|
||||
index = vrm0XMaterial[TexturePropertiesKey][MainTexKey].GetInt32(),
|
||||
};
|
||||
var os = GetBaseColorTextureOffsetScale(vrm0XMaterial);
|
||||
glTF_KHR_texture_transform.Serialize(textureInfo, (os.offsetX, os.offsetY), (os.scaleX, os.scaleY));
|
||||
return textureInfo;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -63,6 +66,30 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
private static (float offsetX, float offsetY, float scaleX, float scaleY) GetBaseColorTextureOffsetScale(JsonNode vrm0XMaterial)
|
||||
{
|
||||
try
|
||||
{
|
||||
var unityOffsetScale = vrm0XMaterial[VectorPropertiesKey][MainTexKey];
|
||||
if (!unityOffsetScale.IsArray() || unityOffsetScale.GetArrayCount() != 4)
|
||||
{
|
||||
throw new Exception("not float4");
|
||||
}
|
||||
|
||||
var unityOffsetX = unityOffsetScale[0].GetSingle();
|
||||
var unityOffsetY = unityOffsetScale[1].GetSingle();
|
||||
var unityScaleX = unityOffsetScale[2].GetSingle();
|
||||
var unityScaleY = unityOffsetScale[3].GetSingle();
|
||||
|
||||
return (unityOffsetX, 1.0f - unityOffsetY - unityScaleY, unityScaleX, unityScaleY);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Debug.LogWarning($"Migration Warning: BaseColorTextureScaleOffset fallback default.");
|
||||
return (0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetCutoff(JsonNode vrm0XMaterial)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user