diff --git a/Debugger/Explorer/MeshViewer.cs b/Debugger/Explorer/MeshViewer.cs index 031c177..c79eb13 100644 --- a/Debugger/Explorer/MeshViewer.cs +++ b/Debugger/Explorer/MeshViewer.cs @@ -179,7 +179,7 @@ protected override void DrawWindow() { if (GUILayout.Button("Dump mesh+textures", GUILayout.Width(160))) { - DumpUtil.DumpMeshAndTextures(assetName, previewMesh, material); + DumpUtil.DumpMeshAndTextures(assetName ?? previewMesh.name, previewMesh, material); } } else if (GUILayout.Button("Dump textures", GUILayout.Width(160))) diff --git a/Debugger/Utils/DumpUtil.cs b/Debugger/Utils/DumpUtil.cs index 5be2f1d..9f14977 100644 --- a/Debugger/Utils/DumpUtil.cs +++ b/Debugger/Utils/DumpUtil.cs @@ -50,6 +50,7 @@ public static void DumpTextures(string assetName, Material material) DumpACI(assetName, (Texture2D)material.GetTexture("_ACIMap")); DumpXYS(assetName, (Texture2D)material.GetTexture("_XYSMap")); DumpXYCA(assetName, (Texture2D)material.GetTexture("_XYCAMap")); + DumpAPR(assetName, (Texture2D)material.GetTexture("_APRMap")); } public static void DumpMeshToOBJ(Mesh mesh, string fileName) @@ -179,7 +180,7 @@ private static void DumpXYCA(string assetName, Texture2D xycaMap, bool extract = var r1 = new Color32[length].Invert(); var b1 = new Color32[length].Invert(); var a1 = new Color32[length].Invert(); - xycaMap.ExtractChannels(r1, r1, b1, a1, false, false, true, false, false, true, true); + xycaMap.ExtractChannels(r1, r1, b1, a1, false, false, true, false, true, true, true); TextureUtil.DumpTextureToPNG(r1.ColorsToTexture(xycaMap.width, xycaMap.height), $"{assetName}_n"); TextureUtil.DumpTextureToPNG(b1.ColorsToTexture(xycaMap.width, xycaMap.height), $"{assetName}_c"); TextureUtil.DumpTextureToPNG(a1.ColorsToTexture(xycaMap.width, xycaMap.height), $"{assetName}_a"); @@ -189,5 +190,29 @@ private static void DumpXYCA(string assetName, Texture2D xycaMap, bool extract = TextureUtil.DumpTextureToPNG(xycaMap, $"{assetName}_XYCA"); } } + + private static void DumpAPR(string assetName, Texture2D aprMap, bool extract = true) + { + if (aprMap == null) + { + return; + } + if (extract) + { + var length = aprMap.width * aprMap.height; + var a1 = new Color32[length].Invert(); + var p1 = new Color32[length].Invert(); + var r1 = new Color32[length].Invert(); + aprMap.ExtractChannels(a1, p1, r1, null, true, true, true, true, true, false, false); + TextureUtil.DumpTextureToPNG(a1.ColorsToTexture(aprMap.width, aprMap.height), $"{assetName}_a"); + TextureUtil.DumpTextureToPNG(p1.ColorsToTexture(aprMap.width, aprMap.height), $"{assetName}_p"); + TextureUtil.DumpTextureToPNG(r1.ColorsToTexture(aprMap.width, aprMap.height), $"{assetName}_r"); + } + else + { + TextureUtil.DumpTextureToPNG(aprMap, $"{assetName}_APR"); + } + } + } } \ No newline at end of file