Added dithering option to textures

This commit is contained in:
2025-01-14 20:47:01 +01:00
parent 829176a25e
commit 3f238c619e
2 changed files with 61 additions and 1 deletions

View File

@@ -14,8 +14,9 @@ public class QuantizedPreviewWindow : EditorWindow
private int bpp = 4;
private int targetWidth = 128;
private int targetHeight = 128;
public bool dithering = true;
private int maxKMeans = 100;
private int previewSize = 256;
private readonly int previewSize = 256;
[MenuItem("Window/Quantized Preview")]
public static void ShowWindow()
@@ -33,6 +34,8 @@ public class QuantizedPreviewWindow : EditorWindow
targetWidth = EditorGUILayout.IntField("Target Width", targetWidth);
targetHeight = EditorGUILayout.IntField("Target Height", targetHeight);
dithering = EditorGUILayout.Toggle("Dithering", dithering);
bpp = EditorGUILayout.IntPopup("Bits Per Pixel", bpp, new[] { "4 bpp", "8 bpp", "16 bpp" }, new[] { 4, 8, 16 });
maxKMeans = EditorGUILayout.IntField("Max K-Means", maxKMeans);
@@ -132,6 +135,10 @@ public class QuantizedPreviewWindow : EditorWindow
{
Texture2D resizedTexture = PSXTexture.ResizeTexture(originalTexture, targetWidth, targetHeight);
if(dithering) {
resizedTexture = PSXTexture.DitherTexture(resizedTexture);
}
if (bpp == 16)
{
quantizedTexture = null;