diff --git a/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/Materials/BuiltInVrmMToonMaterialExporter.cs b/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/Materials/BuiltInVrmMToonMaterialExporter.cs index c376d22f2..a168e320e 100644 --- a/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/Materials/BuiltInVrmMToonMaterialExporter.cs +++ b/Assets/VRM/Runtime/IO/MaterialIO/BuiltInRP/Export/Materials/BuiltInVrmMToonMaterialExporter.cs @@ -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);