Fix for #28876, alpha over with empty image node gives black result.

The image node output is the default value when no image is selected. In pre-2.60 this was always initialized to 0 alpha, the defaults written in the node socket templates were completely ignored for outputs (except for value and RGB input nodes, which use these as button values). Now the stack values are initialized with the template defaults, which are all 0 by default. This patch changes alpha to 0 for image and render layer outputs too.
This commit is contained in:
Lukas Toenne 2011-10-12 13:07:30 +00:00
parent a85f595721
commit 89dd5e933f
2 changed files with 25 additions and 1 deletions

@ -7068,6 +7068,19 @@ void convert_tface_mt(FileData *fd, Main *main)
}
}
static void do_versions_nodetree_image_default_alpha_output(bNodeTree *ntree)
{
bNode *node;
bNodeSocket *sock;
for (node=ntree->nodes.first; node; node=node->next) {
if (ELEM(node->type, CMP_NODE_IMAGE, CMP_NODE_R_LAYERS)) {
/* default Image output value should have 0 alpha */
sock = node->outputs.first;
((bNodeSocketValueRGBA*)sock->default_value)->value[3] = 0.0f;
}
}
}
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@ -12145,6 +12158,17 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
/* put compatibility code here until next subversion bump */
{
{
/* set default alpha value of Image outputs in image and render layer nodes to 0 */
Scene *sce;
bNodeTree *ntree;
for (sce=main->scene.first; sce; sce=sce->id.next)
if (sce->nodetree)
do_versions_nodetree_image_default_alpha_output(sce->nodetree);
for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next)
do_versions_nodetree_image_default_alpha_output(ntree);
}
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

@ -38,7 +38,7 @@
/* **************** IMAGE (and RenderResult, multilayer image) ******************** */
static bNodeSocketTemplate cmp_node_rlayers_out[]= {
{ SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_FLOAT, 0, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
{ SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},