This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/compositor/nodes/COM_RenderLayersNode.cpp
Dalai Felinto 3a95bdfc65 SceneRenderLayer Removal/Refactor
This patch moves all the functionality previously in SceneRenderLayer to SceneLayer.
If we want to rename some of these structs now would be a good time to do it, before they are in SceneLayer.

Everything should be working, though I will test things further tomorrow. Once this is committed depsgraph can get
rid of the workaround added in rna_Main_meshes_new_from_object and finish whatever this patch was preventing from being finished.

This patch also adds a few placeholders for the overrides (samples, ...). These are obviously not working, so some unittests that rely on 'lay', and 'zmask' will fail.

This patch does not addressed the change of moving samples to ViewRender (I have this as a separate patch and needs some separate discussion).

Following next is the individual note of the individual parts that were committed.

Note 1: It is up to Cycles to still get rid of exclude_layer internally.
Note 2: Cycles still need to handle its own doversion for the use_layer_samples cases and

(1) Remove the override as it is
(2) Add a new override (scene.cycles.samples) if scene.cycles.use_layer_samples != IGNORE

Respecting the expected behaviour when scene.cycles.use_layer_samples == BOUNDED.

Note 3: Cycles still need to implement the per-object holdout
(similar to how we do shadow catcher).

Note 4: There are parts of the old (Blender Internal) rendering pipeline that is still
using lay, e.g., in shi->lay.

Honestly it will be easier to purge the entire Blender Internal code away instead of taking things from it bit by bit.

Reviewers: sergey, campbellbarton, brecht

Differential Revision: https://developer.blender.org/D2919
2017-11-22 07:13:33 -02:00

189 lines
5.9 KiB
C++

/*
* 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_RenderLayersProg.h"
#include "COM_TranslateOperation.h"
#include "COM_RotateOperation.h"
#include "COM_ScaleOperation.h"
#include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h"
#include "COM_SetVectorOperation.h"
RenderLayersNode::RenderLayersNode(bNode *editorNode) : Node(editorNode)
{
/* pass */
}
void RenderLayersNode::testSocketLink(NodeConverter &converter,
const CompositorContext &context,
NodeOutput *output,
RenderLayersProg *operation,
Scene *scene,
int layerId,
bool is_preview) const
{
operation->setScene(scene);
operation->setLayerId(layerId);
operation->setRenderData(context.getRenderData());
operation->setViewName(context.getViewName());
converter.mapOutputSocket(output, operation->getOutputSocket());
converter.addOperation(operation);
if (is_preview) /* only for image socket */
converter.addPreview(operation->getOutputSocket());
}
void RenderLayersNode::testRenderLink(NodeConverter &converter,
const CompositorContext &context,
Render *re) const
{
Scene *scene = (Scene *)this->getbNode()->id;
const short layerId = this->getbNode()->custom1;
RenderResult *rr = RE_AcquireResultRead(re);
if (rr == NULL) {
missingRenderLink(converter);
return;
}
SceneLayer *scene_layer = (SceneLayer *)BLI_findlink(&scene->render_layers, layerId);
if (scene_layer == NULL) {
missingRenderLink(converter);
return;
}
RenderLayer *rl = RE_GetRenderLayer(rr, scene_layer->name);
if (rl == NULL) {
missingRenderLink(converter);
return;
}
const int num_outputs = this->getNumberOfOutputSockets();
for (int i = 0; i < num_outputs; i++) {
NodeOutput *output = this->getOutputSocket(i);
NodeImageLayer *storage = (NodeImageLayer*) output->getbNodeSocket()->storage;
RenderPass *rpass = (RenderPass*) BLI_findstring(
&rl->passes,
storage->pass_name,
offsetof(RenderPass, name));
if (rpass == NULL) {
missingSocketLink(converter, output);
continue;
}
RenderLayersProg *operation;
bool is_preview;
if (STREQ(rpass->name, RE_PASSNAME_COMBINED) &&
STREQ(output->getbNodeSocket()->name, "Alpha"))
{
operation = new RenderLayersAlphaProg(rpass->name,
COM_DT_VALUE,
rpass->channels);
is_preview = false;
}
else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
operation = new RenderLayersDepthProg(rpass->name,
COM_DT_VALUE,
rpass->channels);
is_preview = false;
}
else {
DataType type;
switch (rpass->channels) {
case 4: type = COM_DT_COLOR; break;
case 3: type = COM_DT_VECTOR; break;
case 1: type = COM_DT_VALUE; break;
default:
BLI_assert(!"Unexpected number of channels for pass");
type = COM_DT_VALUE;
break;
}
operation = new RenderLayersProg(rpass->name,
type,
rpass->channels);
is_preview = STREQ(output->getbNodeSocket()->name, "Image");
}
testSocketLink(converter,
context,
output,
operation,
scene,
layerId,
is_preview);
}
}
void RenderLayersNode::missingSocketLink(NodeConverter &converter,
NodeOutput *output) const
{
NodeOperation *operation;
switch (output->getDataType()) {
case COM_DT_COLOR:
{
const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
SetColorOperation *color_operation = new SetColorOperation();
color_operation->setChannels(color);
operation = color_operation;
break;
}
case COM_DT_VECTOR:
{
const float vector[3] = {0.0f, 0.0f, 0.0f};
SetVectorOperation *vector_operation = new SetVectorOperation();
vector_operation->setVector(vector);
operation = vector_operation;
break;
}
case COM_DT_VALUE:
{
SetValueOperation *value_operation = new SetValueOperation();
value_operation->setValue(0.0f);
operation = value_operation;
break;
}
}
converter.mapOutputSocket(output, operation->getOutputSocket());
converter.addOperation(operation);
}
void RenderLayersNode::missingRenderLink(NodeConverter &converter) const
{
const int num_outputs = this->getNumberOfOutputSockets();
for (int i = 0; i < num_outputs; i++) {
NodeOutput *output = this->getOutputSocket(i);
missingSocketLink(converter, output);
}
}
void RenderLayersNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const
{
Scene *scene = (Scene *)this->getbNode()->id;
Render *re = (scene) ? RE_GetSceneRender(scene) : NULL;
if (re != NULL) {
testRenderLink(converter, context, re);
RE_ReleaseResult(re);
}
else {
missingRenderLink(converter);
}
}