Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
| Show All 32 Lines | ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation() | ||||
| this->m_blueChannelEnabled = true; | this->m_blueChannelEnabled = true; | ||||
| } | } | ||||
| void ColorCorrectionOperation::initExecution() | void ColorCorrectionOperation::initExecution() | ||||
| { | { | ||||
| this->m_inputImage = this->getInputSocketReader(0); | this->m_inputImage = this->getInputSocketReader(0); | ||||
| this->m_inputMask = this->getInputSocketReader(1); | 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], | void ColorCorrectionOperation::executePixelSampled(float output[4], | ||||
| float x, | float x, | ||||
| float y, | float y, | ||||
| PixelSampler sampler) | PixelSampler sampler) | ||||
| { | { | ||||
| float inputImageColor[4]; | float inputImageColor[4]; | ||||
| float inputMask[4]; | float inputMask[4]; | ||||
| this->m_inputImage->readSampled(inputImageColor, x, y, sampler); | this->m_inputImage->readSampled(inputImageColor, x, y, sampler); | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | #undef MARGIN_DIV | ||||
| g = (luma + saturation * (g - luma)); | g = (luma + saturation * (g - luma)); | ||||
| b = (luma + saturation * (b - luma)); | b = (luma + saturation * (b - luma)); | ||||
| r = 0.5f + ((r - 0.5f) * contrast); | r = 0.5f + ((r - 0.5f) * contrast); | ||||
| g = 0.5f + ((g - 0.5f) * contrast); | g = 0.5f + ((g - 0.5f) * contrast); | ||||
| b = 0.5f + ((b - 0.5f) * contrast); | b = 0.5f + ((b - 0.5f) * contrast); | ||||
| /* Check for negative values to avoid nan. */ | /* Check for negative values to avoid nan. */ | ||||
| r = (r > 0.0f) ? powf(r * gain + lift, invgamma) : r; | r = color_correct_powf_safe(r * gain + lift, invgamma, r); | ||||
| g = (g > 0.0f) ? powf(g * gain + lift, invgamma) : g; | g = color_correct_powf_safe(g * gain + lift, invgamma, g); | ||||
| b = (b > 0.0f) ? powf(b * gain + lift, invgamma) : b; | b = color_correct_powf_safe(b * gain + lift, invgamma, b); | ||||
| // mix with mask | // mix with mask | ||||
| r = mvalue * inputImageColor[0] + value * r; | r = mvalue * inputImageColor[0] + value * r; | ||||
| g = mvalue * inputImageColor[1] + value * g; | g = mvalue * inputImageColor[1] + value * g; | ||||
| b = mvalue * inputImageColor[2] + value * b; | b = mvalue * inputImageColor[2] + value * b; | ||||
| if (this->m_redChannelEnabled) { | if (this->m_redChannelEnabled) { | ||||
| output[0] = r; | output[0] = r; | ||||
| Show All 24 Lines | |||||