Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2010-11-12 17:59:01 +0300
committerTon Roosendaal <ton@blender.org>2010-11-12 17:59:01 +0300
commit0b23f03503e6acb5261711720950fde410bb534d (patch)
tree374f43634168e7e79cb1867ea25d914a9e53a14b
parent3c4b1c0d60e1391bbcd95fb0e7f6d179cc1a33da (diff)
Bugfix #24335
ZCombine node in compositor ignored alpha values. Enabling it would break compatibility though, so it's a tickbox option now. Patch provided by reporter, Martin Lubich. Thanks!
-rw-r--r--source/blender/editors/space_node/drawnode.c12
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c10
-rw-r--r--source/blender/makesrna/intern/rna_nodetree_types.h2
-rw-r--r--source/blender/makesrna/rna_cleanup/rna_properties.txt1
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c86
5 files changed, 95 insertions, 16 deletions
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 62936059609..85c1daf81b3 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -776,6 +776,15 @@ static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C),
uiItemR(col, ptr, "premul", 0, NULL, 0);
}
+static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+{
+ uiLayout *col;
+
+ col =uiLayoutColumn(layout, 1);
+ uiItemR(col, ptr, "use_alpha", 0, NULL, 0);
+}
+
+
static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{
uiLayout *col;
@@ -1149,6 +1158,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_HUECORRECT:
ntype->uifunc=node_composit_buts_huecorrect;
break;
+ case CMP_NODE_ZCOMBINE:
+ ntype->uifunc=node_composit_buts_zcombine;
+ break;
default:
ntype->uifunc= NULL;
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 52a19c6376f..325362dd587 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2034,6 +2034,16 @@ static void def_cmp_huecorrect(StructRNA *srna)
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
+static void def_cmp_zcombine(StructRNA *srna)
+{
+ PropertyRNA *prop;
+
+ prop = RNA_def_property(srna, "use_alpha", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "custom1", 0);
+ RNA_def_property_ui_text(prop, "Use Alpha", "Takes Alpha channel into account when doing the Z operation");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+}
+
/* -- Texture Nodes --------------------------------------------------------- */
diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h
index f824f6f20ce..679a5fc0cdc 100644
--- a/source/blender/makesrna/intern/rna_nodetree_types.h
+++ b/source/blender/makesrna/intern/rna_nodetree_types.h
@@ -71,7 +71,7 @@ DefNode( CompositorNode, CMP_NODE_COMPOSITE, 0, "COMPO
DefNode( CompositorNode, CMP_NODE_OUTPUT_FILE, def_cmp_output_file, "OUTPUT_FILE", OutputFile, "Output File", "" )
DefNode( CompositorNode, CMP_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" )
DefNode( CompositorNode, CMP_NODE_TRANSLATE, 0, "TRANSLATE", Translate, "Translate", "" )
-DefNode( CompositorNode, CMP_NODE_ZCOMBINE, 0, "ZCOMBINE", Zcombine, "Z Combine", "" )
+DefNode( CompositorNode, CMP_NODE_ZCOMBINE, def_cmp_zcombine, "ZCOMBINE", Zcombine, "Z Combine", "" )
DefNode( CompositorNode, CMP_NODE_COMBRGBA, 0, "COMBRGBA", CombRGBA, "Combine RGBA", "" )
DefNode( CompositorNode, CMP_NODE_DILATEERODE, def_cmp_dilate_erode, "DILATEERODE", DilateErode, "Dilate/Erode", "" )
DefNode( CompositorNode, CMP_NODE_ROTATE, def_cmp_rotate, "ROTATE", Rotate, "Rotate", "" )
diff --git a/source/blender/makesrna/rna_cleanup/rna_properties.txt b/source/blender/makesrna/rna_cleanup/rna_properties.txt
index 92adbf4373e..df833d8e82b 100644
--- a/source/blender/makesrna/rna_cleanup/rna_properties.txt
+++ b/source/blender/makesrna/rna_cleanup/rna_properties.txt
@@ -2495,6 +2495,7 @@
#+ * Node|CompositorNode.type -> type: enum, "(read-only)"
#+ * Node|CompositorNode|CompositorNodeAlphaOver.premul -> premul: float "Mix Factor"
#Node|CompositorNode|CompositorNodeAlphaOver.use_premultiply -> use_premultiply: boolean "NO DESCRIPTION"
+#Node|CompositorNode|CompositorNodeZcombine.use_alpha -> use_alpha: boolean "NO DESCRIPTION"
#+ * Node|CompositorNode|CompositorNodeBilateralblur.iterations -> iterations: int "NO DESCRIPTION"
#+ * Node|CompositorNode|CompositorNodeBilateralblur.sigma_color -> sigma_color: float "NO DESCRIPTION"
#+ * Node|CompositorNode|CompositorNodeBilateralblur.sigma_space -> sigma_space: float "NO DESCRIPTION"
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c b/source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c
index 80989feaf26..17d88543698 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_zcombine.c
@@ -31,7 +31,7 @@
/* **************** Z COMBINE ******************** */
- /* lazy coder note: node->custom1 is abused to send signal */
+ /* lazy coder note: node->custom2 is abused to send signal */
static bNodeSocketType cmp_node_zcombine_in[]= {
{ SOCK_RGBA, 1, "Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
{ SOCK_VALUE, 1, "Z", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 10000.0f},
@@ -47,13 +47,40 @@ static bNodeSocketType cmp_node_zcombine_out[]= {
static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float *src2, float *z2)
{
+ float alpha;
+ float malpha;
+
if(*z1 <= *z2) {
- QUATCOPY(out, src1);
+ if (node->custom1) {
+ // use alpha in combine operation
+ alpha= src1[3];
+ malpha= 1.0f - alpha;
+ out[0]= malpha*src2[0] + alpha*src1[0];
+ out[1]= malpha*src2[1] + alpha*src1[1];
+ out[2]= malpha*src2[2] + alpha*src1[2];
+ out[3]= malpha*src2[3] + alpha*src1[3];
+ }
+ else {
+ // do combination based solely on z value
+ QUATCOPY(out, src1);
+ }
}
else {
- QUATCOPY(out, src2);
+ if (node->custom1) {
+ // use alpha in combine operation
+ alpha= src2[3];
+ malpha= 1.0f - alpha;
+ out[0]= malpha*src1[0] + alpha*src2[0];
+ out[1]= malpha*src1[1] + alpha*src2[1];
+ out[2]= malpha*src1[2] + alpha*src2[2];
+ out[3]= malpha*src1[3] + alpha*src2[3];
+ }
+ else {
+ // do combination based solely on z value
+ QUATCOPY(out, src1);
+ }
- if(node->custom1)
+ if(node->custom2)
*z1= *z2;
}
}
@@ -62,20 +89,49 @@ static void do_zcombine_mask(bNode *node, float *out, float *z1, float *z2)
{
if(*z1 > *z2) {
*out= 1.0f;
- if(node->custom1)
+ if(node->custom2)
*z1= *z2;
}
}
-static void do_zcombine_add(bNode *UNUSED(node), float *out, float *col1, float *col2, float *acol)
+static void do_zcombine_add(bNode *node, float *out, float *col1, float *col2, float *acol)
{
- float alpha= *acol;
- float malpha= 1.0f - alpha;
-
- out[0]= malpha*col1[0] + alpha*col2[0];
- out[1]= malpha*col1[1] + alpha*col2[1];
- out[2]= malpha*col1[2] + alpha*col2[2];
- out[3]= malpha*col1[3] + alpha*col2[3];
+ float alpha;
+ float malpha;
+
+ if (node->custom1) {
+ // use alpha in combine operation, antialiased mask in used here just as hint for the z value
+ if (*acol>0.0f) {
+ alpha= col2[3];
+ malpha= 1.0f - alpha;
+
+
+ out[0]= malpha*col1[0] + alpha*col2[0];
+ out[1]= malpha*col1[1] + alpha*col2[1];
+ out[2]= malpha*col1[2] + alpha*col2[2];
+ out[3]= malpha*col1[3] + alpha*col2[3];
+ }
+ else {
+ alpha= col1[3];
+ malpha= 1.0f - alpha;
+
+
+ out[0]= malpha*col2[0] + alpha*col1[0];
+ out[1]= malpha*col2[1] + alpha*col1[1];
+ out[2]= malpha*col2[2] + alpha*col1[2];
+ out[3]= malpha*col2[3] + alpha*col1[3];
+ }
+ }
+ else {
+ // do combination based solely on z value but with antialiased mask
+ alpha = *acol;
+ malpha= 1.0f - alpha;
+
+ out[0]= malpha*col1[0] + alpha*col2[0];
+ out[1]= malpha*col1[1] + alpha*col2[1];
+ out[2]= malpha*col1[2] + alpha*col2[2];
+ out[3]= malpha*col1[3] + alpha*col2[3];
+ }
}
static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
@@ -107,11 +163,11 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in
*zval= in[1]->vec[0];
}
/* lazy coder hack */
- node->custom1= 1;
+ node->custom2= 1;
out[1]->data= zbuf;
}
else {
- node->custom1= 0;
+ node->custom2= 0;
zbuf= in[1]->data;
}