Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_RenderLayersNode.cpp « nodes « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e22c2fd5910d0be7bfd708adb3201a7e1467f591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright 2011, Blender Foundation.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Contributor: 
 *		Jeroen Bakker 
 *		Monique Dewanchand
 */

#include "COM_RenderLayersNode.h"
#include "COM_ExecutionSystem.h"
#include "COM_RenderLayersImageProg.h"
#include "COM_RenderLayersAlphaProg.h"
#include "COM_RenderLayersDepthProg.h"
#include "COM_RenderLayersNormalOperation.h"
#include "COM_RenderLayersSpeedOperation.h"
#include "COM_RenderLayersColorOperation.h"
#include "COM_RenderLayersUVOperation.h"
#include "COM_RenderLayersMistOperation.h"
#include "COM_RenderLayersObjectIndexOperation.h"
#include "COM_RenderLayersDiffuseOperation.h"
#include "COM_RenderLayersSpecularOperation.h"
#include "COM_RenderLayersShadowOperation.h"
#include "COM_RenderLayersAOOperation.h"
#include "COM_RenderLayersEmitOperation.h"
#include "COM_RenderLayersReflectionOperation.h"
#include "COM_RenderLayersRefractionOperation.h"
#include "COM_RenderLayersEnvironmentOperation.h"
#include "COM_RenderLayersIndirectOperation.h"
#include "COM_RenderLayersMaterialIndexOperation.h"
#include "COM_RenderLayersCyclesOperation.h"
#include "COM_TranslateOperation.h"
#include "COM_RotateOperation.h"
#include "COM_ScaleOperation.h"
#include "COM_SetValueOperation.h"

RenderLayersNode::RenderLayersNode(bNode *editorNode): Node(editorNode) {
}

void RenderLayersNode::testSocketConnection(ExecutionSystem* system, int outputSocketNumber, RenderLayersBaseProg * operation) {
	OutputSocket *outputSocket = this->getOutputSocket(outputSocketNumber);
	Scene* scene = (Scene*)this->getbNode()->id;
	short layerId = this->getbNode()->custom1;

	if (outputSocket->isConnected()) {
		operation->setScene(scene);
		operation->setLayerId(layerId);
		outputSocket->relinkConnections(operation->getOutputSocket());
		system->addOperation(operation);
		if (outputSocketNumber == 0) { // only do for image socket if connected
			addPreviewOperation(system, operation->getOutputSocket(), 9);
		}
	} else {
		if (outputSocketNumber == 0) {
			system->addOperation(operation);
			operation->setScene(scene);
			operation->setLayerId(layerId);
			addPreviewOperation(system, operation->getOutputSocket(), 9);
		} else {
			delete operation;
		}
	}
}

void RenderLayersNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context) {
	testSocketConnection(graph, 0, new RenderLayersColourProg());
	testSocketConnection(graph, 1, new RenderLayersAlphaProg());
	testSocketConnection(graph, 2, new RenderLayersDepthProg());
	testSocketConnection(graph, 3, new RenderLayersNormalOperation());
	testSocketConnection(graph, 4, new RenderLayersUVOperation());
	testSocketConnection(graph, 5, new RenderLayersSpeedOperation());
	testSocketConnection(graph, 6, new RenderLayersColorOperation());
	testSocketConnection(graph, 7, new RenderLayersDiffuseOperation());
	testSocketConnection(graph, 8, new RenderLayersSpecularOperation());
	testSocketConnection(graph, 9, new RenderLayersShadowOperation());
	testSocketConnection(graph, 10, new RenderLayersAOOperation());
	testSocketConnection(graph, 11, new RenderLayersReflectionOperation());
	testSocketConnection(graph, 12, new RenderLayersRefractionOperation());
	testSocketConnection(graph, 13, new RenderLayersIndirectOperation());
	testSocketConnection(graph, 14, new RenderLayersObjectIndexOperation());
	testSocketConnection(graph, 15, new RenderLayersMaterialIndexOperation());
	testSocketConnection(graph, 16, new RenderLayersMistOperation());
	testSocketConnection(graph, 17, new RenderLayersEmitOperation());
	testSocketConnection(graph, 18, new RenderLayersEnvironmentOperation());
	
	// cycles passes
	testSocketConnection(graph, 19, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_DIRECT));
	testSocketConnection(graph, 20, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_INDIRECT));
	testSocketConnection(graph, 21, new RenderLayersCyclesOperation(SCE_PASS_DIFFUSE_COLOR));
	testSocketConnection(graph, 22, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_DIRECT));
	testSocketConnection(graph, 23, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_INDIRECT));
	testSocketConnection(graph, 24, new RenderLayersCyclesOperation(SCE_PASS_GLOSSY_COLOR));
	testSocketConnection(graph, 25, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_DIRECT));
	testSocketConnection(graph, 26, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_INDIRECT));
	testSocketConnection(graph, 27, new RenderLayersCyclesOperation(SCE_PASS_TRANSM_COLOR));
}