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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-06-09 16:14:10 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-06-11 12:02:33 +0300
commit665acd29039b278b6de87121b458675ab025ee33 (patch)
tree9ea01a1072e8636274f342c2a048c1176330d799 /source/blender/compositor
parentf028760b83c340b802adea7bab019ca14d95bad4 (diff)
Fix T69497: Color Correction node ignores mask in certain cases
Happens when some of the color correction terms are mathematically undefined: foe example, when pow() is to be calculated and the X argument is negative. There is no ground-truth result in such cases, so ignore such terms entirely. This is a generalization of D6696 from Jacques. Differential Revision: https://developer.blender.org/D7966
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 39ffb690328..893c052831c 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -38,6 +38,15 @@ void ColorCorrectionOperation::initExecution()
this->m_inputMask = this->getInputSocketReader(1);
}
+/* Calculate x^y if the function is defined. Otherwise return the given fallback value. */
+BLI_INLINE float color_correct_powf_safe(const float x, const float y, const float fallback_value)
+{
+ if (x < 0) {
+ return fallback_value;
+ }
+ return powf(x, y);
+}
+
void ColorCorrectionOperation::executePixelSampled(float output[4],
float x,
float y,
@@ -116,9 +125,9 @@ void ColorCorrectionOperation::executePixelSampled(float output[4],
b = 0.5f + ((b - 0.5f) * contrast);
/* Check for negative values to avoid nan. */
- r = (r > 0.0f) ? powf(r * gain + lift, invgamma) : r;
- g = (g > 0.0f) ? powf(g * gain + lift, invgamma) : g;
- b = (b > 0.0f) ? powf(b * gain + lift, invgamma) : b;
+ r = color_correct_powf_safe(r * gain + lift, invgamma, r);
+ g = color_correct_powf_safe(g * gain + lift, invgamma, g);
+ b = color_correct_powf_safe(b * gain + lift, invgamma, b);
// mix with mask
r = mvalue * inputImageColor[0] + value * r;