From de61e5049336b7bfb592c728946c61c9ca1f8bbb Mon Sep 17 00:00:00 2001 From: Isamu Mogi Date: Fri, 5 Jul 2024 20:22:50 +0900 Subject: [PATCH] =?UTF-8?q?VRM0=E3=81=AEMToon=E3=82=A8=E3=82=AF=E3=82=B9?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=88=E6=99=82=E3=81=AB=E3=83=8E=E3=83=BC?= =?UTF-8?q?=E3=83=9E=E3=83=AB=E3=83=9E=E3=83=83=E3=83=97=E3=83=86=E3=82=AF?= =?UTF-8?q?=E3=82=B9=E3=83=81=E3=83=A3=E3=82=92glTF=E3=81=AE=E3=83=9E?= =?UTF-8?q?=E3=83=86=E3=83=AA=E3=82=A2=E3=83=AB=E3=81=AB=E3=82=82=E3=82=A8?= =?UTF-8?q?=E3=82=AF=E3=82=B9=E3=83=9D=E3=83=BC=E3=83=88=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BuiltInVrmMToonMaterialExporter.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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);