From 0c3af32d778f742cb2d5049c2f57220f550e3c19 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Sat, 29 Feb 2020 19:30:43 -0800 Subject: Force mipmaps off when importing RGBA4444 textures --- core/image.cpp | 2 ++ modules/etc/image_etc.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/core/image.cpp b/core/image.cpp index a188447f90..2c39c9b882 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1458,6 +1458,8 @@ Error Image::generate_mipmaps(bool p_renormalize) { ERR_FAIL_COND_V_MSG(!_can_modify(format), ERR_UNAVAILABLE, "Cannot generate mipmaps in compressed or custom image formats."); + ERR_FAIL_COND_V_MSG(format == FORMAT_RGBA4444, ERR_UNAVAILABLE, "Cannot generate mipmaps from RGBA4444 format."); + ERR_FAIL_COND_V_MSG(width == 0 || height == 0, ERR_UNCONFIGURED, "Cannot generate mipmaps with width or height equal to 0."); int mmcount; diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp index 0dbd5ca905..b3f7b1d94f 100644 --- a/modules/etc/image_etc.cpp +++ b/modules/etc/image_etc.cpp @@ -106,9 +106,15 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f // If VRAM compression is using ETC, but image has alpha, convert to RGBA4444 or LA8 // This saves space while maintaining the alpha channel if (detected_channels == Image::USED_CHANNELS_RGBA) { + + if (p_img->has_mipmaps()) { + // Image doesn't support mipmaps with RGBA4444 textures + p_img->clear_mipmaps(); + } p_img->convert(Image::FORMAT_RGBA4444); return; } else if (detected_channels == Image::USE_CHANNELS_LA) { + p_img->convert(Image::FORMAT_LA8); return; } -- cgit v1.2.3