Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2013-11-06 16:44:54 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2013-11-06 16:44:54 +0400
commitb8f22a0565c7b4a1b0b1eb2e8fbdaa3ebbd1a99e (patch)
tree60a5c8878d2282590a28e55399f171d720bcc2b2 /source
parentb91e841f8fa1af0d378870c614880d1b06cc9143 (diff)
Syncing methods for Color Balance node LGG and ASC-CDL modes. The settings for either mode are converted into equivalent settings of the other. This keeps the result of both modes roughly the same and
mimics the previous behavior when settings were shared by both modes (but not equivalent). NOTE: Due to the use of additional sRGB conversion in the LGG mode the result is not entirely accurate, this should perhaps be fixed. Settings for each mode are kept in their own color values nevertheless, this avoids potential problems with float precision.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h3
-rw-r--r--source/blender/blenloader/intern/readfile.c27
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c24
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.c30
5 files changed, 79 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 5b32e7229d5..f2d9c0efc13 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 269
-#define BLENDER_SUBVERSION 1
+#define BLENDER_SUBVERSION 2
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 15c14c7a707..05824ae6950 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -944,6 +944,9 @@ void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *soc
void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim);
+void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *ntree, bNode *node);
+void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *ntree, bNode *node);
+
/* ************** TEXTURE NODES *************** */
struct TexResult;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 17ae0b103ca..aaf646b70bd 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -9783,6 +9783,33 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ if (!MAIN_VERSION_ATLEAST(main, 269, 2)) {
+ /* Initialize CDL settings for Color Balance nodes */
+ FOREACH_NODETREE(main, ntree, id) {
+ if (ntree->type == NTREE_COMPOSIT) {
+ bNode *node;
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == CMP_NODE_COLORBALANCE) {
+ NodeColorBalance *n = node->storage;
+ if (node->custom1 == 0) {
+ /* LGG mode stays the same, just init CDL settings */
+ ntreeCompositColorBalanceSyncFromLGG(ntree, node);
+ }
+ else if (node->custom1 == 1) {
+ /* CDL previously used same variables as LGG, copy them over
+ * and then sync LGG for comparable results in both modes.
+ */
+ copy_v3_v3(n->offset, n->lift);
+ copy_v3_v3(n->power, n->gamma);
+ copy_v3_v3(n->slope, n->gain);
+ ntreeCompositColorBalanceSyncFromCDL(ntree, node);
+ }
+ }
+ }
+ }
+ } FOREACH_NODETREE_END
+ }
+
{
Scene *scene;
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 87136a6a07b..2b9c2bd4e9a 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2693,6 +2693,18 @@ static PointerRNA rna_NodeOutputFile_slot_file_get(CollectionPropertyIterator *i
return ptr;
}
+static void rna_NodeColorBalance_update_lgg(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositColorBalanceSyncFromLGG(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
+static void rna_NodeColorBalance_update_cdl(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ ntreeCompositColorBalanceSyncFromCDL(ptr->id.data, ptr->data);
+ rna_Node_update(bmain, scene, ptr);
+}
+
/* ******** Node Socket Types ******** */
static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter)
@@ -5236,7 +5248,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Lift", "Correction for Shadows");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gamma");
@@ -5244,7 +5256,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gamma", "Correction for Midtones");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "gain");
@@ -5252,7 +5264,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_float_array_default(prop, default_1);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Gain", "Correction for Highlights");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_lgg");
prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_COLOR_GAMMA);
@@ -5260,7 +5272,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
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");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
prop = RNA_def_property(srna, "power", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "power");
@@ -5269,7 +5281,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_range(prop, 0.f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Power", "Correction for Midtones");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
prop = RNA_def_property(srna, "slope", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "slope");
@@ -5278,7 +5290,7 @@ static void def_cmp_colorbalance(StructRNA *srna)
RNA_def_property_range(prop, 0.f, FLT_MAX);
RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
RNA_def_property_ui_text(prop, "Slope", "Correction for Highlights");
- RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeColorBalance_update_cdl");
}
static void def_cmp_huecorrect(StructRNA *srna)
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
index 08019311d4b..81ebc7c4c3b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c
@@ -46,6 +46,36 @@ static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
{-1, 0, ""}
};
+/* Sync functions update formula parameters for other modes, such that the result is comparable.
+ * Note that the results are not exactly the same due to differences in color handling (sRGB conversion happens for LGG),
+ * but this keeps settings comparable.
+ */
+
+void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeColorBalance *n = node->storage;
+ int c;
+
+ for (c = 0; c < 3; ++c) {
+ n->slope[c] = (2.0f - n->lift[c]) * n->gain[c];
+ n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c];
+ n->power[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
+ }
+}
+
+void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeColorBalance *n = node->storage;
+ int c;
+
+ for (c = 0; c < 3; ++c) {
+ float d = n->slope[c] + n->offset[c];
+ n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f*n->offset[c] / d : 0.0f);
+ n->gain[c] = d;
+ n->gamma[c] = (n->power[c] != 0.0f) ? 1.0f / n->power[c] : 1000000.0f;
+ }
+}
+
static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *node)
{
NodeColorBalance *n = node->storage = MEM_callocN(sizeof(NodeColorBalance), "node colorbalance");