summaryrefslogtreecommitdiff
path: root/modules/tinyexr
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-05-29 22:11:33 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-05-30 08:56:19 -0300
commit5567e898d1052c1e2c2d32d3c37dfd957f4dc4bd (patch)
treee0df9b88b6c485f846dab9ae51369288f191cab8 /modules/tinyexr
parent0a6faeb4f5914061c29d946eaa29f2c50b8472fb (diff)
Several fixes related to PBR and Environment
Diffstat (limited to 'modules/tinyexr')
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp16
-rw-r--r--modules/tinyexr/image_loader_tinyexr.h2
2 files changed, 13 insertions, 5 deletions
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index fbf5dea15e..4eb91da10b 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -34,7 +34,7 @@
#include "thirdparty/tinyexr/tinyexr.h"
-Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f) {
+Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
@@ -133,9 +133,17 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f) {
// Assume `out_rgba` have enough memory allocated.
for (int i = 0; i < exr_image.width * exr_image.height; i++) {
- *iw++ = Math::make_half_float(reinterpret_cast<float **>(exr_image.images)[idxR][i]);
- *iw++ = Math::make_half_float(reinterpret_cast<float **>(exr_image.images)[idxG][i]);
- *iw++ = Math::make_half_float(reinterpret_cast<float **>(exr_image.images)[idxB][i]);
+ Color color(
+ reinterpret_cast<float **>(exr_image.images)[idxR][i],
+ reinterpret_cast<float **>(exr_image.images)[idxG][i],
+ reinterpret_cast<float **>(exr_image.images)[idxB][i]);
+
+ if (p_force_linear)
+ color = color.to_linear();
+
+ *iw++ = Math::make_half_float(color.r);
+ *iw++ = Math::make_half_float(color.g);
+ *iw++ = Math::make_half_float(color.b);
if (idxA > 0) {
*iw++ = Math::make_half_float(reinterpret_cast<float **>(exr_image.images)[idxA][i]);
diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h
index 328ac2a385..a52894b12b 100644
--- a/modules/tinyexr/image_loader_tinyexr.h
+++ b/modules/tinyexr/image_loader_tinyexr.h
@@ -38,7 +38,7 @@
class ImageLoaderTinyEXR : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderTinyEXR();
};