summaryrefslogtreecommitdiff
path: root/modules/squish
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-05-31 20:16:38 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-05-31 20:29:56 -0300
commita134f58fb3e072a3453bd5e9286f90b4694c9766 (patch)
treedaa9f4130a90e8a1604835e1ae564db128a06a48 /modules/squish
parenta802bd91d000647a40e401c14c0d323209bc6446 (diff)
rewritten PBR implementation to make it friendlier with Blender
Diffstat (limited to 'modules/squish')
-rw-r--r--modules/squish/image_compress_squish.cpp19
-rw-r--r--modules/squish/image_compress_squish.h2
2 files changed, 13 insertions, 8 deletions
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 2427dac8a7..efed0b8665 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -59,9 +59,9 @@ void image_decompress_squish(Image *p_image) {
squish_flags = squish::kDxt3;
} else if (p_image->get_format() == Image::FORMAT_DXT5) {
squish_flags = squish::kDxt5;
- } else if (p_image->get_format() == Image::FORMAT_LATC_L || p_image->get_format() == Image::FORMAT_RGTC_R) {
+ } else if (p_image->get_format() == Image::FORMAT_RGTC_R) {
squish_flags = squish::kBc4;
- } else if (p_image->get_format() == Image::FORMAT_LATC_LA || p_image->get_format() == Image::FORMAT_RGTC_RG) {
+ } else if (p_image->get_format() == Image::FORMAT_RGTC_RG) {
squish_flags = squish::kBc5;
} else {
ERR_FAIL_COND(true);
@@ -79,7 +79,7 @@ void image_decompress_squish(Image *p_image) {
p_image->create(p_image->get_width(), p_image->get_height(), p_image->has_mipmaps(), target_format, data);
}
-void image_compress_squish(Image *p_image) {
+void image_compress_squish(Image *p_image, bool p_srgb) {
if (p_image->get_format() >= Image::FORMAT_DXT1)
return; //do not compress, already compressed
@@ -96,16 +96,21 @@ void image_compress_squish(Image *p_image) {
p_image->convert(Image::FORMAT_RGBA8); //still uses RGBA to convert
+ if (p_srgb && (dc == Image::DETECTED_R || dc == Image::DETECTED_RG)) {
+ //R and RG do not support SRGB
+ dc = Image::DETECTED_RGB;
+ }
+
switch (dc) {
case Image::DETECTED_L: {
- target_format = Image::FORMAT_LATC_L;
- squish_comp |= squish::kBc4;
+ target_format = Image::FORMAT_DXT1;
+ squish_comp |= squish::kDxt1;
} break;
case Image::DETECTED_LA: {
- target_format = Image::FORMAT_LATC_LA;
- squish_comp |= squish::kBc5;
+ target_format = Image::FORMAT_DXT5;
+ squish_comp |= squish::kDxt5;
} break;
case Image::DETECTED_R: {
diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h
index 519e3537ef..8d859b8e0b 100644
--- a/modules/squish/image_compress_squish.h
+++ b/modules/squish/image_compress_squish.h
@@ -32,7 +32,7 @@
#include "image.h"
-void image_compress_squish(Image *p_image);
+void image_compress_squish(Image *p_image, bool p_srgb);
void image_decompress_squish(Image *p_image);
#endif // IMAGE_COMPRESS_SQUISH_H