From b91e841f8fa1af0d378870c614880d1b06cc9143 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 12:44:51 +0000 Subject: [PATCH] Fix #37333: Bad default value in Color Balance. Use independent offset/power/slope variables for the CDL mode in color balance node. This avoids stupid default values in particular for offset, which would be 1 when just using the lift value for it. --- .../compositor/nodes/COM_ColorBalanceNode.cpp | 6 +++--- .../operations/COM_ColorBalanceASCCDLOperation.cpp | 6 +++--- .../operations/COM_ColorBalanceASCCDLOperation.h | 12 ++++++------ source/blender/makesdna/DNA_node_types.h | 4 ++-- source/blender/makesrna/intern/rna_nodetree.c | 6 +++--- .../composite/nodes/node_composite_colorbalance.c | 4 ++++ 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp index 68829940da5..2b396fb9861 100644 --- a/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorBalanceNode.cpp @@ -57,9 +57,9 @@ void ColorBalanceNode::convertToOperations(ExecutionSystem *graph, CompositorCon } else { ColorBalanceASCCDLOperation *operationCDL = new ColorBalanceASCCDLOperation(); - operationCDL->setGain(n->gain); - operationCDL->setLift(n->lift); - operationCDL->setGamma(n->gamma); + operationCDL->setOffset(n->offset); + operationCDL->setPower(n->power); + operationCDL->setSlope(n->slope); operation = operationCDL; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp index aa4d0932c92..1456aaf6a55 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cpp @@ -61,9 +61,9 @@ void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y fac = min(1.0f, fac); const float mfac = 1.0f - fac; - output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]); - output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]); - output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]); + output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_offset[0], this->m_power[0], this->m_slope[0]); + output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_offset[1], this->m_power[1], this->m_slope[1]); + output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_offset[2], this->m_power[2], this->m_slope[2]); output[3] = inputColor[3]; } diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 17fb5f67be9..ee0b89f7f70 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -36,9 +36,9 @@ protected: SocketReader *m_inputValueOperation; SocketReader *m_inputColorOperation; - float m_gain[3]; - float m_lift[3]; - float m_gamma[3]; + float m_offset[3]; + float m_power[3]; + float m_slope[3]; public: /** @@ -61,8 +61,8 @@ public: */ void deinitExecution(); - void setGain(float gain[3]) { copy_v3_v3(this->m_gain, gain); } - void setLift(float lift[3]) { copy_v3_v3(this->m_lift, lift); } - void setGamma(float gamma[3]) { copy_v3_v3(this->m_gamma, gamma); } + void setOffset(float offset[3]) { copy_v3_v3(this->m_offset, offset); } + void setPower(float power[3]) { copy_v3_v3(this->m_power, power); } + void setSlope(float slope[3]) { copy_v3_v3(this->m_slope, slope); } }; #endif diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 4ce4f6010b6..a4510dd23fd 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -677,12 +677,12 @@ typedef struct NodeLensDist { } NodeLensDist; typedef struct NodeColorBalance { - /* for processing */ + /* ASC CDL parameters */ float slope[3]; float offset[3]; float power[3]; - /* for ui representation */ + /* LGG parameters */ float lift[3]; float gamma[3]; float gain[3]; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 1f154460ef0..87136a6a07b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -5256,14 +5256,14 @@ static void def_cmp_colorbalance(StructRNA *srna) prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "lift"); + RNA_def_property_float_sdna(prop, NULL, "offset"); RNA_def_property_array(prop, 3); RNA_def_property_ui_range(prop, 0, 1, 0.1, 3); RNA_def_property_ui_text(prop, "Offset", "Correction for Shadows"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gamma"); + RNA_def_property_float_sdna(prop, NULL, "power"); RNA_def_property_array(prop, 3); RNA_def_property_float_array_default(prop, default_1); RNA_def_property_range(prop, 0.f, FLT_MAX); @@ -5272,7 +5272,7 @@ static void def_cmp_colorbalance(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_float_sdna(prop, NULL, "gain"); + RNA_def_property_float_sdna(prop, NULL, "slope"); RNA_def_property_array(prop, 3); RNA_def_property_float_array_default(prop, default_1); RNA_def_property_range(prop, 0.f, FLT_MAX); diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index 9ae744439bc..08019311d4b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -53,6 +53,10 @@ static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *nod n->lift[0] = n->lift[1] = n->lift[2] = 1.0f; n->gamma[0] = n->gamma[1] = n->gamma[2] = 1.0f; n->gain[0] = n->gain[1] = n->gain[2] = 1.0f; + + n->slope[0] = n->slope[1] = n->slope[2] = 1.0f; + n->offset[0] = n->offset[1] = n->offset[2] = 0.0f; + n->power[0] = n->power[1] = n->power[2] = 1.0f; } void register_node_type_cmp_colorbalance(void)