diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-20 07:19:55 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-20 07:19:55 +0300 |
commit | 1d3186cbcf9e3e463e4e6362ac76862b801cf7ba (patch) | |
tree | 450dc8b914efeb8829f815dbba1f9aabd7449a0f /source/blender/makesrna | |
parent | 8bcf66e1d16ece55f8736797f7d4180a456060ff (diff) |
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...
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 51 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree_types.h | 1 |
2 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 2105e10bbd1..d151e911a9c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -42,6 +42,8 @@ #include "BKE_image.h" #include "BKE_texture.h" +#include "BLI_math.h" + #include "WM_types.h" #include "MEM_guardedalloc.h" @@ -298,6 +300,23 @@ static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *p rna_Node_update(bmain, scene, ptr); } +static void rna_Node_colorbalance_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNode *node= (bNode*)ptr->data; + NodeColorBalance *ncb = node->storage; + float lift[3], gamma[3], gain[3]; + float n_one[3] = {-1.f, -1.f, -1.f}; + + mul_v3_v3fl(lift, ncb->lift, 2.f); + add_v3_v3(lift, n_one); + mul_v3_v3fl(gamma, ncb->gamma, 2.f); + mul_v3_v3fl(gain, ncb->gain, 2.f); + + lift_gamma_gain_to_asc_cdl(lift, gamma, gain, ncb->offset, ncb->slope, ncb->power); + + rna_Node_update(bmain, scene, ptr); +} + static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl) { EnumPropertyItem *item= NULL; @@ -1854,6 +1873,38 @@ static void def_cmp_lensdist(StructRNA *srna) RNA_def_property_ui_text(prop, "Fit", "For positive distortion factor only: scale image such that black areas are not visible"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); } + +static void def_cmp_colorbalance(StructRNA *srna) +{ + PropertyRNA *prop; + static float default_col[3] = {0.5f, 0.5f, 0.5f}; + + RNA_def_struct_sdna_from(srna, "NodeColorBalance", "storage"); + + prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "lift"); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_col); + RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); + RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_colorbalance_update"); + + prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gamma"); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_col); + RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); + RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_colorbalance_update"); + + prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "gain"); + RNA_def_property_array(prop, 3); + RNA_def_property_float_array_default(prop, default_col); + RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); + RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_colorbalance_update"); +} diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index d9a1db996de..936832221f9 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -107,6 +107,7 @@ DefNode( CompositorNode, CMP_NODE_LENSDIST, def_cmp_lensdist, "LENSD DefNode( CompositorNode, CMP_NODE_VIEW_LEVELS, def_cmp_levels, "LEVELS", Levels, "Levels", "" ) DefNode( CompositorNode, CMP_NODE_COLOR_MATTE, def_cmp_color_matte, "COLOR_MATTE", ColorMatte, "Color Matte", "" ) DefNode( CompositorNode, CMP_NODE_DIST_MATTE, def_cmp_distance_matte, "DISTANCE_MATTE", DistanceMatte, "Distance Matte", "" ) +DefNode( CompositorNode, CMP_NODE_COLORBALANCE, def_cmp_colorbalance, "COLORBALANCE", ColorBalance, "Color Balance", "" ) DefNode( TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" ) DefNode( TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" ) |