mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 21:38:56 -05:00
Refactor BuiltIn MaterialDescriptorGenerator
This commit is contained in:
@@ -13,26 +13,15 @@ namespace UniGLTF
|
||||
{
|
||||
if (BuiltInGltfUnlitMaterialImporter.TryCreateParam(data, i, out var param)) return param;
|
||||
if (BuiltInGltfPbrMaterialImporter.TryCreateParam(data, i, out param)) return param;
|
||||
|
||||
// fallback
|
||||
if (Symbols.VRM_DEVELOP)
|
||||
{
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
}
|
||||
|
||||
return new MaterialDescriptor(
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.Shader,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
public MaterialDescriptor GetGltfDefault(string materialName = null) => BuiltInGltfDefaultMaterialImporter.CreateParam(materialName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace UniGLTF
|
||||
/// </summary>
|
||||
public static class BuiltInGltfDefaultMaterialImporter
|
||||
{
|
||||
public static MaterialDescriptor CreateParam()
|
||||
public static MaterialDescriptor CreateParam(string materialName = null)
|
||||
{
|
||||
// FIXME
|
||||
return new MaterialDescriptor(
|
||||
"__default__",
|
||||
string.IsNullOrEmpty(materialName) ? "__default__" : materialName,
|
||||
BuiltInGltfPbrMaterialImporter.Shader,
|
||||
default,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
|
||||
@@ -41,21 +41,13 @@ namespace VRM
|
||||
}
|
||||
|
||||
// fallback
|
||||
Debug.LogWarning($"fallback");
|
||||
return new MaterialDescriptor(
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.Shader,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
if (Symbols.VRM_DEVELOP)
|
||||
{
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
}
|
||||
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
public MaterialDescriptor GetGltfDefault(string materialName = null) => BuiltInGltfDefaultMaterialImporter.CreateParam(materialName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,20 +21,9 @@ namespace UniVRM10
|
||||
{
|
||||
Debug.LogWarning($"material: {i} out of range. fallback");
|
||||
}
|
||||
return new MaterialDescriptor(
|
||||
GltfMaterialImportUtils.ImportMaterialName(i, null),
|
||||
BuiltInGltfPbrMaterialImporter.Shader,
|
||||
null,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
return GetGltfDefault(GltfMaterialImportUtils.ImportMaterialName(i, null));
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
public MaterialDescriptor GetGltfDefault(string materialName = null) => BuiltInGltfDefaultMaterialImporter.CreateParam(materialName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user