mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 13:29:41 -05:00
Take off responsibility of determining shaders from ImporterContext.
This commit is contained in:
@@ -289,8 +289,8 @@ namespace UniGLTF
|
||||
{
|
||||
// no material. work around.
|
||||
// TODO: https://www.khronos.org/registry/glTF/specs/2.0/glTF-2.0.html#default-material
|
||||
var param = MaterialDescriptor.Default;
|
||||
var material = await MaterialFactory.LoadAsync(param, TextureFactory.GetTextureAsync, awaitCaller);
|
||||
var param = MaterialDescriptorGenerator.GetGltfDefault();
|
||||
await MaterialFactory.LoadAsync(param, TextureFactory.GetTextureAsync, awaitCaller);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -298,7 +298,7 @@ namespace UniGLTF
|
||||
{
|
||||
await awaitCaller.NextFrameIfTimedOut();
|
||||
var param = MaterialDescriptorGenerator.Get(Data, i);
|
||||
var material = await MaterialFactory.LoadAsync(param, TextureFactory.GetTextureAsync, awaitCaller);
|
||||
await MaterialFactory.LoadAsync(param, TextureFactory.GetTextureAsync, awaitCaller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,10 @@ namespace UniGLTF
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate the descriptor of the glTF default material.
|
||||
/// </summary>
|
||||
public static class BuiltInGltfDefaultMaterialImporter
|
||||
{
|
||||
public static MaterialDescriptor CreateParam()
|
||||
{
|
||||
// FIXME
|
||||
return new MaterialDescriptor(
|
||||
"__default__",
|
||||
"Standard",
|
||||
default,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new List<Action<Material>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa5431a3a9ee4f9caac398688c3a8973
|
||||
timeCreated: 1670224943
|
||||
@@ -8,6 +8,14 @@ namespace UniGLTF
|
||||
/// </summary>
|
||||
public interface IMaterialDescriptorGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate the MaterialDescriptor generated from the index i.
|
||||
/// </summary>
|
||||
MaterialDescriptor Get(GltfData data, int i);
|
||||
|
||||
/// <summary>
|
||||
/// Generate the MaterialDescriptor for the non-specified glTF material.
|
||||
/// </summary>
|
||||
MaterialDescriptor GetGltfDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VRMShaders;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// Generate the descriptor of the glTF default material.
|
||||
/// </summary>
|
||||
public static class UrpGltfDefaultMaterialImporter
|
||||
{
|
||||
public static MaterialDescriptor CreateParam()
|
||||
{
|
||||
// FIXME
|
||||
return new MaterialDescriptor(
|
||||
"__default__",
|
||||
UrpGltfPbrMaterialImporter.ShaderName,
|
||||
default,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new List<Action<Material>>()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 320b6d26ea014356b1c37e38425bf152
|
||||
timeCreated: 1670225169
|
||||
@@ -32,5 +32,10 @@ namespace UniGLTF
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Collection<Action<Material>>());
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return UrpGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,5 +53,10 @@ namespace VRM
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,10 @@ namespace VRM
|
||||
new Dictionary<string, Vector4>(),
|
||||
new Action<Material>[]{});
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return UrpGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,9 @@ namespace UniVRM10
|
||||
new Action<Material>[]{});
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return BuiltInGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,5 +27,9 @@ namespace UniVRM10
|
||||
new Action<Material>[]{});
|
||||
}
|
||||
|
||||
public MaterialDescriptor GetGltfDefault()
|
||||
{
|
||||
return UrpGltfDefaultMaterialImporter.CreateParam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,13 +17,6 @@ namespace VRMShaders
|
||||
|
||||
public SubAssetKey SubAssetKey => new SubAssetKey(SubAssetKey.MaterialType, Name);
|
||||
|
||||
public static readonly MaterialDescriptor Default = new MaterialDescriptor("__default__", "Standard", default,
|
||||
new Dictionary<string, TextureDescriptor>(),
|
||||
new Dictionary<string, float>(),
|
||||
new Dictionary<string, Color>(),
|
||||
new Dictionary<string, Vector4>(),
|
||||
new List<Action<Material>>());
|
||||
|
||||
public MaterialDescriptor(
|
||||
string name,
|
||||
string shaderName,
|
||||
|
||||
Reference in New Issue
Block a user