diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-31 14:03:08 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-31 14:03:08 +0400 |
commit | 667a2cafbe91d93f1c5d409da58cf5d83a0ab15b (patch) | |
tree | b4040467871ea1fe196dc16d1e4c7e2d5c2ad906 /source/blender/nodes/intern/CMP_nodes | |
parent | 1280b6f9024de7c7a3d67cd2dfb80820164bc802 (diff) |
recent commit to make color balance work like the sequencer, I forgot that the gamma was inverted. fixed.
Diffstat (limited to 'source/blender/nodes/intern/CMP_nodes')
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c index 843daa49a5b..43c6c6d791e 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorbalance.c @@ -54,8 +54,8 @@ DO_INLINE float colorbalance_cdl(float in, float offset, float power, float slop return powf(x, 1.f/power); } -/* note: lift_lgg is just 2-lift */ -DO_INLINE float colorbalance_lgg(float in, float lift_lgg, 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) { /* 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 @@ -66,7 +66,7 @@ DO_INLINE float colorbalance_lgg(float in, float lift_lgg, float gamma, float ga /* prevent NaN */ if (x < 0.f) x = 0.f; - return powf(srgb_to_linearrgb(x), gamma); + return powf(srgb_to_linearrgb(x), gamma_inv); } static void do_colorbalance_cdl(bNode *node, float* out, float *in) @@ -94,9 +94,9 @@ static void do_colorbalance_lgg(bNode *node, float* out, float *in) { NodeColorBalance *n= (NodeColorBalance *)node->storage; - 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[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]; } @@ -105,9 +105,9 @@ 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_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[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]; } @@ -131,6 +131,7 @@ static void node_composit_exec_colorbalance(void *data, bNode *node, bNodeStack 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; } } |