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:
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c86
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c174
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c43
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_crop.c9
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_defocus.c58
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_displace.c157
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c4
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c7
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_scale.c4
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c2
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_texture.c9
-rw-r--r--source/blender/nodes/intern/CMP_nodes/CMP_value.c2
-rw-r--r--source/blender/nodes/intern/CMP_nodes/Makefile2
13 files changed, 351 insertions, 206 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
index b081880b87b..e502129c3d3 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c
@@ -44,20 +44,38 @@ static bNodeSocketType cmp_node_chroma_out[]={
static void do_rgba_to_ycca_normalized(bNode *node, float *out, float *in)
{
- /*normalize to the range -1.0 to 1.0) */
- rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
- out[0]=((out[0])-16)/255.0;
- out[1]=((out[1])-128)/255.0;
- out[2]=((out[2])-128)/255.0;
+ rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
+
+ //normalize to 0..1.0
+ out[0]=out[0]/255.0;
+ out[1]=out[1]/255.0;
+ out[2]=out[2]/255.0;
+
+ //rescale to -1.0..1.0
+ out[0]=(out[0]*2.0)-1.0;
+ out[1]=(out[1]*2.0)-1.0;
+ out[2]=(out[2]*2.0)-1.0;
+
+// out[0]=((out[0])-16)/255.0;
+// out[1]=((out[1])-128)/255.0;
+// out[2]=((out[2])-128)/255.0;
out[3]=in[3];
}
static void do_ycca_to_rgba_normalized(bNode *node, float *out, float *in)
{
- /*un-normalize the normalize from above */
- in[0]=(in[0]*255.0)+16;
- in[1]=(in[1]*255.0)+128;
- in[2]=(in[2]*255.0)+128;
+ /*un-normalize the normalize from above */
+ in[0]=(in[0]+1.0)/2.0;
+ in[1]=(in[1]+1.0)/2.0;
+ in[2]=(in[2]+1.0)/2.0;
+
+ in[0]=(in[0]*255.0);
+ in[1]=(in[1]*255.0);
+ in[2]=(in[2]*255.0);
+
+// in[0]=(in[0]*255.0)+16;
+// in[1]=(in[1]*255.0)+128;
+// in[2]=(in[2]*255.0)+128;
ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601);
out[3]=in[3];
}
@@ -65,47 +83,41 @@ static void do_ycca_to_rgba_normalized(bNode *node, float *out, float *in)
static void do_chroma_key(bNode *node, float *out, float *in)
{
NodeChroma *c;
- float x, z, alpha;
- float theta, beta, angle;
- float kfg, newY, newCb, newCr;
+ float x, z, alpha;
+ float theta, beta, angle, angle2;
+ float kfg;
c=node->storage;
- /* Algorithm from book "Video Demistified" */
+ /* 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*/
- theta=atan2(c->key[2],c->key[1]);
+ theta=atan2(c->key[2], c->key[1]);
/*rotate the cb and cr into x/z space */
- x=in[1]*cos(theta)+in[2]*sin(theta);
- z=in[2]*cos(theta)-in[1]*sin(theta);
+ x=in[1]*cos(theta)+in[2]*sin(theta);
+ z=in[2]*cos(theta)-in[1]*sin(theta);
- /*if within the acceptance angle */
- angle=c->t1*M_PI/180.0; /* convert to radians */
+ /*if within the acceptance angle */
+ angle=c->t1*M_PI/180.0; /* convert to radians */
- /* if kfg is <0 then the pixel is outside of the key color */
- kfg=x-(fabs(z)/tan(angle/2.0));
+ /* if kfg is <0 then the pixel is outside of the key color */
+ kfg=x-(fabs(z)/tan(angle/2.0));
- if(kfg>0.0) { /* found a pixel that is within key color */
+ out[0]=in[0];
+ out[1]=in[1];
+ out[2]=in[2];
- newY=in[0]-(1-c->t3)*kfg;
- newCb=in[1]-kfg*cos((double)theta);
- newCr=in[2]-kfg*sin((double)theta);
- alpha=(kfg+c->fsize)*(c->fstrength);
+ if(kfg>0.0) { /* found a pixel that is within key color */
+ alpha=(1.0-kfg)*(c->fstrength);
- beta=atan2(newCr,newCb);
- beta=beta*180.0/M_PI; /* convert to degrees for compare*/
-
- /* if beta is within the clippin angle */
- if(fabs(beta)<(c->t2/2.0)) {
- newCb=0.0;
- newCr=0.0;
- alpha=0.0;
- }
+ beta=atan2(z,x);
+ angle2=c->t2*M_PI/180.0;
- out[0]=newY;
- out[1]=newCb;
- out[2]=newCr;
+ /* if beta is within the cutoff angle */
+ if(fabs(beta)<(angle2/2.0)) {
+ alpha=0.0;
+ }
/* don't make something that was more transparent less transparent */
if (alpha<in[3]) {
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c
index 54fb1e384c3..3191ad757a0 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c
@@ -34,7 +34,8 @@
/* ******************* Color Spill Supression ********************************* */
static bNodeSocketType cmp_node_color_spill_in[]={
- {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ {SOCK_VALUE, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{-1,0,""}
};
@@ -50,6 +51,14 @@ static void do_simple_spillmap_red(bNode *node, float* out, float *in)
out[0]=in[0]-( ncs->limscale * in[ncs->limchan] );
}
+static void do_simple_spillmap_red_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[0]-( ncs->limscale * in[ncs->limchan]));
+}
+
static void do_simple_spillmap_green(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
@@ -57,6 +66,14 @@ static void do_simple_spillmap_green(bNode *node, float* out, float *in)
out[0]=in[1]-( ncs->limscale * in[ncs->limchan] );
}
+static void do_simple_spillmap_green_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[1]-( ncs->limscale * in[ncs->limchan]));
+}
+
static void do_simple_spillmap_blue(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
@@ -64,6 +81,14 @@ static void do_simple_spillmap_blue(bNode *node, float* out, float *in)
out[0]=in[2]-( ncs->limscale * in[ncs->limchan] );
}
+static void do_simple_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[2]-( ncs->limscale * in[ncs->limchan]));
+}
+
static void do_average_spillmap_red(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
@@ -71,6 +96,14 @@ static void do_average_spillmap_red(bNode *node, float* out, float *in)
out[0]=in[0]-(ncs->limscale * avg(in[1], in[2]) );
}
+static void do_average_spillmap_red_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[0]-(ncs->limscale * avg(in[1], in[2]) ));
+}
+
static void do_average_spillmap_green(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
@@ -78,6 +111,14 @@ static void do_average_spillmap_green(bNode *node, float* out, float *in)
out[0]=in[1]-(ncs->limscale * avg(in[0], in[2]) );
}
+static void do_average_spillmap_green_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[2]) ));
+}
+
static void do_average_spillmap_blue(bNode *node, float* out, float *in)
{
NodeColorspill *ncs;
@@ -85,6 +126,14 @@ static void do_average_spillmap_blue(bNode *node, float* out, float *in)
out[0]=in[2]-(ncs->limscale * avg(in[0], in[1]) );
}
+static void do_average_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac)
+{
+ NodeColorspill *ncs;
+ ncs=node->storage;
+
+ out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[1]) ));
+}
+
static void do_apply_spillmap_red(bNode *node, float* out, float *in, float *map)
{
NodeColorspill *ncs;
@@ -109,7 +158,7 @@ static void do_apply_spillmap_green(bNode *node, float* out, float *in, float *m
out[0]=in[0]+(ncs->uspillr*map[0]);
out[1]=in[1]-(ncs->uspillg*map[0]);
out[2]=in[2]+(ncs->uspillb*map[0]);
- }
+ }
else {
out[0]=in[0];
out[1]=in[1];
@@ -125,7 +174,7 @@ static void do_apply_spillmap_blue(bNode *node, float* out, float *in, float *ma
out[0]=in[0]+(ncs->uspillr*map[0]);
out[1]=in[1]+(ncs->uspillg*map[0]);
out[2]=in[2]-(ncs->uspillb*map[0]);
- }
+ }
else {
out[0]=in[0];
out[1]=in[1];
@@ -138,16 +187,20 @@ static void node_composit_exec_color_spill(void *data, bNode *node, bNodeStack *
/*
Originally based on the information from the book "The Art and Science of Digital Composition" and
discussions from vfxtalk.com.*/
- CompBuf *cbuf;
+ CompBuf *cbuf;
+ CompBuf *mask;
CompBuf *rgbbuf;
CompBuf *spillmap;
NodeColorspill *ncs;
ncs=node->storage;
+
+ /* early out for missing connections */
+ if(out[0]->hasoutput==0 ) return;
+ if(in[0]->hasinput==0) return;
+ if(in[0]->data==NULL) return;
- if(out[0]->hasoutput==0 || in[0]->hasinput==0) return;
- if(in[0]->data==NULL) return;
-
- cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
+ cbuf=typecheck_compbuf(in[0]->data, CB_RGBA);
+ mask=typecheck_compbuf(in[1]->data, CB_VAL);
spillmap=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1);
rgbbuf=dupalloc_compbuf(cbuf);
@@ -157,14 +210,22 @@ static void node_composit_exec_color_spill(void *data, bNode *node, bNodeStack *
{
switch(node->custom2)
{
- case 0: /* simple limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA);
+ case 0: /* simple limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_red_fac, CB_RGBA, CB_VAL);
+ }
break;
}
- case 1: /* average limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA);
+ case 1: /* average limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_red_fac, CB_RGBA, CB_VAL);
+ }
break;
}
}
@@ -180,22 +241,30 @@ static void node_composit_exec_color_spill(void *data, bNode *node, bNodeStack *
{
switch(node->custom2)
{
- case 0: /* simple limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA);
- break;
- }
- case 1: /* average limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA);
- break;
- }
+ case 0: /* simple limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_green_fac, CB_RGBA, CB_VAL);
+ }
+ break;
+ }
+ case 1: /* average limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_green_fac, CB_RGBA, CB_VAL);
+ }
+ break;
+ }
}
if(ncs->unspill==0) {
ncs->uspillr=0.0f;
ncs->uspillg=1.0f;
ncs->uspillb=0.0f;
- }
+ }
composit2_pixel_processor(node, rgbbuf, cbuf, in[0]->vec, spillmap, NULL, do_apply_spillmap_green, CB_RGBA, CB_VAL);
break;
}
@@ -203,16 +272,24 @@ static void node_composit_exec_color_spill(void *data, bNode *node, bNodeStack *
{
switch(node->custom2)
{
- case 0: /* simple limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA);
- break;
- }
- case 1: /* average limit */
- {
- composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA);
- break;
- }
+ case 0: /* simple limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_blue_fac, CB_RGBA, CB_VAL);
+ }
+ break;
+ }
+ case 1: /* average limit */
+ {
+ if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) {
+ composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA);
+ } else {
+ composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_blue_fac, CB_RGBA, CB_VAL);
+ }
+ break;
+ }
}
if(ncs->unspill==0) {
ncs->uspillr=0.0f;
@@ -246,19 +323,18 @@ static void node_composit_init_color_spill(bNode *node)
}
bNodeType cmp_node_color_spill={
- /* *next,*prev */ NULL, NULL,
- /* type code */ CMP_NODE_COLOR_SPILL,
- /* name */ "Color Spill",
- /* width+range */ 140, 80, 200,
- /* class+opts */ NODE_CLASS_MATTE, NODE_OPTIONS,
- /* input sock */ cmp_node_color_spill_in,
- /* output sock */ cmp_node_color_spill_out,
- /* storage */ "NodeColorspill",
- /* execfunc */ node_composit_exec_color_spill,
- /* butfunc */ NULL,
- /* initfunc */ node_composit_init_color_spill,
- /* freestoragefunc */ node_free_standard_storage,
- /* copystoragefunc */ node_copy_standard_storage,
- /* id */ NULL
+ /* *next,*prev */ NULL, NULL,
+ /* type code */ CMP_NODE_COLOR_SPILL,
+ /* name */ "Color Spill",
+ /* width+range */ 140, 80, 200,
+ /* class+opts */ NODE_CLASS_MATTE, NODE_OPTIONS,
+ /* input sock */ cmp_node_color_spill_in,
+ /* output sock */ cmp_node_color_spill_out,
+ /* storage */ "NodeColorspill",
+ /* execfunc */ node_composit_exec_color_spill,
+ /* butfunc */ NULL,
+ /* initfunc */ node_composit_init_color_spill,
+ /* freestoragefunc */ node_free_standard_storage,
+ /* copystoragefunc */ node_copy_standard_storage,
};
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
index b40b27e06ee..43c6c6d791e 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c
@@ -54,14 +54,19 @@ DO_INLINE float colorbalance_cdl(float in, float offset, float power, float slop
return powf(x, 1.f/power);
}
-DO_INLINE float colorbalance_lgg(float in, float lift, float gamma, float gain)
+/* note: lift_lgg is just 2-lift, gamma_inv is 1.0/gamma */
+DO_INLINE float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float gain)
{
- float x = gain*(in+(lift-1)*(1-in));
-
+ /* 1:1 match with the sequencer with linear/srgb conversions, the conversion isnt pretty
+ * but best keep it this way, sice testing for durian shows a similar calculation
+ * without lin/srgb conversions gives bad results (over-saturated shadows) with colors
+ * slightly below 1.0. some correction can be done but it ends up looking bad for shadows or lighter tones - campbell */
+ float x= (((linearrgb_to_srgb(in) - 1.0f) * lift_lgg) + 1.0f) * gain;
+
/* prevent NaN */
if (x < 0.f) x = 0.f;
-
- return powf(x, (1.f/gamma));
+
+ return powf(srgb_to_linearrgb(x), gamma_inv);
}
static void do_colorbalance_cdl(bNode *node, float* out, float *in)
@@ -88,10 +93,10 @@ static void do_colorbalance_cdl_fac(bNode *node, float* out, float *in, float *f
static void do_colorbalance_lgg(bNode *node, float* out, float *in)
{
NodeColorBalance *n= (NodeColorBalance *)node->storage;
-
- out[0] = colorbalance_lgg(in[0], n->lift[0], n->gamma[0], n->gain[0]);
- out[1] = colorbalance_lgg(in[1], n->lift[1], n->gamma[1], n->gain[1]);
- out[2] = colorbalance_lgg(in[2], n->lift[2], n->gamma[2], n->gain[2]);
+
+ out[0] = colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma_inv[0], n->gain[0]);
+ out[1] = colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma_inv[1], n->gain[1]);
+ out[2] = colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma_inv[2], n->gain[2]);
out[3] = in[3];
}
@@ -99,10 +104,10 @@ static void do_colorbalance_lgg_fac(bNode *node, float* out, float *in, float *f
{
NodeColorBalance *n= (NodeColorBalance *)node->storage;
const float mfac= 1.0f - *fac;
-
- out[0] = mfac*in[0] + *fac * colorbalance_lgg(in[0], n->lift[0], n->gamma[0], n->gain[0]);
- out[1] = mfac*in[1] + *fac * colorbalance_lgg(in[1], n->lift[1], n->gamma[1], n->gain[1]);
- out[2] = mfac*in[2] + *fac * colorbalance_lgg(in[2], n->lift[2], n->gamma[2], n->gain[2]);
+
+ out[0] = mfac*in[0] + *fac * colorbalance_lgg(in[0], n->lift_lgg[0], n->gamma_inv[0], n->gain[0]);
+ out[1] = mfac*in[1] + *fac * colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma_inv[1], n->gain[1]);
+ out[2] = mfac*in[2] + *fac * colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma_inv[2], n->gain[2]);
out[3] = in[3];
}
@@ -119,7 +124,17 @@ static void node_composit_exec_colorbalance(void *data, bNode *node, bNodeStack
out[0]->data = pass_on_compbuf(cbuf);
return;
}
-
+
+ {
+ NodeColorBalance *n= (NodeColorBalance *)node->storage;
+ int c;
+
+ for (c = 0; c < 3; c++) {
+ n->lift_lgg[c] = 2.0f - n->lift[c];
+ n->gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f/n->gamma[c] : 1000000.0f;
+ }
+ }
+
if (cbuf) {
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* create output based on image input */
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_crop.c b/source/blender/nodes/intern/CMP_nodes/CMP_crop.c
index c2edb3dd52f..dd5ce88bd36 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_crop.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_crop.c
@@ -48,7 +48,14 @@ static void node_composit_exec_crop(void *data, bNode *node, bNodeStack **in, bN
CompBuf *stackbuf;
int x, y;
float *srcfp, *outfp;
- rcti outputrect;
+ rcti outputrect;
+
+ if(node->custom2) {
+ ntxy->x1= cbuf->x* ntxy->fac_x1;
+ ntxy->x2= cbuf->x* ntxy->fac_x2;
+ ntxy->y1= cbuf->y* ntxy->fac_y1;
+ ntxy->y2= cbuf->y* ntxy->fac_y2;
+ }
/* check input image size */
if(cbuf->x <= ntxy->x1 + 1)
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
index 4c515df34fb..a93a5760842 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c
@@ -242,11 +242,9 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
CompBuf *crad; // CoC radius buffer
BokehCoeffs BKH[8]; // bokeh shape data, here never > 8 pts.
float bkh_b[4] = {0}; // shape 2D bound
- unsigned int p, px, p4, zp, cp, cp4;
- float *ctcol, u, v, iZ, ct_crad, lwt, wt=0, cR2=0;
- float dof_sp, maxfgc, bk_hn_theta=0, inradsq=0;
float cam_fdist=1, cam_invfdist=1, cam_lens=35;
- int x, y, sx, sy, len_bkh=0;
+ float dof_sp, maxfgc, bk_hn_theta=0, inradsq=0;
+ int y, len_bkh=0, ydone=0;
float aspect, aperture;
int minsz;
//float bcrad, nmaxc, scf;
@@ -288,6 +286,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// to prevent *reaaallly* big radius values and impossible calculation times,
// limit the maximum to half the image width or height, whichever is smaller
float maxr = 0.5f*(float)MIN2(img->x, img->y);
+ unsigned int p;
+
for (p=0; p<(unsigned int)(img->x*img->y); p++) {
crad->rect[p] = zbuf ? (zbuf->rect[p]*nqd->scale) : inpval;
// bug #5921, limit minimum
@@ -298,6 +298,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
}
}
else {
+ float wt;
+
// actual zbuffer.
// separate foreground from background CoC's
// then blur background and blend in again with foreground,
@@ -305,10 +307,11 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// wts buffer here used for blendmask
maxfgc = 0.f; // maximum foreground CoC radius
for (y=0; y<img->y; y++) {
- p = y * img->x;
+ unsigned int p = y * img->x;
+ int x;
for (x=0; x<img->x; x++) {
- px = p + x;
- iZ = (zbuf->rect[px]==0.f) ? 0.f : (1.f/zbuf->rect[px]);
+ unsigned int px = p + x;
+ float iZ = (zbuf->rect[px]==0.f) ? 0.f : (1.f/zbuf->rect[px]);
crad->rect[px] = 0.5f*(aperture*(dof_sp*(cam_invfdist - iZ) - 1.f));
if (crad->rect[px] <= 0.f) {
wts->rect[px] = 1.f;
@@ -342,11 +345,13 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// and blend...
for (y=0; y<img->y; y++) {
- p = y*img->x;
+ unsigned int p = y*img->x;
+ int x;
+
for (x=0; x<img->x; x++) {
- px = p + x;
+ unsigned px = p + x;
if (zbuf->rect[px]!=0.f) {
- iZ = (zbuf->rect[px]==0.f) ? 0.f : (1.f/zbuf->rect[px]);
+ float iZ = (zbuf->rect[px]==0.f) ? 0.f : (1.f/zbuf->rect[px]);
// bug #6656 part 2b, do not rescale
/*
@@ -373,18 +378,30 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
//------------------------------------------------------------------
// main loop
+ #pragma omp parallel for private(y) if(!nqd->preview && img->y*img->x > 16384) schedule(guided)
for (y=0; y<img->y; y++) {
+ unsigned int p, p4, zp, cp, cp4;
+ float *ctcol, u, v, ct_crad, cR2=0;
+ int x, sx, sy;
+
// some sort of visual feedback would be nice, or at least this text in the renderwin header
// but for now just print some info in the console every 8 scanlines.
- if (((y & 7)==0) || (y==(img->y-1))) {
- if(G.background==0) {
- printf("\rdefocus: Processing Line %d of %d ... ", y+1, img->y);
- fflush(stdout);
+ #pragma omp critical
+ {
+ if (((ydone & 7)==0) || (ydone==(img->y-1))) {
+ if(G.background==0) {
+ printf("\rdefocus: Processing Line %d of %d ... ", ydone+1, img->y);
+ fflush(stdout);
+ }
}
+
+ ydone++;
}
- // esc set by main calling process
+
+ // esc set by main calling process. don't break because openmp doesn't
+ // allow it, just continue and do nothing
if(node->exec & NODE_BREAK)
- break;
+ continue;
zp = y * img->x;
for (x=0; x<img->x; x++) {
@@ -412,6 +429,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
if (!nqd->preview) {
int xs, xe, ys, ye;
float lwt, wtcol[4] = {0}, aacol[4] = {0};
+ float wt;
// shape weight
if (nqd->bktype==0) // disk
@@ -700,7 +718,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
else {
// sampled, simple rejection sampling here, good enough
unsigned int maxsam, s, ui = BLI_rand()*BLI_rand();
- float wcor, cpr = BLI_frand();
+ float wcor, cpr = BLI_frand(), lwt;
if (no_zbuf)
maxsam = nqd->samples; // no zbuffer input, use sample value directly
else {
@@ -749,8 +767,10 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf,
// finally, normalize
for (y=0; y<new->y; y++) {
- p = y * new->x;
- p4 = p * new->type;
+ unsigned int p = y * new->x;
+ unsigned int p4 = p * new->type;
+ int x;
+
for (x=0; x<new->x; x++) {
float dv = (wts->rect[p]==0.f) ? 1.f : (1.f/wts->rect[p]);
new->rect[p4] *= dv;
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
index 877f71bfbfb..7d64d4e719c 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c
@@ -44,94 +44,96 @@ static bNodeSocketType cmp_node_displace_out[]= {
{ -1, 0, "" }
};
-static float *vecbuf_get_pixel(CompBuf *vecbuf, float *veccol, int x, int y)
-{
- /* the x-xrad stuff is a bit weird, but i seem to need it otherwise
- * my returned pixels are offset weirdly */
- return compbuf_get_pixel(vecbuf, veccol, x-vecbuf->xrad, y-vecbuf->yrad, vecbuf->xrad, vecbuf->yrad);
-}
+/* minimum distance (in pixels) a pixel has to be displaced
+ * in order to take effect */
+#define DISPLACE_EPSILON 0.01
-static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *veccol, float *xscale, float *yscale)
+static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *veccol, CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale)
{
ImBuf *ibuf;
- float dx=0.0, dy=0.0;
- float dspx, dspy;
- float uv[2], col[4], colnext[4], colprev[4];
- float *vp, *vpnext, *vpprev;
- float *out= stackbuf->rect, *vec=vecbuf->rect, *in= cbuf->rect;
- int x, y, vx, vy, sx, sy;
+ int x, y;
+ float p_dx, p_dy; /* main displacement in pixel space */
+ float d_dx, d_dy;
+ float dxt, dyt;
+ float u, v;
+ float xs, ys;
+ float vec[3], vecdx[3], vecdy[3];
+ float col[3];
- /* ibuf needed for sampling */
ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0, 0);
ibuf->rect_float= cbuf->rect;
- vec = vecbuf->rect;
-
- sx= stackbuf->x;
- sy= stackbuf->y;
-
- QUATCOPY(col, veccol);
- QUATCOPY(colnext, veccol);
- QUATCOPY(colprev, veccol);
-
- for(y=0; y<sy; y++) {
- for(x= 0; x< sx; x++, out+=4, in+=4, vec+=3) {
+ for(y=0; y < stackbuf->y; y++) {
+ for(x=0; x < stackbuf->x; x++) {
+ /* calc pixel coordinates */
+ qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof, vec);
- vp = vecbuf_get_pixel(vecbuf, col, x, y);
-
- /* this happens in compbuf_get_pixel, need to make sure the following
- * check takes them into account */
- vx= x-vecbuf->xof;
- vy= y-vecbuf->yof;
+ if (xbuf)
+ qd_getPixel(xbuf, x-xbuf->xof, y-xbuf->yof, &xs);
+ else
+ xs = xscale[0];
- /* find the new displaced co-ords, also correcting for translate offset */
- dspx = vx - (*xscale * vp[0]);
- dspy = vy - (*yscale * vp[1]);
-
- /* convert image space to 0.0-1.0 UV space for sampling, correcting for translate offset */
- uv[0] = dspx / (float)sx;
- uv[1] = dspy / (float)sy;
-
- if(vx>0 && vx< vecbuf->x-1 && vy>0 && vy< vecbuf->y-1) {
- /* adaptive sampling, X and Y channel.
- * we call vecbuf_get_pixel for every pixel since the input
- * might be a procedural, and then we can't use offsets */
- vpprev = vecbuf_get_pixel(vecbuf, colprev, x-1, y);
- vpnext = vecbuf_get_pixel(vecbuf, colnext, x+1, y);
- dx= 0.5f*(fabs(vp[0]-vpprev[0]) + fabs(vp[0]-vpnext[0]));
-
- vpprev = vecbuf_get_pixel(vecbuf, colprev, x, y-1);
- vpnext = vecbuf_get_pixel(vecbuf, colnext, x, y+1);
- dy= 0.5f*(fabs(vp[1]-vpnext[1]) + fabs(vp[1]-vpprev[1]));
+ if (ybuf)
+ qd_getPixel(ybuf, x-ybuf->xof, y-ybuf->yof, &ys);
+ else
+ ys = yscale[0];
- vpprev = vecbuf_get_pixel(vecbuf, colprev, x-1, y-1);
- vpnext = vecbuf_get_pixel(vecbuf, colnext, x-1, y+1);
- dx+= 0.25f*(fabs(vp[0]-vpprev[0]) + fabs(vp[0]-vpnext[0]));
- dy+= 0.25f*(fabs(vp[1]-vpprev[1]) + fabs(vp[1]-vpnext[1]));
-
- vpprev = vecbuf_get_pixel(vecbuf, colprev, x+1, y-1);
- vpnext = vecbuf_get_pixel(vecbuf, colnext, x+1, y+1);
- dx+= 0.25f*(fabs(vp[0]-vpprev[0]) + fabs(vp[0]-vpnext[0]));
- dy+= 0.25f*(fabs(vp[1]-vpprev[1]) + fabs(vp[1]-vpnext[1]));
-
- /* scaled down to prevent blurriness */
- /* 8: magic number, provides a good level of sharpness without getting too aliased */
- dx /= 8;
- dy /= 8;
+
+ p_dx = vec[0] * xs;
+ p_dy = vec[1] * ys;
+
+ /* if no displacement, then just copy this pixel */
+ if (p_dx < DISPLACE_EPSILON && p_dy < DISPLACE_EPSILON) {
+ qd_getPixel(cbuf, x-cbuf->xof, y-cbuf->yof, col);
+ qd_setPixel(stackbuf, x, y, col);
+ continue;
}
-
- /* should use mipmap */
- if(dx > 0.006f) dx= 0.006f;
- if(dy > 0.006f) dy= 0.006f;
- if ((vp[0]> 0.0) && (dx < 0.004)) dx = 0.004;
- if ((vp[1]> 0.0) && (dy < 0.004)) dy = 0.004;
-
- ibuf_sample(ibuf, uv[0], uv[1], dx, dy, out);
+ /* displaced pixel in uv coords, for image sampling */
+ u = (x - cbuf->xof - p_dx + 0.5f) / (float)stackbuf->x;
+ v = (y - cbuf->yof - p_dy + 0.5f) / (float)stackbuf->y;
+
+
+ /* calc derivatives */
+ qd_getPixel(vecbuf, x-vecbuf->xof+1, y-vecbuf->yof, vecdx);
+ qd_getPixel(vecbuf, x-vecbuf->xof, y-vecbuf->yof+1, vecdy);
+ d_dx = vecdx[0] * xs;
+ d_dy = vecdy[0] * ys;
+
+ /* clamp derivatives to minimum displacement distance in UV space */
+ dxt = MAX2(p_dx - d_dx, DISPLACE_EPSILON)/(float)stackbuf->x;
+ dyt = MAX2(p_dy - d_dy, DISPLACE_EPSILON)/(float)stackbuf->y;
+
+ ibuf_sample(ibuf, u, v, dxt, dyt, col);
+ qd_setPixel(stackbuf, x, y, col);
}
}
-
- IMB_freeImBuf(ibuf);
+ IMB_freeImBuf(ibuf);
+
+
+/* simple method for reference, linear interpolation */
+/*
+ int x, y;
+ float dx, dy;
+ float u, v;
+ float vec[3];
+ float col[3];
+
+ for(y=0; y < stackbuf->y; y++) {
+ for(x=0; x < stackbuf->x; x++) {
+ qd_getPixel(vecbuf, x, y, vec);
+
+ dx = vec[0] * (xscale[0]);
+ dy = vec[1] * (yscale[0]);
+
+ u = (x - dx + 0.5f) / (float)stackbuf->x;
+ v = (y - dy + 0.5f) / (float)stackbuf->y;
+
+ qd_getPixelLerp(cbuf, u*cbuf->x - 0.5f, v*cbuf->y - 0.5f, col);
+ qd_setPixel(stackbuf, x, y, col);
+ }
+ }
+*/
}
@@ -143,13 +145,18 @@ static void node_composit_exec_displace(void *data, bNode *node, bNodeStack **in
if(in[0]->data && in[1]->data) {
CompBuf *cbuf= in[0]->data;
CompBuf *vecbuf= in[1]->data;
+ CompBuf *xbuf= in[2]->data;
+ CompBuf *ybuf= in[3]->data;
CompBuf *stackbuf;
cbuf= typecheck_compbuf(cbuf, CB_RGBA);
vecbuf= typecheck_compbuf(vecbuf, CB_VEC3);
+ xbuf= typecheck_compbuf(xbuf, CB_VAL);
+ ybuf= typecheck_compbuf(ybuf, CB_VAL);
+
stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */
- do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, in[2]->vec, in[3]->vec);
+ do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec);
out[0]->data= stackbuf;
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c b/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
index 58850cf3568..9eb79bb8c36 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c
@@ -60,7 +60,6 @@ static void do_huecorrect(bNode *node, float *out, float *in)
CLAMP(hsv[0], 0.f, 1.f);
CLAMP(hsv[1], 0.f, 1.f);
- CLAMP(hsv[2], 0.f, 1.f);
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2);
@@ -89,7 +88,6 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac)
CLAMP(hsv[0], 0.f, 1.f);
CLAMP(hsv[1], 0.f, 1.f);
- CLAMP(hsv[2], 0.f, 1.f);
/* convert back to rgb */
hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2);
@@ -143,7 +141,7 @@ static void node_composit_init_huecorrect(bNode* node)
for (c=0; c<3; c++) {
CurveMap *cuma = &cumapping->cm[c];
- curvemap_reset(cuma, &cumapping->clipr, cumapping->preset);
+ curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
}
/* default to showing Saturation */
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c
index d2eb27d13c6..6f29548fcc3 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c
@@ -47,7 +47,12 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack *
if(nif->sfra!=nif->efra && (rd->cfra<nif->sfra || rd->cfra>nif->efra)) {
return; /* BAIL OUT RETURN */
}
- else {
+ else if (!G.rendering) {
+ /* only output files when rendering a sequence -
+ * otherwise, it overwrites the output files just
+ * scrubbing through the timeline when the compositor updates */
+ return;
+ } else {
CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf= IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0, 0);
char string[256];
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_scale.c b/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
index d7a9497f41d..9779875b01a 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_scale.c
@@ -64,6 +64,10 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b
else if(node->custom1==CMP_SCALE_SCENEPERCENT) {
newx = cbuf->x * (rd->size / 100.0f);
newy = cbuf->y * (rd->size / 100.0f);
+ }
+ else if (node->custom1==CMP_SCALE_RENDERPERCENT) {
+ newx= (rd->xsch * rd->size)/100;
+ newy= (rd->ysch * rd->size)/100;
} else { /* CMP_SCALE_ABSOLUTE */
newx= MAX2((int)in[1]->vec[0], 1);
newy= MAX2((int)in[2]->vec[0], 1);
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
index d80dd9b0a4b..0ac47c58ab3 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c
@@ -64,7 +64,7 @@ static void node_composit_exec_sephsva(void *data, bNode *node, bNodeStack **in,
if(in[0]->data==NULL) {
float h, s, v;
- rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v);
+ rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v);
out[0]->vec[0] = h;
out[1]->vec[0] = s;
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c
index b130b3f38a8..f990fa452cb 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_texture.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_texture.c
@@ -95,10 +95,11 @@ static void node_composit_exec_texture(void *data, bNode *node, bNodeStack **in,
/* first make the preview image */
CompBuf *prevbuf= alloc_compbuf(140, 140, CB_RGBA, 1); /* alloc */
-
- sizex = rd->xsch;
- sizey = rd->ysch;
-
+
+ /* Also take care about the render size! */
+ sizex = (rd->size*rd->xsch)/100;
+ sizey = (rd->size*rd->ysch)/100;
+
prevbuf->rect_procedural= texture_procedural;
prevbuf->node= node;
VECCOPY(prevbuf->procedural_offset, in[0]->vec);
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_value.c b/source/blender/nodes/intern/CMP_nodes/CMP_value.c
index 576fb37dc45..14a3b6fe15c 100644
--- a/source/blender/nodes/intern/CMP_nodes/CMP_value.c
+++ b/source/blender/nodes/intern/CMP_nodes/CMP_value.c
@@ -31,7 +31,7 @@
/* **************** VALUE ******************** */
static bNodeSocketType cmp_node_value_out[]= {
- { SOCK_VALUE, 0, "Value", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
+ { SOCK_VALUE, 0, "Value", 0.5f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f},
{ -1, 0, "" }
};
diff --git a/source/blender/nodes/intern/CMP_nodes/Makefile b/source/blender/nodes/intern/CMP_nodes/Makefile
index 5e8753570af..5e97864fb95 100644
--- a/source/blender/nodes/intern/CMP_nodes/Makefile
+++ b/source/blender/nodes/intern/CMP_nodes/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
# All rights reserved.