mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-23 19:36:18 -05:00
Merge pull request #1011 from ousttrue/fix/VrmLoadTest.VrmTestModelsTests
古いシェーダー名をフォールバック
This commit is contained in:
commit
920fffb3bc
|
|
@ -18,6 +18,16 @@ namespace VRMShaders
|
|||
m_externalMap = externalMaterialMap;
|
||||
}
|
||||
|
||||
static Dictionary<string, string> s_fallbackShaders = new Dictionary<string, string>
|
||||
{
|
||||
{"VRM/UnlitTexture", "Unlit/Texture"},
|
||||
{"VRM/UnlitTransparent", "Unlit/Transparent"},
|
||||
{"VRM/UnlitCutout", "Unlit/Transparent Cutout"},
|
||||
// 互換性は無いがとりあえず、
|
||||
{"VRM/UnlitTransparentZWrite", "VRM/MToon"},
|
||||
{"UniGLTF/StandardVColor", UniGLTF.UniUnlit.Utils.ShaderName},
|
||||
};
|
||||
|
||||
public struct MaterialLoadInfo
|
||||
{
|
||||
public readonly Material Asset;
|
||||
|
|
@ -109,29 +119,47 @@ namespace VRMShaders
|
|||
getTexture = (_) => Task.FromResult<Texture>(null);
|
||||
}
|
||||
|
||||
material = new Material(Shader.Find(matDesc.ShaderName));
|
||||
var shaderName = matDesc.ShaderName;
|
||||
if (String.IsNullOrEmpty(shaderName))
|
||||
{
|
||||
throw new Exception("no shader name");
|
||||
}
|
||||
if (s_fallbackShaders.TryGetValue(shaderName, out string fallback))
|
||||
{
|
||||
Debug.LogWarning($"fallback: {shaderName} => {fallback}");
|
||||
shaderName = fallback;
|
||||
}
|
||||
|
||||
var shader = Shader.Find(shaderName);
|
||||
if (shader == null)
|
||||
{
|
||||
throw new Exception($"shader: {shaderName} not found");
|
||||
}
|
||||
|
||||
material = new Material(shader);
|
||||
material.name = matDesc.SubAssetKey.Name;
|
||||
|
||||
foreach(var kv in matDesc.TextureSlots)
|
||||
foreach (var kv in matDesc.TextureSlots)
|
||||
{
|
||||
var texture = await getTexture(kv.Value);
|
||||
if(texture!=null){
|
||||
if (texture != null)
|
||||
{
|
||||
material.SetTexture(kv.Key, texture);
|
||||
SetTextureOffsetAndScale(material, kv.Key, kv.Value.Offset, kv.Value.Scale);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(var kv in matDesc.Colors)
|
||||
foreach (var kv in matDesc.Colors)
|
||||
{
|
||||
material.SetColor(kv.Key, kv.Value);
|
||||
}
|
||||
|
||||
foreach(var kv in matDesc.Vectors)
|
||||
foreach (var kv in matDesc.Vectors)
|
||||
{
|
||||
material.SetVector(kv.Key, kv.Value);
|
||||
}
|
||||
|
||||
foreach(var kv in matDesc.FloatValues)
|
||||
foreach (var kv in matDesc.FloatValues)
|
||||
{
|
||||
material.SetFloat(kv.Key, kv.Value);
|
||||
}
|
||||
|
|
@ -141,7 +169,7 @@ namespace VRMShaders
|
|||
material.renderQueue = matDesc.RenderQueue.Value;
|
||||
}
|
||||
|
||||
foreach(var action in matDesc.Actions)
|
||||
foreach (var action in matDesc.Actions)
|
||||
{
|
||||
action(material);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
"name": "VRMShaders.GLTF.IO.Runtime",
|
||||
"references": [],
|
||||
"references": [
|
||||
"VRMShaders.GLTF.UniUnlit.Runtime"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
"defineConstraints": []
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user