From ac19e0d13595706e12a078459ece0c44b6866daf Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 2 Jun 2022 15:12:22 +0900 Subject: [PATCH] =?UTF-8?q?PreShaderPropExporter=20=E3=81=AF=E6=97=A2?= =?UTF-8?q?=E3=81=AB=20VRM/MToon=20=E5=B0=82=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM/Editor/Format/VRMMaterialValidator.cs | 2 +- Assets/VRM/Runtime/IO/VRMMaterialExporter.cs | 7 +++--- .../VRM/IO/Runtime/PreShaderPropExporter.cs | 24 +++++++------------ 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/Assets/VRM/Editor/Format/VRMMaterialValidator.cs b/Assets/VRM/Editor/Format/VRMMaterialValidator.cs index 941e59038..d6c792e65 100644 --- a/Assets/VRM/Editor/Format/VRMMaterialValidator.cs +++ b/Assets/VRM/Editor/Format/VRMMaterialValidator.cs @@ -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) diff --git a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs index bf021f20b..5b7c9035b 100644 --- a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs @@ -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 { diff --git a/Assets/VRMShaders/VRM/IO/Runtime/PreShaderPropExporter.cs b/Assets/VRMShaders/VRM/IO/Runtime/PreShaderPropExporter.cs index 8bc5988cb..9d6cd11ce 100644 --- a/Assets/VRMShaders/VRM/IO/Runtime/PreShaderPropExporter.cs +++ b/Assets/VRMShaders/VRM/IO/Runtime/PreShaderPropExporter.cs @@ -25,17 +25,16 @@ namespace UniGLTF.ShaderPropExporter } } + /// + /// 今はMToon専用 + /// public static partial class PreShaderPropExporter { - public static readonly string[] VRMExtensionShaders = new string[] - { - "VRM/UnlitTransparentZWrite", - "VRM/MToon" - }; - static Dictionary 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"); } } }