mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 13:29:41 -05:00
mv function of importing material name
This commit is contained in:
@@ -22,7 +22,7 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
return new MaterialDescriptor(
|
||||
GetMaterialName(i, null),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
@@ -30,16 +30,6 @@ namespace UniGLTF
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
|
||||
}
|
||||
|
||||
public static string GetMaterialName(int index, glTFMaterial src)
|
||||
{
|
||||
if (src != null && !string.IsNullOrEmpty(src.name))
|
||||
{
|
||||
return src.name;
|
||||
}
|
||||
return $"material_{index:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ namespace UniGLTF
|
||||
});
|
||||
|
||||
matDesc = new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, src),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, src),
|
||||
ShaderName,
|
||||
null,
|
||||
textureSlots,
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
matDesc = new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, src),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, src),
|
||||
UniUnlitUtil.ShaderName,
|
||||
null,
|
||||
textureSlots,
|
||||
|
||||
@@ -5,6 +5,15 @@ namespace UniGLTF
|
||||
{
|
||||
public static class GltfMaterialImportUtils
|
||||
{
|
||||
public static string ImportMaterialName(int index, glTFMaterial src)
|
||||
{
|
||||
if (src != null && !string.IsNullOrEmpty(src.name))
|
||||
{
|
||||
return src.name;
|
||||
}
|
||||
return $"material_{index:00}";
|
||||
}
|
||||
|
||||
public static Color? ImportLinearEmissiveFactorFromMaterial(GltfData data, glTFMaterial src)
|
||||
{
|
||||
if (src.emissiveFactor == null || src.emissiveFactor.Length != 3) return null;
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace UniGLTF
|
||||
});
|
||||
|
||||
matDesc = new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, src),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, src),
|
||||
ShaderName,
|
||||
null,
|
||||
textureSlots,
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace UniGLTF
|
||||
}
|
||||
|
||||
return new MaterialDescriptor(
|
||||
GetMaterialName(i, null),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
@@ -31,17 +31,6 @@ namespace UniGLTF
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Collection<Action<Material>>());
|
||||
|
||||
}
|
||||
|
||||
public static string GetMaterialName(int index, glTFMaterial src)
|
||||
{
|
||||
if (src != null && !string.IsNullOrEmpty(src.name))
|
||||
{
|
||||
return src.name;
|
||||
}
|
||||
|
||||
return $"material_{index:00}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ namespace VRM
|
||||
// fallback
|
||||
Debug.LogWarning($"fallback");
|
||||
return new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, null),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace VRM
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
}
|
||||
return new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, null),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace UniVRM10
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
}
|
||||
return new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, null), BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null), BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace UniVRM10
|
||||
// fallback
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
return new MaterialDescriptor(
|
||||
BuiltInGltfMaterialDescriptorGenerator.GetMaterialName(i, null),
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.ShaderName,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
|
||||
Reference in New Issue
Block a user