Skip to content

Commit

Permalink
Fix compression threshold check
Browse files Browse the repository at this point in the history
This check is intended to prevent lossy DXT5 texture compression for small textures below 256 pixels in either width OR height. Was instead checking width AND height.
This meant loose replacement UI images of 320x200 would suffer from lossy compression, degrading their appearance.
  • Loading branch information
Interkarma committed Jul 28, 2023
1 parent e5f6a7d commit 4a65a03
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -1020,7 +1020,7 @@ private static bool TryImportTextureFromDisk(string path, bool mipMaps, bool isL
{
byte[] bytes = File.ReadAllBytes(path);
Vector2Int resolution = FindPngResolution(bytes) ?? throw new Exception($"Failed to find PNG resolution for {path}");
TextureFormat textureFormat = resolution.x < retroThreshold && resolution.y < retroThreshold ? TextureFormat.ARGB32 : TextureFormat;
TextureFormat textureFormat = resolution.x < retroThreshold || resolution.y < retroThreshold ? TextureFormat.ARGB32 : TextureFormat;

tex = new Texture2D(4, 4, textureFormat, mipMaps, isLinear);
if (!tex.LoadImage(bytes, readOnly))
Expand Down

0 comments on commit 4a65a03

Please sign in to comment.