From b8f22a0565c7b4a1b0b1eb2e8fbdaa3ebbd1a99e Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 6 Nov 2013 12:44:54 +0000 Subject: 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. --- .../composite/nodes/node_composite_colorbalance.c | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'source/blender/nodes') 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"); -- cgit v1.2.3