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/nodes.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/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 27e6309ab2d..3905189c8b0 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -316,7 +316,12 @@ void ImageTextureNode::compile(SVMCompiler &compiler) flags |= NODE_IMAGE_COMPRESS_AS_SRGB; } if (!alpha_out->links.empty()) { - flags |= NODE_IMAGE_ALPHA_UNASSOCIATE; + const bool unassociate_alpha = !(ColorSpaceManager::colorspace_is_data(colorspace) || + use_alpha == false); + + if (unassociate_alpha) { + flags |= NODE_IMAGE_ALPHA_UNASSOCIATE; + } } if (projection != NODE_IMAGE_PROJ_BOX) { @@ -389,11 +394,14 @@ void ImageTextureNode::compile(OSLCompiler &compiler) compiler.parameter_texture("filename", slot); } + const bool unassociate_alpha = !(ColorSpaceManager::colorspace_is_data(colorspace) || + use_alpha == false); + compiler.parameter(this, "projection"); compiler.parameter(this, "projection_blend"); compiler.parameter("convert_from_srgb", compress_as_srgb); compiler.parameter("ignore_alpha", !use_alpha); - compiler.parameter("unassociate_alpha", !alpha_out->links.empty()); + compiler.parameter("unassociate_alpha", !alpha_out->links.empty() && unassociate_alpha); compiler.parameter("is_float", is_float); compiler.parameter(this, "interpolation"); compiler.parameter(this, "extension"); |