2013-09-05 09:39:38 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
2019-02-18 07:21:50 +11:00
|
|
|
*
|
|
|
|
* Copyright 2011, Blender Foundation.
|
2013-09-05 09:39:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "COM_RenderLayersProg.h"
|
|
|
|
|
2021-01-12 16:19:54 +01:00
|
|
|
#include "COM_MetaData.h"
|
|
|
|
|
|
|
|
#include "BKE_image.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "BKE_scene.h"
|
2021-01-12 16:19:54 +01:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_listbase.h"
|
2021-01-12 16:19:54 +01:00
|
|
|
#include "BLI_string.h"
|
|
|
|
#include "BLI_string_ref.hh"
|
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
|
2013-12-22 14:11:10 +11:00
|
|
|
#include "RE_pipeline.h"
|
2020-11-09 15:42:38 +01:00
|
|
|
#include "RE_texture.h"
|
2013-09-05 09:39:38 +00:00
|
|
|
|
2021-03-23 17:12:27 +01:00
|
|
|
namespace blender::compositor {
|
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
/* ******** Render Layers Base Prog ******** */
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
RenderLayersProg::RenderLayersProg(const char *passName, DataType type, int elementsize)
|
2020-08-07 15:58:58 +02:00
|
|
|
: m_passName(passName)
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
2020-11-06 17:49:09 +01:00
|
|
|
this->setScene(nullptr);
|
|
|
|
this->m_inputBuffer = nullptr;
|
2013-09-05 09:39:38 +00:00
|
|
|
this->m_elementsize = elementsize;
|
2020-11-06 17:49:09 +01:00
|
|
|
this->m_rd = nullptr;
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
|
|
|
|
this->addOutputSocket(type);
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
void RenderLayersProg::initExecution()
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
|
|
|
Scene *scene = this->getScene();
|
2020-11-06 17:49:09 +01:00
|
|
|
Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
|
|
|
|
RenderResult *rr = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
if (re) {
|
2013-09-05 09:39:38 +00:00
|
|
|
rr = RE_AcquireResultRead(re);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
if (rr) {
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
|
|
|
|
if (view_layer) {
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
|
2015-04-06 10:40:12 -03:00
|
|
|
if (rl) {
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
this->m_inputBuffer = RE_RenderLayerGetPass(
|
|
|
|
rl, this->m_passName.c_str(), this->m_viewName);
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (re) {
|
|
|
|
RE_ReleaseResult(re);
|
2020-11-06 17:49:09 +01:00
|
|
|
re = nullptr;
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
void RenderLayersProg::doInterpolation(float output[4], float x, float y, PixelSampler sampler)
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
|
|
|
unsigned int offset;
|
|
|
|
int width = this->getWidth(), height = this->getHeight();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-14 11:20:00 +02:00
|
|
|
int ix = x, iy = y;
|
|
|
|
if (ix < 0 || iy < 0 || ix >= width || iy >= height) {
|
2019-04-23 11:21:22 +10:00
|
|
|
if (this->m_elementsize == 1) {
|
2016-04-14 11:20:00 +02:00
|
|
|
output[0] = 0.0f;
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
else if (this->m_elementsize == 3) {
|
2016-04-14 11:20:00 +02:00
|
|
|
zero_v3(output);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
else {
|
2016-04-14 11:20:00 +02:00
|
|
|
zero_v4(output);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2016-04-14 11:20:00 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
switch (sampler) {
|
2021-03-26 12:39:54 +01:00
|
|
|
case PixelSampler::Nearest: {
|
2013-09-05 09:39:38 +00:00
|
|
|
offset = (iy * width + ix) * this->m_elementsize;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
if (this->m_elementsize == 1) {
|
2013-09-05 09:39:38 +00:00
|
|
|
output[0] = this->m_inputBuffer[offset];
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
else if (this->m_elementsize == 3) {
|
2013-09-05 09:39:38 +00:00
|
|
|
copy_v3_v3(output, &this->m_inputBuffer[offset]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
|
|
|
else {
|
2013-09-05 09:39:38 +00:00
|
|
|
copy_v4_v4(output, &this->m_inputBuffer[offset]);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2013-09-05 09:39:38 +00:00
|
|
|
break;
|
Fix for interpolation errors on lower-left borders in compositor image
inputs.
http://wiki.blender.org/uploads/4/4c/Compo_image_interpolation_borders.png
Problem is that all image buffer reader nodes (RenderLayer, Image,
MovieClip) were clipping pixel coordinates to 0..N range (N being width
or height respectively). Bilinear interpolation works ok then on the
upper-right borders (x, N) and (N, y), since the last (N-1) pixel fades
out to N (background). But the lower-left (x, 0) and (0, y) borders are
not correctly interpolated because the nodes cut off the negative pixels
before the interpolation function can calculate their value.
To fix this, the interpolation functions are now entirely responsible
for handling "out of range" cases, i.e. setting (0,0,0,0) results for
invalid pixels, while also handling interpolation for borders.
Callers should not do pixel range checks themselves, which also makes
the code simpler. Should not have any real performance penalty,
the interpolation functions do this check anyway, so is probably even
slightly faster.
2013-12-04 11:56:36 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-26 12:39:54 +01:00
|
|
|
case PixelSampler::Bilinear:
|
2015-03-09 12:45:01 +05:00
|
|
|
BLI_bilinear_interpolation_fl(
|
|
|
|
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
|
2013-09-05 09:39:38 +00:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-26 12:39:54 +01:00
|
|
|
case PixelSampler::Bicubic:
|
2015-03-09 12:45:01 +05:00
|
|
|
BLI_bicubic_interpolation_fl(
|
|
|
|
this->m_inputBuffer, output, width, height, this->m_elementsize, x, y);
|
2013-09-05 09:39:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
void RenderLayersProg::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
const RenderData *rd = this->m_rd;
|
|
|
|
|
|
|
|
int dx = 0, dy = 0;
|
|
|
|
|
|
|
|
if (rd->mode & R_BORDER && rd->mode & R_CROP) {
|
|
|
|
/* see comment in executeRegion describing coordinate mapping,
|
|
|
|
* here it simply goes other way around
|
|
|
|
*/
|
2019-04-17 08:24:14 +02:00
|
|
|
int full_width = rd->xsch * rd->size / 100;
|
2013-09-05 09:39:38 +00:00
|
|
|
int full_height = rd->ysch * rd->size / 100;
|
|
|
|
|
|
|
|
dx = rd->border.xmin * full_width - (full_width - this->getWidth()) / 2.0f;
|
|
|
|
dy = rd->border.ymin * full_height - (full_height - this->getHeight()) / 2.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ix = x - dx;
|
|
|
|
int iy = y - dy;
|
|
|
|
#endif
|
|
|
|
|
2015-03-05 20:24:41 +05:00
|
|
|
#ifndef NDEBUG
|
|
|
|
{
|
|
|
|
const DataType data_type = this->getOutputSocket()->getDataType();
|
|
|
|
int actual_element_size = this->m_elementsize;
|
|
|
|
int expected_element_size;
|
2021-03-19 14:26:24 +01:00
|
|
|
if (data_type == DataType::Value) {
|
2015-03-05 20:24:41 +05:00
|
|
|
expected_element_size = 1;
|
|
|
|
}
|
2021-03-19 14:26:24 +01:00
|
|
|
else if (data_type == DataType::Vector) {
|
2015-03-05 20:24:41 +05:00
|
|
|
expected_element_size = 3;
|
|
|
|
}
|
2021-03-19 14:26:24 +01:00
|
|
|
else if (data_type == DataType::Color) {
|
2015-03-05 20:24:41 +05:00
|
|
|
expected_element_size = 4;
|
|
|
|
}
|
|
|
|
else {
|
2015-08-12 22:17:27 +02:00
|
|
|
expected_element_size = 0;
|
2015-03-05 20:24:41 +05:00
|
|
|
BLI_assert(!"Something horribly wrong just happened");
|
|
|
|
}
|
|
|
|
BLI_assert(expected_element_size == actual_element_size);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2020-11-06 17:49:09 +01:00
|
|
|
if (this->m_inputBuffer == nullptr) {
|
2015-01-19 18:13:26 +01:00
|
|
|
int elemsize = this->m_elementsize;
|
|
|
|
if (elemsize == 1) {
|
|
|
|
output[0] = 0.0f;
|
|
|
|
}
|
|
|
|
else if (elemsize == 3) {
|
|
|
|
zero_v3(output);
|
2015-01-24 01:59:09 +11:00
|
|
|
}
|
|
|
|
else {
|
2015-01-19 18:13:26 +01:00
|
|
|
BLI_assert(elemsize == 4);
|
|
|
|
zero_v4(output);
|
|
|
|
}
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-30 18:03:59 +06:00
|
|
|
doInterpolation(output, x, y, sampler);
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
void RenderLayersProg::deinitExecution()
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
2020-11-06 17:49:09 +01:00
|
|
|
this->m_inputBuffer = nullptr;
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
void RenderLayersProg::determineResolution(unsigned int resolution[2],
|
|
|
|
unsigned int /*preferredResolution*/[2])
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
|
|
|
Scene *sce = this->getScene();
|
2020-11-06 17:49:09 +01:00
|
|
|
Render *re = (sce) ? RE_GetSceneRender(sce) : nullptr;
|
|
|
|
RenderResult *rr = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
resolution[0] = 0;
|
|
|
|
resolution[1] = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
if (re) {
|
2013-09-05 09:39:38 +00:00
|
|
|
rr = RE_AcquireResultRead(re);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
if (rr) {
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&sce->view_layers, getLayerId());
|
|
|
|
if (view_layer) {
|
|
|
|
RenderLayer *rl = RE_GetRenderLayer(rr, view_layer->name);
|
2015-04-06 10:40:12 -03:00
|
|
|
if (rl) {
|
2013-09-05 09:39:38 +00:00
|
|
|
resolution[0] = rl->rectx;
|
|
|
|
resolution[1] = rl->recty;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2019-04-23 11:21:22 +10:00
|
|
|
if (re) {
|
2013-09-05 09:39:38 +00:00
|
|
|
RE_ReleaseResult(re);
|
2019-04-23 11:21:22 +10:00
|
|
|
}
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
|
2021-03-26 15:49:21 +01:00
|
|
|
std::unique_ptr<MetaData> RenderLayersProg::getMetaData()
|
2021-01-12 16:19:54 +01:00
|
|
|
{
|
|
|
|
Scene *scene = this->getScene();
|
|
|
|
Render *re = (scene) ? RE_GetSceneRender(scene) : nullptr;
|
2021-03-02 11:08:04 +01:00
|
|
|
RenderResult *render_result = nullptr;
|
|
|
|
MetaDataExtractCallbackData callback_data = {nullptr};
|
2021-01-12 16:19:54 +01:00
|
|
|
|
|
|
|
if (re) {
|
2021-03-02 11:08:04 +01:00
|
|
|
render_result = RE_AcquireResultRead(re);
|
2021-01-12 16:19:54 +01:00
|
|
|
}
|
|
|
|
|
2021-03-02 11:08:04 +01:00
|
|
|
if (render_result && render_result->stamp_data) {
|
2021-01-12 16:19:54 +01:00
|
|
|
ViewLayer *view_layer = (ViewLayer *)BLI_findlink(&scene->view_layers, getLayerId());
|
|
|
|
if (view_layer) {
|
|
|
|
std::string full_layer_name = std::string(
|
|
|
|
view_layer->name,
|
|
|
|
BLI_strnlen(view_layer->name, sizeof(view_layer->name))) +
|
|
|
|
"." + m_passName;
|
2021-03-03 12:14:06 +01:00
|
|
|
blender::StringRef cryptomatte_layer_name =
|
|
|
|
blender::bke::cryptomatte::BKE_cryptomatte_extract_layer_name(full_layer_name);
|
2021-01-12 16:19:54 +01:00
|
|
|
callback_data.setCryptomatteKeys(cryptomatte_layer_name);
|
|
|
|
|
2021-03-02 11:08:04 +01:00
|
|
|
BKE_stamp_info_callback(&callback_data,
|
|
|
|
render_result->stamp_data,
|
|
|
|
MetaDataExtractCallbackData::extract_cryptomatte_meta_data,
|
|
|
|
false);
|
2021-01-12 16:19:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (re) {
|
|
|
|
RE_ReleaseResult(re);
|
|
|
|
re = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return std::move(callback_data.meta_data);
|
|
|
|
}
|
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
/* ******** Render Layers AO Operation ******** */
|
2015-03-05 20:21:55 +05:00
|
|
|
void RenderLayersAOOperation::executePixelSampled(float output[4],
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
PixelSampler sampler)
|
|
|
|
{
|
|
|
|
float *inputBuffer = this->getInputBuffer();
|
2020-11-06 17:49:09 +01:00
|
|
|
if (inputBuffer == nullptr) {
|
2015-03-05 20:21:55 +05:00
|
|
|
zero_v3(output);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
doInterpolation(output, x, y, sampler);
|
|
|
|
}
|
|
|
|
output[3] = 1.0f;
|
|
|
|
}
|
|
|
|
|
2013-09-05 09:39:38 +00:00
|
|
|
/* ******** Render Layers Alpha Operation ******** */
|
2013-11-19 11:06:16 +01:00
|
|
|
void RenderLayersAlphaProg::executePixelSampled(float output[4],
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
PixelSampler sampler)
|
2013-09-05 09:39:38 +00:00
|
|
|
{
|
|
|
|
float *inputBuffer = this->getInputBuffer();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 17:49:09 +01:00
|
|
|
if (inputBuffer == nullptr) {
|
2015-01-19 18:13:26 +01:00
|
|
|
output[0] = 0.0f;
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-07-01 22:11:44 +06:00
|
|
|
float temp[4];
|
|
|
|
doInterpolation(temp, x, y, sampler);
|
|
|
|
output[0] = temp[3];
|
2013-09-05 09:39:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ******** Render Layers Depth Operation ******** */
|
2015-03-27 15:49:07 +05:00
|
|
|
void RenderLayersDepthProg::executePixelSampled(float output[4],
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
PixelSampler /*sampler*/)
|
2013-09-11 17:34:32 +00:00
|
|
|
{
|
|
|
|
int ix = x;
|
|
|
|
int iy = y;
|
|
|
|
float *inputBuffer = this->getInputBuffer();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 17:49:09 +01:00
|
|
|
if (inputBuffer == nullptr || ix < 0 || iy < 0 || ix >= (int)this->getWidth() ||
|
2013-09-11 17:34:32 +00:00
|
|
|
iy >= (int)this->getHeight()) {
|
2016-02-08 13:36:41 +11:00
|
|
|
output[0] = 10e10f;
|
2013-09-11 17:34:32 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
unsigned int offset = (iy * this->getWidth() + ix);
|
|
|
|
output[0] = inputBuffer[offset];
|
|
|
|
}
|
2017-08-01 09:06:34 +10:00
|
|
|
}
|
2021-03-23 17:12:27 +01:00
|
|
|
|
|
|
|
} // namespace blender::compositor
|