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_BokehBlurNode.h"
24
#include "DNA_camera_types.h"
25
#include "DNA_object_types.h"
26
#include "DNA_node_types.h"
27
#include "COM_ExecutionSystem.h"
28
#include "COM_BokehBlurOperation.h"
29
#include "COM_VariableSizeBokehBlurOperation.h"
30
#include "COM_ConvertDepthToRadiusOperation.h"
32
BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
37
void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
39
bNode *b_node = this->getbNode();
41
InputSocket *inputSizeSocket = this->getInputSocket(2);
43
bool connectedSizeSocket = inputSizeSocket->isConnected();
45
if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) {
46
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
48
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
49
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
50
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
51
operation->setQuality(context->getQuality());
52
operation->setbNode(this->getbNode());
53
graph->addOperation(operation);
54
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
56
operation->setThreshold(0.0f);
57
operation->setMaxBlur(b_node->custom4);
58
operation->setDoScaleSize(true);
61
BokehBlurOperation *operation = new BokehBlurOperation();
63
const bNodeSocket *sock = this->getInputSocket(2)->getbNodeSocket();
64
const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value;
66
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
67
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
68
this->getInputSocket(2)->relinkConnections(operation->getInputSocket(3), 2, graph);
69
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
70
//operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
71
operation->setQuality(context->getQuality());
72
operation->setbNode(this->getbNode());
73
graph->addOperation(operation);
74
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
76
if (!connectedSizeSocket) {
77
operation->setSize(size);