summaryrefslogtreecommitdiff
path: root/modules/etc/image_etc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/etc/image_etc.cpp')
-rw-r--r--modules/etc/image_etc.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index f0cbf6ae28..b80138c99d 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -139,6 +139,18 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
return;
}
+ if (force_etc1_format) {
+ // 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::DETECTED_RGBA) {
+ p_img->convert(Image::FORMAT_RGBA4444);
+ return;
+ } else if (detected_channels == Image::DETECTED_LA) {
+ p_img->convert(Image::FORMAT_LA8);
+ return;
+ }
+ }
+
uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);