From 1d3186cbcf9e3e463e4e6362ac76862b801cf7ba Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Wed, 20 Jan 2010 04:19:55 +0000 Subject: Durian request: Added 'Color Balance' node to compositor. uses Lift/Gamma/Gain similar to sequence editor. --> http://mke3.net/blender/devel/2.5/color_balance_node.jpg Also added 0 key (zero key) shortcut when mouse is over a button, to reset it to its default value. Same as the RMB menu ->Reset to Default, except for color wheels, it only resets the hue/sat/value components that that widget affects. Peter/Xavier: The existing color balance code can generate NaNs (fractional power of a negative), which causes havoc along the image pipeline. I added a check in the node code to prevent this. Still plenty of potential for lots of better colour correction tools in the compositor, just needs time... --- source/blender/blenlib/BLI_math_color.h | 4 ++++ source/blender/blenlib/intern/math_color.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h index 2123765643e..41cce59c2b9 100644 --- a/source/blender/blenlib/BLI_math_color.h +++ b/source/blender/blenlib/BLI_math_color.h @@ -73,6 +73,10 @@ void linearrgb_to_srgb_v3_v3(float *col_to, float *col_from); int constrain_rgb(float *r, float *g, float *b); void minmax_rgb(short c[3]); + +/***************** lift/gamma/gain / ASC-CDL conversion *****************/ + +void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power); void rgb_byte_to_float(char *in, float *out); void rgb_float_to_byte(float *in, char *out); diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index a4bd11a4bc8..044f1ca743e 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -386,3 +386,17 @@ int constrain_rgb(float *r, float *g, float *b) return 0; /* Color within RGB gamut */ } +/* ********************************* lift/gamma/gain / ASC-CDL conversion ********************************* */ + +void lift_gamma_gain_to_asc_cdl(float *lift, float *gamma, float *gain, float *offset, float *slope, float *power) +{ + int c; + for(c=0; c<3; c++) { + offset[c]= lift[c]*gain[c]; + slope[c]= gain[c]*(1.0f-lift[c]); + if(gamma[c] == 0) + power[c]= FLT_MAX; + else + power[c]= 1.0f/gamma[c]; + } +} -- cgit v1.2.3