mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 03:48:19 -05:00
Migrate materials when importing a VRM 0.x model.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
public bool IsRoughnessTextureValueSquared { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Built-in RP Standard shader's emission color is exported in gamma color space until UniGLTF v0.106.0.
|
||||
/// Before UniGLTF v0.107.0, Built-in RP Standard shader's emission color is exported in gamma color space.
|
||||
/// </summary>
|
||||
public bool IsEmissiveFactorGamma { get; set; } = false;
|
||||
}
|
||||
|
||||
@@ -40,6 +40,11 @@ namespace VRM
|
||||
return false;
|
||||
}
|
||||
|
||||
return IsNewer(newerVersion, olderVersion);
|
||||
}
|
||||
|
||||
public static bool IsNewer(Version newerVersion, Version olderVersion)
|
||||
{
|
||||
if (newerVersion.Major > olderVersion.Major)
|
||||
{
|
||||
return true;
|
||||
@@ -55,7 +60,7 @@ namespace VRM
|
||||
return true;
|
||||
}
|
||||
|
||||
if (String.Compare(newerVersion.Pre, olderVersion.Pre) > 0)
|
||||
if (string.CompareOrdinal(newerVersion.Pre, olderVersion.Pre) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,34 @@ namespace VRM
|
||||
throw new NotVrm0Exception();
|
||||
}
|
||||
VrmExtension = vrm;
|
||||
|
||||
UpdateMigrationFlags(Data.MigrationFlags, VrmExtension.exporterVersion);
|
||||
}
|
||||
|
||||
private static void UpdateMigrationFlags(MigrationFlags migrationFlags, string exportedVrmVersionString)
|
||||
{
|
||||
if (!VRMVersion.ParseVersion(exportedVrmVersionString, out var exportedVrmVersion)) return;
|
||||
|
||||
migrationFlags.IsRoughnessTextureValueSquared = VRMVersion.IsNewer(
|
||||
new VRMVersion.Version
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 69,
|
||||
Patch = 0,
|
||||
Pre = "",
|
||||
},
|
||||
exportedVrmVersion
|
||||
);
|
||||
migrationFlags.IsEmissiveFactorGamma = VRMVersion.IsNewer(
|
||||
new VRMVersion.Version
|
||||
{
|
||||
Major = 0,
|
||||
Minor = 107,
|
||||
Patch = 0,
|
||||
Pre = "",
|
||||
},
|
||||
exportedVrmVersion
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user