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_MixNode.h"
25
#include "COM_MixBlendOperation.h"
26
#include "COM_MixAddOperation.h"
27
#include "COM_MixMultiplyOperation.h"
28
#include "COM_MixBurnOperation.h"
29
#include "COM_MixColorOperation.h"
30
#include "COM_MixDarkenOperation.h"
31
#include "COM_MixDifferenceOperation.h"
32
#include "COM_MixDivideOperation.h"
33
#include "COM_MixHueOperation.h"
34
#include "COM_MixLightenOperation.h"
35
#include "COM_MixLinearLightOperation.h"
36
#include "COM_MixOverlayOperation.h"
37
#include "COM_MixSaturationOperation.h"
38
#include "COM_MixScreenOperation.h"
39
#include "COM_MixSoftLightOperation.h"
40
#include "COM_MixSubtractOperation.h"
41
#include "COM_MixValueOperation.h"
42
#include "COM_MixDodgeOperation.h"
44
#include "COM_ExecutionSystem.h"
45
#include "COM_SetValueOperation.h"
46
#include "DNA_material_types.h" // the ramp types
49
MixNode::MixNode(bNode *editorNode) : Node(editorNode)
54
void MixNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
56
InputSocket *valueSocket = this->getInputSocket(0);
57
InputSocket *color1Socket = this->getInputSocket(1);
58
InputSocket *color2Socket = this->getInputSocket(2);
59
OutputSocket *outputSocket = this->getOutputSocket(0);
60
bNode *editorNode = this->getbNode();
61
bool useAlphaPremultiply = this->getbNode()->custom2 & 1;
62
bool useClamp = this->getbNode()->custom2 & 2;
64
MixBaseOperation *convertProg;
66
switch (editorNode->custom1) {
68
convertProg = new MixAddOperation();
71
convertProg = new MixMultiplyOperation();
74
convertProg = new MixLightenOperation();
77
convertProg = new MixBurnOperation();
80
convertProg = new MixHueOperation();
83
convertProg = new MixColorOperation();
86
convertProg = new MixSoftLightOperation();
89
convertProg = new MixScreenOperation();
92
convertProg = new MixLinearLightOperation();
95
convertProg = new MixDifferenceOperation();
98
convertProg = new MixSaturationOperation();
101
convertProg = new MixDivideOperation();
104
convertProg = new MixSubtractOperation();
107
convertProg = new MixDarkenOperation();
109
case MA_RAMP_OVERLAY:
110
convertProg = new MixOverlayOperation();
113
convertProg = new MixValueOperation();
116
convertProg = new MixDodgeOperation();
121
convertProg = new MixBlendOperation();
124
convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
125
convertProg->setUseClamp(useClamp);
127
valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
128
color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
129
color2Socket->relinkConnections(convertProg->getInputSocket(2), 2, graph);
130
outputSocket->relinkConnections(convertProg->getOutputSocket(0));
131
addPreviewOperation(graph, context, convertProg->getOutputSocket(0));
133
convertProg->getInputSocket(2)->setResizeMode(color2Socket->getResizeMode());
135
graph->addOperation(convertProg);