diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-19 03:56:12 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-19 15:36:42 +0300 |
commit | 3b23b5c638feae0ad6319440771b83a64a1f9ebe (patch) | |
tree | 16fbedd83ffa6a02904d3f93576c1de1674a0584 /intern/cycles/render/image.cpp | |
parent | 7c78c20b6bf6f7dd00397c456fb9e2116febfca7 (diff) |
Images: don't (un)premultipy non-color data
The previous behavior here was wrong for some specific combinations of
settings, non-color RGB channels should never be affected by the alpha
channel.
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r-- | intern/cycles/render/image.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 431e9230cb4..6301b416724 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -513,8 +513,14 @@ bool ImageManager::file_load_image_generic(Image *img, unique_ptr<ImageInput> *i ImageSpec spec = ImageSpec(); ImageSpec config = ImageSpec(); - if (img->use_alpha == false) + /* For typical RGBA images we let OIIO convert to associated alpha, + * but some types we want to leave the RGB channels untouched. */ + const bool associate_alpha = !(ColorSpaceManager::colorspace_is_data(img->colorspace) || + img->use_alpha == false); + + if (!associate_alpha) { config.attribute("oiio:UnassociatedAlpha", 1); + } if (!(*in)->open(img->filename, spec, config)) { return false; |