diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-26 13:16:58 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-26 13:21:57 +0300 |
commit | 909b0ac16c26786f864a84e14ec7714c3308d8f0 (patch) | |
tree | 3b8d9839a0aa38d748ffc2ad8d0269328b45e043 /intern/cycles/blender | |
parent | f18373a9ab1ae1534f311af92e03b9c6db1a0cc8 (diff) |
Fix Cycles packed images not handling channel packed alpha correctly
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 20 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.h | 2 |
2 files changed, 14 insertions, 8 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 11b6a38c195..bb7c750078f 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -147,9 +147,9 @@ void BlenderSession::create_session() scene->image_manager->builtin_image_info_cb = function_bind( &BlenderSession::builtin_image_info, this, _1, _2, _3); scene->image_manager->builtin_image_pixels_cb = function_bind( - &BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5); + &BlenderSession::builtin_image_pixels, this, _1, _2, _3, _4, _5, _6); scene->image_manager->builtin_image_float_pixels_cb = function_bind( - &BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5); + &BlenderSession::builtin_image_float_pixels, this, _1, _2, _3, _4, _5, _6); session->scene = scene; @@ -1223,6 +1223,7 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *builtin_data, unsigned char *pixels, const size_t pixels_size, + const bool associate_alpha, const bool free_cache) { if (!builtin_data) { @@ -1272,12 +1273,14 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, b_image.buffers_free(); } - /* Premultiply, byte images are always straight for Blender. */ - unsigned char *cp = pixels; - for (size_t i = 0; i < num_pixels; i++, cp += channels) { - cp[0] = (cp[0] * cp[3]) >> 8; - cp[1] = (cp[1] * cp[3]) >> 8; - cp[2] = (cp[2] * cp[3]) >> 8; + if (associate_alpha) { + /* Premultiply, byte images are always straight for Blender. */ + unsigned char *cp = pixels; + for (size_t i = 0; i < num_pixels; i++, cp += channels) { + cp[0] = (cp[0] * cp[3]) >> 8; + cp[1] = (cp[1] * cp[3]) >> 8; + cp[2] = (cp[2] * cp[3]) >> 8; + } } return true; } @@ -1286,6 +1289,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void *builtin_data, float *pixels, const size_t pixels_size, + const bool, const bool free_cache) { if (!builtin_data) { diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index f0107d4e0b1..b93273e32ae 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -162,11 +162,13 @@ class BlenderSession { void *builtin_data, unsigned char *pixels, const size_t pixels_size, + const bool associate_alpha, const bool free_cache); bool builtin_image_float_pixels(const string &builtin_name, void *builtin_data, float *pixels, const size_t pixels_size, + const bool associate_alpha, const bool free_cache); void builtin_images_load(); |