Auto-delete consumed roughness source after metallic-smoothness repack

PolyHavenMaterialBuilder now removes the separate roughness map (asset +
meta) once its data has been packed into the generated
_metallic_smoothness.png; skipped when the repack fails or roughness came
from the ARM texture.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Fable 5 committed 2026-07-16 14:47:49 +02:00
1 parent 0e855622c4
commit dc731a9941
1 file changed
+9
@@ -40,6 +40,15 @@ namespace Chameleon.Editor.PolyHaven
if (!string.IsNullOrEmpty(roughPath) || !string.IsNullOrEmpty(armPath)) if (!string.IsNullOrEmpty(roughPath) || !string.IsNullOrEmpty(armPath))
metallicGlossPath = BuildMetallicSmoothness(folder, slug, roughPath, metalPath, armPath, maxSize); metallicGlossPath = BuildMetallicSmoothness(folder, slug, roughPath, metalPath, armPath, maxSize);
// The roughness source is fully consumed into the packed map and never
// referenced by the material — drop it once the repack succeeded.
if (!string.IsNullOrEmpty(metallicGlossPath) && !string.IsNullOrEmpty(roughPath))
{
AssetDatabase.DeleteAsset(roughPath);
byType.Remove(PolyHavenMapType.Rough);
Debug.Log($"[PolyHaven] Deleted consumed roughness source: {roughPath}");
}
// AO comes from the dedicated map, or the ARM red channel as a fallback. // AO comes from the dedicated map, or the ARM red channel as a fallback.
string occlusionPath = null; string occlusionPath = null;
if (byType.TryGetValue(PolyHavenMapType.AO, out var aoSeparate)) if (byType.TryGetValue(PolyHavenMapType.AO, out var aoSeparate))