fix MToon export

This commit is contained in:
ousttrue
2021-03-15 20:52:19 +09:00
parent b474ca3eba
commit 377d5127cc
3 changed files with 11 additions and 9 deletions

View File

@@ -45,6 +45,10 @@ namespace UniGLTF
/// <returns></returns>
public int GetTextureIndex(Texture src, glTFTextureTypes textureType)
{
if (src == null)
{
return -1;
}
return m_exportMap[new ExportKey(src, textureType)];
}

View File

@@ -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

View File

@@ -107,7 +107,7 @@ namespace VRM
// "Queue",
};
public static glTF_VRM_Material CreateFromMaterial(Material m, Func<Texture, glTFTextureTypes, int> 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);