diff options
author | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-06 16:44:54 +0400 |
---|---|---|
committer | Lukas Toenne <lukas.toenne@googlemail.com> | 2013-11-06 16:44:54 +0400 |
commit | b8f22a0565c7b4a1b0b1eb2e8fbdaa3ebbd1a99e (patch) | |
tree | 60a5c8878d2282590a28e55399f171d720bcc2b2 /source/blender/nodes | |
parent | b91e841f8fa1af0d378870c614880d1b06cc9143 (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/blender/nodes')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_colorbalance.c | 30 |
1 files changed, 30 insertions, 0 deletions
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"); |