Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	Debugger/MeshViewer.cs
#	Debugger/ModTools.cs
#	Debugger/Utils/DumpUtil.cs
  • Loading branch information
dymanoid committed Jun 21, 2019
2 parents d784984 + 266af32 commit e29b0a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Debugger/Explorer/MeshViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
27 changes: 26 additions & 1 deletion Debugger/Utils/DumpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand All @@ -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");
}
}

}
}

0 comments on commit e29b0a4

Please sign in to comment.