mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-06-02 22:14:30 -05:00
add shader.name check
This commit is contained in:
parent
517168298b
commit
2fce44159d
|
|
@ -1,8 +1,5 @@
|
||||||
using System;
|
using UniGLTF.UniUnlit;
|
||||||
using System.Collections.Generic;
|
|
||||||
using UniGLTF.UniUnlit;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
|
||||||
|
|
||||||
|
|
||||||
namespace UniGLTF
|
namespace UniGLTF
|
||||||
|
|
@ -185,7 +182,7 @@ namespace UniGLTF
|
||||||
|
|
||||||
static void Export_TextureTransform(Material m, glTFTextureInfo textureInfo, string propertyName)
|
static void Export_TextureTransform(Material m, glTFTextureInfo textureInfo, string propertyName)
|
||||||
{
|
{
|
||||||
if( textureInfo != null && m.HasProperty(propertyName))
|
if (textureInfo != null && m.HasProperty(propertyName))
|
||||||
{
|
{
|
||||||
var offset = m.GetTextureOffset(propertyName);
|
var offset = m.GetTextureOffset(propertyName);
|
||||||
var scale = m.GetTextureScale(propertyName);
|
var scale = m.GetTextureScale(propertyName);
|
||||||
|
|
@ -202,6 +199,21 @@ namespace UniGLTF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool UseUnlit(string shaderName)
|
||||||
|
{
|
||||||
|
switch (shaderName)
|
||||||
|
{
|
||||||
|
case "Unlit/Color":
|
||||||
|
case "Unlit/Texture":
|
||||||
|
case "Unlit/Transparent":
|
||||||
|
case "Unlit/Transparent Cutout":
|
||||||
|
case "UniGLTF/UniUnlit":
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual glTFMaterial CreateMaterial(Material m)
|
protected virtual glTFMaterial CreateMaterial(Material m)
|
||||||
{
|
{
|
||||||
switch (m.shader.name)
|
switch (m.shader.name)
|
||||||
|
|
|
||||||
|
|
@ -112,10 +112,35 @@ namespace VRM
|
||||||
yield return Validation.Error("ReduceBlendshapeSize is need VRMBlendShapeProxy, you need to convert to VRM once.");
|
yield return Validation.Error("ReduceBlendshapeSize is need VRMBlendShapeProxy, you need to convert to VRM once.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Source.GetComponentsInChildren<Renderer>().All(x => !x.gameObject.activeInHierarchy))
|
var renderers = Source.GetComponentsInChildren<Renderer>();
|
||||||
|
if (renderers.All(x => !x.gameObject.activeInHierarchy))
|
||||||
{
|
{
|
||||||
yield return Validation.Error("No active mesh");
|
yield return Validation.Error("No active mesh");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var materials = renderers.SelectMany(x => x.sharedMaterials).Distinct();
|
||||||
|
foreach (var material in materials)
|
||||||
|
{
|
||||||
|
if (material.shader.name == "Standard")
|
||||||
|
{
|
||||||
|
// standard
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MaterialExporter.UseUnlit(material.shader.name))
|
||||||
|
{
|
||||||
|
// unlit
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VRMMaterialExporter.VRMExtensionShaders.Contains(material.shader.name))
|
||||||
|
{
|
||||||
|
// VRM supported
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return Validation.Warning(string.Format("unknown material '{0}' is used. this will export as `Standard` fallback", material.shader.name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeFrom(GameObject go)
|
public void InitializeFrom(GameObject go)
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,7 @@ namespace VRM
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CreateFromMaterial
|
#region CreateFromMaterial
|
||||||
private static readonly string[] VRMExtensionShaders = new string[]
|
public static readonly string[] VRMExtensionShaders = new string[]
|
||||||
{
|
{
|
||||||
"VRM/UnlitTransparentZWrite",
|
"VRM/UnlitTransparentZWrite",
|
||||||
"VRM/MToon"
|
"VRM/MToon"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user