VRM0のMToonエクスポート時にノーマルマップテクスチャをglTFのマテリアルにもエクスポートするようにした

This commit is contained in:
Isamu Mogi
2024-07-05 20:22:50 +09:00
parent 8b1dd9602c
commit de61e50493

View File

@@ -32,6 +32,7 @@ namespace VRM
ExportRenderingSettings(srcProps, dst);
ExportBaseColor(src, srcProps, textureExporter, dst);
ExportEmission(src, srcProps, textureExporter, dst);
ExportNormal(src, srcProps, textureExporter, dst);
return true;
}
@@ -116,6 +117,23 @@ namespace VRM
}
}
private static void ExportNormal(Material srcMaterial, MToonDefinition src, ITextureExporter textureExporter, glTFMaterial dst)
{
if (src.Lighting.Normal.NormalTexture != null)
{
var index = textureExporter.RegisterExportingAsNormal(src.Lighting.Normal.NormalTexture);
if (index != -1)
{
dst.normalTexture = new glTFMaterialNormalTextureInfo()
{
index = index,
scale = src.Lighting.Normal.NormalScaleValue,
};
ExportMainTextureTransform(srcMaterial, dst.normalTexture);
}
}
}
private static void ExportMainTextureTransform(Material src, glTFTextureInfo targetTextureInfo)
{
GltfMaterialExportUtils.ExportTextureTransform(src, targetTextureInfo, MToon.Utils.PropMainTex);