mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-30 06:43:21 -05:00
fix MToon export
This commit is contained in:
@@ -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)];
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user