diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-01 19:37:15 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2013-03-01 19:37:15 +0400 |
commit | f186f89a42575622a9939a6fbe3f240d2a1ba85a (patch) | |
tree | 97fb62739b7efb67694d78ed54d38ea59578c10d /source/blender/blenloader | |
parent | 69f746d04cdb87d701f0e9ccc56f2fc236f8dd95 (diff) |
Fix #34461: Inconsistent behavior of "Color Mix Node" and "Alpha Over Node"
Added compatibility option "Straight Alpha Output" to image input node
When this option is enabled, image input node will convert float buffer
to straight alpha.
This is not what you'll usually want with new alpha pipeline, nit this
is needed to preserve compatibility with older files saved in 2.65.
In that version byte image are resulting with straight alpha passing
to the compositor and alpha-overing required extra premultiplication
of inputs.
So, that's why Straight Alpha Output is needed -- it's set in versioning
code for byte node images so they'll still output straight alpha.
This option is currently only available in N-panel.
Additional change: added Alpha Mode for image input node to N-panel.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d70cbe4a145..9c6e82cf998 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7355,6 +7355,23 @@ static void do_version_node_fix_translate_wrapping(void *UNUSED(data), ID *UNUSE } } +static void do_version_node_straight_image_alpha_workaround(void *data, ID *UNUSED(id), bNodeTree *ntree) +{ + FileData *fd = (FileData *) data; + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_IMAGE) { + Image *image = blo_do_versions_newlibadr(fd, ntree->id.lib, node->id); + + if (image) { + if ((image->flag & IMA_DO_PREMUL) == 0 && image->alpha_mode == IMA_ALPHA_STRAIGHT) + node->custom1 |= CMP_NODE_IMAGE_USE_STRAIGHT_OUTPUT; + } + } + } +} + static void do_version_node_fix_internal_links_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) { bNode *node; @@ -8648,6 +8665,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Scene *scene; Image *image, *nimage; Tex *tex, *otex; + bNodeTreeType *ntreetype; + bNodeTree *ntree; for (scene = main->scene.first; scene; scene = scene->id.next) { Sequence *seq; @@ -8752,6 +8771,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main) for (image = main->image.first; image; image = image->id.next) image->flag &= ~IMA_DONE_TAG; + + ntreetype = ntreeGetType(NTREE_COMPOSIT); + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, fd, do_version_node_straight_image_alpha_workaround); + + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) + do_version_node_straight_image_alpha_workaround(fd, NULL, ntree); } if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 7)) { |