PreShaderPropExporter は既に VRM/MToon 専用

This commit is contained in:
ousttrue
2022-06-02 15:12:22 +09:00
parent 61422eb94c
commit ac19e0d135
3 changed files with 12 additions and 21 deletions

View File

@@ -30,7 +30,7 @@ namespace VRM
//
// extensions.VRM.materialProperties に記録する
//
var prop = UniGLTF.ShaderPropExporter.PreShaderPropExporter.GetPropsForSupportedShader(m.shader.name);
var prop = UniGLTF.ShaderPropExporter.PreShaderPropExporter.GetPropsForMToon();
foreach (var kv in prop.Properties)
{
if (kv.ShaderPropertyType == UniGLTF.ShaderPropExporter.ShaderPropertyType.TexEnv)

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
using UniGLTF.ShaderPropExporter;
@@ -135,16 +134,16 @@ namespace VRM
renderQueue = m.renderQueue,
};
if (!PreShaderPropExporter.VRMExtensionShaders.Contains(m.shader.name))
if (m.shader.name != MToon.Utils.ShaderName)
{
material.shader = glTF_VRM_Material.VRM_USE_GLTFSHADER;
return material;
}
var prop = PreShaderPropExporter.GetPropsForSupportedShader(m.shader.name);
var prop = PreShaderPropExporter.GetPropsForMToon();
if (prop == null)
{
Debug.LogWarningFormat("Fail to export shader: {0}", m.shader.name);
throw new Exception("arienai");
}
else
{

View File

@@ -25,17 +25,16 @@ namespace UniGLTF.ShaderPropExporter
}
}
/// <summary>
/// 今はMToon専用
/// </summary>
public static partial class PreShaderPropExporter
{
public static readonly string[] VRMExtensionShaders = new string[]
{
"VRM/UnlitTransparentZWrite",
"VRM/MToon"
};
static Dictionary<string, ShaderProps> m_shaderPropMap;
public static ShaderProps GetPropsForSupportedShader(string shaderName)
const string ShaderName = "VRM/MToon";
public static ShaderProps GetPropsForMToon()
{
if (m_shaderPropMap == null)
{
@@ -51,19 +50,12 @@ namespace UniGLTF.ShaderPropExporter
}
ShaderProps props;
if (m_shaderPropMap.TryGetValue(shaderName, out props))
if (m_shaderPropMap.TryGetValue(ShaderName, out props))
{
return props;
}
#if UNITY_EDITOR
// fallback
Debug.LogWarningFormat("{0} is not predefined shader. Use ShaderUtil", shaderName);
var shader = Shader.Find(shaderName);
return ShaderProps.FromShader(shader);
#else
return null;
#endif
throw new Exception("arienai");
}
}
}