Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_BrightnessOperation.cpp
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | void BrightnessOperation::executePixelSampled(float output[4], | ||||
| float inputContrast[4]; | float inputContrast[4]; | ||||
| this->m_inputProgram->readSampled(inputValue, x, y, sampler); | this->m_inputProgram->readSampled(inputValue, x, y, sampler); | ||||
| this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler); | this->m_inputBrightnessProgram->readSampled(inputBrightness, x, y, sampler); | ||||
| this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler); | this->m_inputContrastProgram->readSampled(inputContrast, x, y, sampler); | ||||
| float brightness = inputBrightness[0]; | float brightness = inputBrightness[0]; | ||||
| float contrast = inputContrast[0]; | float contrast = inputContrast[0]; | ||||
| brightness /= 100.0f; | brightness /= 100.0f; | ||||
| float delta = contrast / 200.0f; | float delta = contrast / 200.0f; | ||||
| a = 1.0f - delta * 2.0f; | |||||
| /* | /* | ||||
| * The algorithm is by Werner D. Streidt | * The algorithm is by Werner D. Streidt | ||||
| * (http://visca.com/ffactory/archives/5-99/msg00021.html) | * (http://visca.com/ffactory/archives/5-99/msg00021.html) | ||||
| * Extracted of OpenCV demhist.c | * Extracted of OpenCV demhist.c | ||||
| */ | */ | ||||
| if (contrast > 0) { | if (contrast > 0) { | ||||
| a = 1.0f / a; | a = 1.0f / (1.0f - delta * 2.0f); | ||||
| b = a * (brightness - delta); | b = a * (brightness - delta); | ||||
| } | } | ||||
| else { | else { | ||||
| delta *= -1; | delta *= -1; | ||||
| b = a * (brightness + delta); | a = 1.0f - delta * 2.0f; | ||||
| b = a * brightness + delta; | |||||
| } | } | ||||
| if (this->m_use_premultiply) { | if (this->m_use_premultiply) { | ||||
| premul_to_straight_v4(inputValue); | premul_to_straight_v4(inputValue); | ||||
| } | } | ||||
| output[0] = a * inputValue[0] + b; | output[0] = a * inputValue[0] + b; | ||||
| output[1] = a * inputValue[1] + b; | output[1] = a * inputValue[1] + b; | ||||
| output[2] = a * inputValue[2] + b; | output[2] = a * inputValue[2] + b; | ||||
| output[3] = inputValue[3]; | output[3] = inputValue[3]; | ||||
| Show All 11 Lines | |||||