diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-05 18:29:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-05 18:29:16 +0400 |
commit | b1cdc52b30f709848c7f30eb077d6d5c20c43428 (patch) | |
tree | e10cef4273add6fcd21cb85ce2726825a30021cb /source | |
parent | d89d1aa09810a95fe2968a76393a102fabe8a146 (diff) |
Color Balance Node
changes from sequencer applied to compositor mostly noticable is how the lift works.
Before & After,
http://www.graphicall.org/ftp/ideasman42/color_balance_before_after.png
even with lower values these kinds of errors can be seen.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/sequencer.c | 7 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_sequence_types.h | 4 | ||||
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c | 30 |
4 files changed, 27 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 2f25c24272e..fa2c11f3395 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1525,13 +1525,12 @@ static StripColorBalance calc_cb(StripColorBalance * cb_) return cb; } -/* compiler should inline */ -MINLINE float color_balance_fl(float v, float lift, float gain, float gamma, float mul) +/* pow(p[c] * cb.gain[c] + cb.lift[c], cb.gamma[c]) * mul;*/ +MINLINE float color_balance_fl(const float v, const float lift, const float gain, const float gamma, const float mul) { - return pow(pow(v * gain, lift), gamma) * mul; + return powf(powf(v * gain, lift), gamma) * mul; } - static void make_cb_table_byte(float lift, float gain, float gamma, unsigned char * table, float mul) { diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 9cbd304a86d..872d69f3148 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -311,6 +311,9 @@ typedef struct NodeColorBalance { float lift[3]; float gamma[3]; float gain[3]; + + /* temp storage for inverted lift */ + float lift_lgg[3]; } NodeColorBalance; typedef struct NodeColorspill { diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 4530e91910b..f5ca32c6b32 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -72,8 +72,8 @@ typedef struct StripColorBalance { float gain[3]; int flag; int pad; - float exposure; - float saturation; + // float exposure; + // float saturation; } StripColorBalance; typedef struct StripProxy { diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c index b40b27e06ee..f2e5815dfeb 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c @@ -56,8 +56,8 @@ DO_INLINE float colorbalance_cdl(float in, float offset, float power, float slop DO_INLINE float colorbalance_lgg(float in, float lift, float gamma, float gain) { - float x = gain*(in+(lift-1)*(1-in)); - + float x= powf(in * gain, lift); + /* prevent NaN */ if (x < 0.f) x = 0.f; @@ -88,10 +88,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[0], n->gain[0]); + out[1] = colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma[1], n->gain[1]); + out[2] = colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma[2], n->gain[2]); out[3] = in[3]; } @@ -99,10 +99,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[0], n->gain[0]); + out[1] = mfac*in[1] + *fac * colorbalance_lgg(in[1], n->lift_lgg[1], n->gamma[1], n->gain[1]); + out[2] = mfac*in[2] + *fac * colorbalance_lgg(in[2], n->lift_lgg[2], n->gamma[2], n->gain[2]); out[3] = in[3]; } @@ -119,7 +119,15 @@ 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 - pow(n->lift[c], 2); + } + } + if (cbuf) { stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* create output based on image input */ |