cleaner and unique stub

This commit is contained in:
tresabhi committed 2026-06-09 13:30:40 -05:00
1 parent 05dd4dbd98
commit 5cbe08fe1c
4 files changed
+19 -3

No files matched your search

+3 -1
View File
@@ -233,7 +233,9 @@ public partial class GameInterface
}
catch (Exception e)
{
throw new Exception($"Failed to export tank part: {part}", e);
Console.WriteLine(e);
}
return [];
}
}
+16 -2
View File
@@ -39,7 +39,7 @@ public class MonoGltf
{ "RMAO", KnownChannel.MetallicRoughness },
// { "CDE", ?? },
};
readonly string stubTexture = "../../stub/stupid.png";
readonly byte[] stubBytes = File.ReadAllBytes("../game/stub/small.png");
public MonoGltf(UStaticMesh staticMesh)
{
@@ -83,7 +83,16 @@ public class MonoGltf
var name = Path.GetFileNameWithoutExtension(texture.GetPathName());
var path = $"../../../textures/{name}.webp";
materialBuilder.WithChannelImage(channel, stubTexture);
var lastIndex = stubBytes.Length - 1;
stubBytes[lastIndex] = (byte)(++stubBytes[lastIndex] % 255);
var uniqueBytes = (byte[])stubBytes.Clone();
var stubImage = new MemoryImage(uniqueBytes);
// Console.WriteLine(
// $"created stub image {stubImage} @ {stubImage.SourcePath} w/ byte {uniqueBytes[lastIndex]}"
// );
materialBuilder.WithChannelImage(channel, stubImage);
materialBuilder.GetChannel(channel).Texture.PrimaryImage.Name = path;
}
else
@@ -126,8 +135,11 @@ public class MonoGltf
var mappedTextures = new Dictionary<MemoryImage, string>();
// Console.WriteLine($"found {model.LogicalImages.Count} logical images");
foreach (var image in model.LogicalImages)
{
// Console.WriteLine($"mapping {image.Content} ({image.Name})");
mappedTextures[image.Content] = image.Name!;
image.Name = null;
}
@@ -141,6 +153,8 @@ public class MonoGltf
ImageWriting = ResourceWriteMode.SatelliteFile,
ImageWriteCallback = (context, assetName, image) =>
{
// Console.WriteLine($"got {image} -> {mappedTextures[image]}");
return mappedTextures[image];
},
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 95 B

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 886 KiB