Fix T67808: Bright/Contrast node wrong for negative contrast

strange nobody noticed since 2012...

thx @jenkm for spotting

Reviewers: brecht

Subscribers: jenkm

Maniphest Tasks: T67808

Differential Revision: https://developer.blender.org/D5378
This commit is contained in:
Philipp Oeser 2019-07-31 12:22:42 +02:00
parent 200c9f37d6
commit 8dd95abb2f
Notes: blender-bot 2023-09-08 04:55:43 +02:00
Referenced by commit b54528fa1e, BrightContrast not working correctly with negative contrast
Referenced by issue #67808, Bright/Contrast node is broken
1 changed files with 3 additions and 3 deletions

View File

@ -56,19 +56,19 @@ void BrightnessOperation::executePixelSampled(float output[4],
float contrast = inputContrast[0];
brightness /= 100.0f;
float delta = contrast / 200.0f;
a = 1.0f - delta * 2.0f;
/*
* The algorithm is by Werner D. Streidt
* (http://visca.com/ffactory/archives/5-99/msg00021.html)
* Extracted of OpenCV demhist.c
*/
if (contrast > 0) {
a = 1.0f / a;
a = 1.0f / (1.0f - delta * 2.0f);
b = a * (brightness - delta);
}
else {
delta *= -1;
b = a * (brightness + delta);
a = 1.0f - delta * 2.0f;
b = a * brightness + delta;
}
if (this->m_use_premultiply) {
premul_to_straight_v4(inputValue);