diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
index ca73855ef..486bdece0 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
@@ -45,6 +45,10 @@ namespace UniGLTF
///
public int GetTextureIndex(Texture src, glTFTextureTypes textureType)
{
+ if (src == null)
+ {
+ return -1;
+ }
return m_exportMap[new ExportKey(src, textureType)];
}
diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs
index 980cef846..a24c3e240 100644
--- a/Assets/VRM/Runtime/IO/VRMExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMExporter.cs
@@ -137,7 +137,7 @@ namespace VRM
VRM.meta.title = meta.Title;
if (meta.Thumbnail != null)
{
- VRM.meta.texture = TextureExporter.ExportTexture(glTF, glTF.buffers.Count - 1, meta.Thumbnail);
+ VRM.meta.texture = TextureManager.ExportSRGB(meta.Thumbnail);
}
// ussage permission
@@ -200,7 +200,7 @@ namespace VRM
// materials
foreach (var m in Materials)
{
- VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.GetTextureIndex));
+ VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager));
}
// Serialize VRM
diff --git a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
index 2b955cb95..0b49c6b90 100644
--- a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
@@ -107,7 +107,7 @@ namespace VRM
// "Queue",
};
- public static glTF_VRM_Material CreateFromMaterial(Material m, Func getTextureIndex)
+ public static glTF_VRM_Material CreateFromMaterial(Material m, TextureExporter textureExporter)
{
var material = new glTF_VRM_Material
{
@@ -160,12 +160,10 @@ namespace VRM
var texture = m.GetTexture(kv.Key);
if (texture != null)
{
- var textureType = glTFTextureTypes.SRGB;
- if (kv.Key == "_BumpMap")
- {
- textureType = glTFTextureTypes.Normal;
- }
- var value = getTextureIndex(texture, textureType);
+ var value = kv.Key == "_BumpMap"
+ ? textureExporter.ExportNormal(texture)
+ : textureExporter.ExportSRGB(texture)
+ ;
if (value == -1)
{
Debug.LogFormat("not found {0}", texture.name);