summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2018-08-06 14:56:06 -0300
committerJuan Linietsky <reduzio@gmail.com>2018-08-06 14:56:06 -0300
commitedde52c8dea0193111239b6b2f002adcc24ac0c9 (patch)
tree8aa3f65b49956fa3f7c3ab765509f2f07b7b6c6c /modules
parent80a8636aa3739822b1ebbbad39f932a176ec158d (diff)
Added proper import support for 3D and Array textures
Diffstat (limited to 'modules')
-rw-r--r--modules/etc/image_etc.cpp29
-rw-r--r--modules/squish/image_compress_squish.cpp31
2 files changed, 57 insertions, 3 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 8a674bc8c1..ddfa7af771 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -98,6 +98,33 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
Image::Format img_format = p_img->get_format();
Image::DetectChannels detected_channels = p_img->get_detected_channels();
+ if (p_source == Image::COMPRESS_SOURCE_LAYERED) {
+ //keep what comes in
+ switch (p_img->get_format()) {
+ case Image::FORMAT_L8: {
+ detected_channels = Image::DETECTED_L;
+ } break;
+ case Image::FORMAT_LA8: {
+ detected_channels = Image::DETECTED_LA;
+ } break;
+ case Image::FORMAT_R8: {
+ detected_channels = Image::DETECTED_R;
+ } break;
+ case Image::FORMAT_RG8: {
+ detected_channels = Image::DETECTED_RG;
+ } break;
+ case Image::FORMAT_RGB8: {
+ detected_channels = Image::DETECTED_RGB;
+ } break;
+ case Image::FORMAT_RGBA8:
+ case Image::FORMAT_RGBA4444:
+ case Image::FORMAT_RGBA5551: {
+ detected_channels = Image::DETECTED_RGBA;
+ } break;
+ default: {}
+ }
+ }
+
if (p_source == Image::COMPRESS_SOURCE_SRGB && (detected_channels == Image::DETECTED_R || detected_channels == Image::DETECTED_RG)) {
//R and RG do not support SRGB
detected_channels = Image::DETECTED_RGB;
@@ -147,7 +174,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
PoolVector<uint8_t>::Read r = img->get_data().read();
- int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps() ? -1 : 0);
+ int target_size = Image::get_image_data_size(imgw, imgh, etc_format, p_img->has_mipmaps());
int mmc = 1 + (p_img->has_mipmaps() ? Image::get_image_required_mipmaps(imgw, imgh, etc_format) : 0);
PoolVector<uint8_t> dst_data;
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 0cf24dd8d8..f6be537413 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -46,7 +46,7 @@ void image_decompress_squish(Image *p_image) {
Image::Format target_format = Image::FORMAT_RGBA8;
PoolVector<uint8_t> data;
- int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps() ? -1 : 0);
+ int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->get_mipmap_count();
data.resize(target_size);
@@ -96,6 +96,33 @@ void image_compress_squish(Image *p_image, Image::CompressSource p_source) {
Image::DetectChannels dc = p_image->get_detected_channels();
+ if (p_source == Image::COMPRESS_SOURCE_LAYERED) {
+ //keep what comes in
+ switch (p_image->get_format()) {
+ case Image::FORMAT_L8: {
+ dc = Image::DETECTED_L;
+ } break;
+ case Image::FORMAT_LA8: {
+ dc = Image::DETECTED_LA;
+ } break;
+ case Image::FORMAT_R8: {
+ dc = Image::DETECTED_R;
+ } break;
+ case Image::FORMAT_RG8: {
+ dc = Image::DETECTED_RG;
+ } break;
+ case Image::FORMAT_RGB8: {
+ dc = Image::DETECTED_RGB;
+ } break;
+ case Image::FORMAT_RGBA8:
+ case Image::FORMAT_RGBA4444:
+ case Image::FORMAT_RGBA5551: {
+ dc = Image::DETECTED_RGBA;
+ } break;
+ default: {}
+ }
+ }
+
p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
if (p_source == Image::COMPRESS_SOURCE_SRGB && (dc == Image::DETECTED_R || dc == Image::DETECTED_RG)) {
@@ -148,7 +175,7 @@ void image_compress_squish(Image *p_image, Image::CompressSource p_source) {
}
PoolVector<uint8_t> data;
- int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps() ? -1 : 0);
+ int target_size = Image::get_image_data_size(w, h, target_format, p_image->has_mipmaps());
int mm_count = p_image->has_mipmaps() ? Image::get_image_required_mipmaps(w, h, target_format) : 0;
data.resize(target_size);
int shift = Image::get_format_pixel_rshift(target_format);