2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include "COM_ColorBalanceASCCDLOperation.h"
26
inline float colorbalance_cdl(float in, float offset, float power, float slope)
28
float x = in * slope + offset;
33
return powf(x, power);
36
ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() : NodeOperation()
38
this->addInputSocket(COM_DT_VALUE);
39
this->addInputSocket(COM_DT_COLOR);
40
this->addOutputSocket(COM_DT_COLOR);
41
this->m_inputValueOperation = NULL;
42
this->m_inputColorOperation = NULL;
43
this->setResolutionInputSocketIndex(1);
46
void ColorBalanceASCCDLOperation::initExecution()
48
this->m_inputValueOperation = this->getInputSocketReader(0);
49
this->m_inputColorOperation = this->getInputSocketReader(1);
52
void ColorBalanceASCCDLOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
57
this->m_inputValueOperation->read(value, x, y, sampler);
58
this->m_inputColorOperation->read(inputColor, x, y, sampler);
62
const float mfac = 1.0f - fac;
64
output[0] = mfac * inputColor[0] + fac * colorbalance_cdl(inputColor[0], this->m_lift[0], this->m_gamma[0], this->m_gain[0]);
65
output[1] = mfac * inputColor[1] + fac * colorbalance_cdl(inputColor[1], this->m_lift[1], this->m_gamma[1], this->m_gain[1]);
66
output[2] = mfac * inputColor[2] + fac * colorbalance_cdl(inputColor[2], this->m_lift[2], this->m_gamma[2], this->m_gain[2]);
67
output[3] = inputColor[3];
71
void ColorBalanceASCCDLOperation::deinitExecution()
73
this->m_inputValueOperation = NULL;
74
this->m_inputColorOperation = NULL;