From ee77504ed3d4375e089da25be3d9d7f78d61a1df Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Wed, 23 Jun 2021 23:52:45 +0900 Subject: [PATCH] don't export alpha if material has no transparency --- .../Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs index ab5da1bf9..8a58d5a2a 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using UniGLTF.UniUnlit; using UnityEngine; using VRMShaders; @@ -38,7 +39,10 @@ namespace UniGLTF if (m.HasProperty("_MainTex")) { - var index = textureManager.ExportAsSRgb(m.GetTexture("_MainTex"), needsAlpha: true); + var hasTransparency = string.Equals(material.alphaMode, "MASK", StringComparison.Ordinal) || + string.Equals(material.alphaMode, "BLEND", StringComparison.Ordinal); + + var index = textureManager.ExportAsSRgb(m.GetTexture("_MainTex"), hasTransparency); if (index != -1) { material.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo()