[Bf-blender-cvs] [665acd29039] master: Fix T69497: Color Correction node ignores mask in certain cases
Sergey Sharybin
noreply at git.blender.org
Thu Jun 11 11:02:49 CEST 2020
Commit: 665acd29039b278b6de87121b458675ab025ee33
Author: Sergey Sharybin
Date: Tue Jun 9 15:14:10 2020 +0200
Branches: master
https://developer.blender.org/rB665acd29039b278b6de87121b458675ab025ee33
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
===================================================================
M source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
===================================================================
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;
More information about the Bf-blender-cvs
mailing list