Page MenuHome

nodeFix.patch

nodeFix.patch

Index: source/blender/nodes/composite/nodes/node_composite_distanceMatte.c
===================================================================
--- source/blender/nodes/composite/nodes/node_composite_distanceMatte.c (revision 45348)
+++ source/blender/nodes/composite/nodes/node_composite_distanceMatte.c (working copy)
@@ -51,7 +51,9 @@
{
NodeChroma *c= (NodeChroma *)node->storage;
float tolerence=c->t1;
- float falloff=c->t2;
+ float fper=c->t2;
+ /* get falloff amount in pixels */
+ float falloff=(1.0f-fper) * tolerence;
float distance;
float alpha;
@@ -61,22 +63,26 @@
copy_v3_v3(out, in);
- /*make 100% transparent */
- if (distance < tolerence) {
- out[3]=0.0;
+ if (distance <= tolerence) {
+ if(distance<=falloff) {
+ alpha=0.0f;
+ }
+ else{
+ /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/
+ alpha=(distance-falloff)/(tolerence-falloff);
+ }
+
+ /*only change if more transparent than before */
+ if (alpha < in[3]) {
+ /*clamp*/
+ if(alpha<0.0f) alpha=0.0f;
+ if(alpha>1.0f) alpha=1.0f;
+ out[3]=alpha;
+ }
+ else { /* leave as before */
+ out[3]=in[3];
+ }
}
- /*in the falloff region, make partially transparent */
- else if (distance < falloff+tolerence) {
- distance=distance-tolerence;
- alpha=distance/falloff;
- /*only change if more transparent than before */
- if (alpha < in[3]) {
- out[3]=alpha;
- }
- else { /* leave as before */
- out[3]=in[3];
- }
- }
else {
out[3]=in[3];
}
Index: source/blender/nodes/composite/nodes/node_composite_diffMatte.c
===================================================================
--- source/blender/nodes/composite/nodes/node_composite_diffMatte.c (revision 45348)
+++ source/blender/nodes/composite/nodes/node_composite_diffMatte.c (working copy)
@@ -49,39 +49,42 @@
{
NodeChroma *c= (NodeChroma *)node->storage;
float tolerence=c->t1;
- float falloff=c->t2;
+ float fper=c->t2;
+ /* get falloff amount in pixels */
+ float falloff=(1.0f-fper)*tolerence;
float difference;
float alpha;
+ float maxInputAlpha;
+ /*average together the distances*/
difference= fabs(inColor2[0]-inColor1[0]) +
fabs(inColor2[1]-inColor1[1]) +
- fabs(inColor2[2]-inColor1[2]);
+ fabs(inColor2[2]-inColor1[2]);
+ difference=difference/3.0f;
- /*average together the distances*/
- difference=difference/3.0f;
-
copy_v3_v3(outColor, inColor1);
- /*make 100% transparent*/
- if (difference < tolerence) {
- outColor[3]=0.0;
- }
- /*in the falloff region, make partially transparent */
- else if (difference < falloff+tolerence) {
- difference=difference-tolerence;
- alpha=difference/falloff;
- /*only change if more transparent than before */
- if (alpha < inColor1[3]) {
- outColor[3]=alpha;
- }
- else { /* leave as before */
- outColor[3]=inColor1[3];
- }
- }
- else {
- /*foreground object*/
- outColor[3]= inColor1[3];
- }
+ if (difference <= tolerence) {
+ if(difference<=falloff) {
+ alpha=0.0f;
+ }
+ else{
+ /* alpha as percent (distance / tolerance), each modified by falloff amount (in pixels)*/
+ alpha=(difference-falloff)/(tolerence-falloff);
+ }
+
+ /*only change if more transparent than either image */
+ maxInputAlpha=maxf(inColor1[3], inColor2[3]);
+ if (alpha < maxInputAlpha) {
+ /*clamp*/
+ if(alpha<0.0f) alpha=0.0f;
+ if(alpha>1.0f) alpha=1.0f;
+ outColor[3]=alpha;
+ }
+ else { /* leave as before */
+ outColor[3]=maxInputAlpha;
+ }
+ }
}
static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
Index: source/blender/nodes/composite/nodes/node_composite_chromaMatte.c
===================================================================
--- source/blender/nodes/composite/nodes/node_composite_chromaMatte.c (revision 45348)
+++ source/blender/nodes/composite/nodes/node_composite_chromaMatte.c (working copy)
@@ -20,7 +20,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): Bob Holcomb
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -94,7 +94,7 @@
/* Algorithm from book "Video Demistified," does not include the spill reduction part */
- /* find theta, the angle that the color space should be rotated based on key*/
+ /* find theta, the angle that the color space should be rotated based on key chroma values*/
theta=atan2(c->key[2], c->key[1]);
/*rotate the cb and cr into x/z space */
@@ -102,27 +102,26 @@
z=in[2]*cosf(theta)-in[1]*sinf(theta);
/*if within the acceptance angle */
- angle=c->t1; /* t1 is radians. */
+ angle=c->t1; /* t1 is radians. */
/* if kfg is <0 then the pixel is outside of the key color */
- kfg= x-(fabsf(z)/tanf(angle/2.0f));
+ kfg= x-(fabsf(z)/tanf(angle/2.0f));
- out[0]=in[0];
- out[1]=in[1];
- out[2]=in[2];
+ copy_v3_v3(out, in);
- if (kfg>0.0f) { /* found a pixel that is within key color */
- alpha=(1.0f-kfg)*(c->fstrength);
+ if (kfg>=0.0f) { /* found a pixel that is within key color */
+ beta=atan2(z,x);
+ angle2=c->t2; /* t2 is radians. */
- beta=atan2(z,x);
- angle2=c->t2; /* t2 is radians. */
+ /* if beta is within the cutoff angle */
+ if (fabsf(beta) < (angle2/2.0f)) {
+ alpha=0.0;
+ }
+ else {
+ alpha=1.0f-(kfg/c->fstrength);
+ }
- /* if beta is within the cutoff angle */
- if (fabsf(beta) < (angle2/2.0f)) {
- alpha=0.0;
- }
-
- /* don't make something that was more transparent less transparent */
+ /* don't make something that was more transparent less transparent */
if (alpha<in[3]) {
out[3]=alpha;
}
@@ -130,11 +129,8 @@
out[3]=in[3];
}
}
- else { /*pixel is outside key color */
- out[0]=in[0];
- out[1]=in[1];
- out[2]=in[2];
- out[3]=in[3]; /* make pixel just as transparent as it was before */
+ else { /* make pixel just as transparent as it was before */
+ out[3]=in[3];
}
}
Index: source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- source/blender/makesrna/intern/rna_nodetree.c (revision 45345)
+++ source/blender/makesrna/intern/rna_nodetree.c (working copy)
@@ -328,6 +328,39 @@
chroma->t2 = value;
}
+
+static void rna_distance_matte_t1_set(PointerRNA *ptr, float value)
+{
+ bNode *node = (bNode*)ptr->data;
+ NodeChroma *chroma = node->storage;
+
+ chroma->t1 = value;
+}
+
+static void rna_distance_matte_t2_set(PointerRNA *ptr, float value)
+{
+ bNode *node = (bNode*)ptr->data;
+ NodeChroma *chroma = node->storage;
+
+ chroma->t2 = value;
+}
+
+static void rna_difference_matte_t1_set(PointerRNA *ptr, float value)
+{
+ bNode *node = (bNode*)ptr->data;
+ NodeChroma *chroma = node->storage;
+
+ chroma->t1 = value;
+}
+
+static void rna_difference_matte_t2_set(PointerRNA *ptr, float value)
+{
+ bNode *node = (bNode*)ptr->data;
+ NodeChroma *chroma = node->storage;
+
+ chroma->t2 = value;
+}
+
static void rna_Node_scene_set(PointerRNA *ptr, PointerRNA value)
{
bNode *node = (bNode*)ptr->data;
@@ -1885,14 +1918,14 @@
prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
- RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
+ RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t1_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
- RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
+ RNA_def_property_float_funcs(prop, NULL, "rna_difference_matte_t2_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
@@ -1931,14 +1964,14 @@
prop = RNA_def_property(srna, "tolerance", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t1");
- RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t1_set", NULL);
+ RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t1_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Tolerance", "Color distances below this threshold are keyed");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t2");
- RNA_def_property_float_funcs(prop, NULL, "rna_Matte_t2_set", NULL);
+ RNA_def_property_float_funcs(prop, NULL, "rna_distance_matte_t2_set", NULL);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Falloff", "Color distances below this additional threshold are partially keyed");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
@@ -2062,17 +2095,17 @@
RNA_def_property_ui_text(prop, "Lift", "Alpha lift");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
- prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
- RNA_def_property_float_sdna(prop, NULL, "fstrength");
+ prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "fstrength");
RNA_def_property_range(prop, 0.0f, 1.0f);
- RNA_def_property_ui_text(prop, "Gain", "Alpha gain");
+ RNA_def_property_ui_text(prop, "Falloff", "Alpha falloff");
RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
- prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE);
+ prop = RNA_def_property(srna, "shadow_adjust", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "t3");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Shadow Adjust", "Adjusts the brightness of any shadows captured");
- RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
}
static void def_cmp_channel_matte(StructRNA *srna)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
31/28/435f2cb54c205752b96b324ceeb3

Event Timeline