2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2006 Blender Foundation. All rights reserved. */
|
2012-01-05 17:50:09 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup render
|
2012-01-05 17:50:09 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <errno.h>
|
2012-01-05 17:50:09 +00:00
|
|
|
#include <stdio.h>
|
2012-09-04 18:27:47 +00:00
|
|
|
#include <stdlib.h>
|
2012-01-05 17:50:09 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2019-05-19 21:51:18 +02:00
|
|
|
#include "BLI_ghash.h"
|
2014-11-14 11:00:10 +01:00
|
|
|
#include "BLI_hash_md5.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_listbase.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
#include "BLI_path_util.h"
|
2012-08-20 15:29:02 +00:00
|
|
|
#include "BLI_rect.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
#include "BLI_string.h"
|
2020-03-04 15:12:36 +11:00
|
|
|
#include "BLI_string_utils.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
#include "BLI_threads.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
|
2017-11-14 17:23:40 +11:00
|
|
|
#include "BKE_appdir.h"
|
2018-11-07 15:37:31 +01:00
|
|
|
#include "BKE_camera.h"
|
2013-01-10 16:37:48 +00:00
|
|
|
#include "BKE_global.h"
|
2018-11-07 15:37:31 +01:00
|
|
|
#include "BKE_image.h"
|
2022-03-11 17:50:57 +01:00
|
|
|
#include "BKE_image_format.h"
|
2022-03-18 21:28:04 +01:00
|
|
|
#include "BKE_image_save.h"
|
2013-01-10 16:37:48 +00:00
|
|
|
#include "BKE_report.h"
|
2015-04-06 10:40:12 -03:00
|
|
|
#include "BKE_scene.h"
|
2013-01-10 16:37:48 +00:00
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "IMB_colormanagement.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
2022-03-22 00:54:42 +01:00
|
|
|
#include "IMB_openexr.h"
|
2012-01-05 17:50:09 +00:00
|
|
|
|
Fix T56799: Custom render passes missing when using Save Buffers
The problem here was that when a render result is allocated, the standard render passes are added according to the
pass bitfield. Then, when the render engine sets the result, it adds the additional passes which are then merged
into the main render result.
However, when using Save Buffers, the EXR is created before the actual render starts, so it's missing all those
additional passes.
To fix that, we need to query the render engine for a list of additional passes so they can be added before the EXR
is created. Luckily, there already is a function to do that for the node editor.
The same needs to be done when the EXR is loaded back.
Due to how that is implemented though (Render API calls into engine, engine calls back for each pass), if we have
multiple places that call this function there needs to be a way to tell which one the call came from in the pass
registration callback. Therefore, the original caller now provides a callback that is called for each pass.
2019-01-18 00:45:21 +01:00
|
|
|
#include "RE_engine.h"
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
#include "render_result.h"
|
|
|
|
|
#include "render_types.h"
|
|
|
|
|
|
|
|
|
|
/********************************** Free *************************************/
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
static void render_result_views_free(RenderResult *rr)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
while (rr->views.first) {
|
|
|
|
|
RenderView *rv = rr->views.first;
|
|
|
|
|
BLI_remlink(&rr->views, rv);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rv->rect32) {
|
2015-04-06 10:40:12 -03:00
|
|
|
MEM_freeN(rv->rect32);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rv->rectz) {
|
2015-04-06 10:40:12 -03:00
|
|
|
MEM_freeN(rv->rectz);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rv->rectf) {
|
2015-04-06 10:40:12 -03:00
|
|
|
MEM_freeN(rv->rectf);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
MEM_freeN(rv);
|
|
|
|
|
}
|
2018-01-25 14:07:51 +01:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
rr->have_combined = false;
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
void render_result_free(RenderResult *rr)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr == NULL) {
|
2012-06-13 17:23:44 +00:00
|
|
|
return;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
while (rr->layers.first) {
|
|
|
|
|
RenderLayer *rl = rr->layers.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
while (rl->passes.first) {
|
2012-06-13 17:23:44 +00:00
|
|
|
RenderPass *rpass = rl->passes.first;
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rpass->rect) {
|
2012-03-24 06:38:07 +00:00
|
|
|
MEM_freeN(rpass->rect);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_remlink(&rl->passes, rpass);
|
|
|
|
|
MEM_freeN(rpass);
|
|
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
BLI_remlink(&rr->layers, rl);
|
2012-01-05 17:50:09 +00:00
|
|
|
MEM_freeN(rl);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
render_result_views_free(rr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr->rect32) {
|
|
|
|
|
MEM_freeN(rr->rect32);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr->rectz) {
|
|
|
|
|
MEM_freeN(rr->rectz);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr->rectf) {
|
|
|
|
|
MEM_freeN(rr->rectf);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr->text) {
|
|
|
|
|
MEM_freeN(rr->text);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr->error) {
|
|
|
|
|
MEM_freeN(rr->error);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
BKE_stamp_data_free(rr->stamp_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
MEM_freeN(rr);
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_result_free_list(ListBase *lb, RenderResult *rr)
|
|
|
|
|
{
|
|
|
|
|
RenderResult *rrnext;
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
for (; rr; rr = rrnext) {
|
|
|
|
|
rrnext = rr->next;
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (lb && lb->first) {
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_remlink(lb, rr);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
render_result_free(rr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/********************************* multiview *************************************/
|
2012-01-05 17:50:09 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src)
|
|
|
|
|
{
|
|
|
|
|
RenderView *rview;
|
|
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (dst == NULL || src == NULL) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
for (rview = src->views.first; rview; rview = rview->next) {
|
|
|
|
|
RenderView *rv;
|
|
|
|
|
|
|
|
|
|
rv = MEM_mallocN(sizeof(RenderView), "new render view");
|
|
|
|
|
BLI_addtail(&dst->views, rv);
|
|
|
|
|
|
|
|
|
|
BLI_strncpy(rv->name, rview->name, sizeof(rv->name));
|
|
|
|
|
rv->rectf = rview->rectf;
|
|
|
|
|
rv->rectz = rview->rectz;
|
|
|
|
|
rv->rect32 = rview->rect32;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_result_views_shallowdelete(RenderResult *rr)
|
|
|
|
|
{
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rr == NULL) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
while (rr->views.first) {
|
|
|
|
|
RenderView *rv = rr->views.first;
|
|
|
|
|
BLI_remlink(&rr->views, rv);
|
|
|
|
|
MEM_freeN(rv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/********************************** New **************************************/
|
|
|
|
|
|
2021-09-29 21:13:03 +02:00
|
|
|
static void render_layer_allocate_pass(RenderResult *rr, RenderPass *rp)
|
|
|
|
|
{
|
|
|
|
|
if (rp->rect != NULL) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const size_t rectsize = ((size_t)rr->rectx) * rr->recty * rp->channels;
|
|
|
|
|
rp->rect = MEM_callocN(sizeof(float) * rectsize, rp->name);
|
|
|
|
|
|
|
|
|
|
if (STREQ(rp->name, RE_PASSNAME_VECTOR)) {
|
|
|
|
|
/* initialize to max speed */
|
|
|
|
|
float *rect = rp->rect;
|
|
|
|
|
for (int x = rectsize - 1; x >= 0; x--) {
|
|
|
|
|
rect[x] = PASS_VECTOR_MAX;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (STREQ(rp->name, RE_PASSNAME_Z)) {
|
|
|
|
|
float *rect = rp->rect;
|
|
|
|
|
for (int x = rectsize - 1; x >= 0; x--) {
|
|
|
|
|
rect[x] = 10e10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
RenderPass *render_layer_add_pass(RenderResult *rr,
|
|
|
|
|
RenderLayer *rl,
|
|
|
|
|
int channels,
|
|
|
|
|
const char *name,
|
|
|
|
|
const char *viewname,
|
2021-09-29 21:13:03 +02:00
|
|
|
const char *chan_id,
|
|
|
|
|
const bool allocate)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2015-10-24 01:01:10 +11:00
|
|
|
const int view_id = BLI_findstringindex(&rr->views, viewname, offsetof(RenderView, name));
|
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
|
|
|
RenderPass *rpass = MEM_callocN(sizeof(RenderPass), name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rpass->channels = channels;
|
|
|
|
|
rpass->rectx = rl->rectx;
|
|
|
|
|
rpass->recty = rl->recty;
|
2015-04-06 10:40:12 -03:00
|
|
|
rpass->view_id = view_id;
|
2019-04-17 06:17:24 +02: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
|
|
|
BLI_strncpy(rpass->name, name, sizeof(rpass->name));
|
|
|
|
|
BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id));
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_strncpy(rpass->view, viewname, sizeof(rpass->view));
|
2022-03-22 00:59:36 +01:00
|
|
|
RE_render_result_full_channel_name(
|
|
|
|
|
rpass->fullname, NULL, rpass->name, rpass->view, rpass->chan_id, -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
if (rl->exrhandle) {
|
2012-01-05 17:50:09 +00:00
|
|
|
int a;
|
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
|
|
|
for (a = 0; a < channels; a++) {
|
|
|
|
|
char passname[EXR_PASS_MAXNAME];
|
2022-03-22 00:59:36 +01:00
|
|
|
RE_render_result_full_channel_name(passname, NULL, rpass->name, NULL, rpass->chan_id, a);
|
2022-03-18 17:06:51 +01:00
|
|
|
IMB_exr_add_channel(rl->exrhandle, rl->name, passname, viewname, 0, 0, NULL, false);
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-06-18 12:47:16 +02:00
|
|
|
|
2016-03-03 13:21:04 +05:00
|
|
|
BLI_addtail(&rl->passes, rpass);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-29 21:13:03 +02:00
|
|
|
if (allocate) {
|
|
|
|
|
render_layer_allocate_pass(rr, rpass);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* The result contains non-allocated pass now, so tag it as such. */
|
|
|
|
|
rr->passes_allocated = false;
|
|
|
|
|
}
|
2021-09-15 17:42:17 +02:00
|
|
|
|
2014-10-04 19:00:26 +06:00
|
|
|
return rpass;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
RenderResult *render_result_new(Render *re,
|
|
|
|
|
rcti *partrct,
|
|
|
|
|
const char *layername,
|
|
|
|
|
const char *viewname)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
|
|
|
|
RenderResult *rr;
|
|
|
|
|
RenderLayer *rl;
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderView *rv;
|
|
|
|
|
int rectx, recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-23 18:50:56 +00:00
|
|
|
rectx = BLI_rcti_size_x(partrct);
|
|
|
|
|
recty = BLI_rcti_size_y(partrct);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rectx <= 0 || recty <= 0) {
|
2012-01-05 17:50:09 +00:00
|
|
|
return NULL;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rr = MEM_callocN(sizeof(RenderResult), "new render result");
|
|
|
|
|
rr->rectx = rectx;
|
|
|
|
|
rr->recty = recty;
|
|
|
|
|
rr->renrect.xmin = 0;
|
2020-12-16 16:16:50 +01:00
|
|
|
rr->renrect.xmax = rectx;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* tilerect is relative coordinates within render disprect. do not subtract crop yet */
|
2012-03-24 02:51:46 +00:00
|
|
|
rr->tilerect.xmin = partrct->xmin - re->disprect.xmin;
|
2012-09-04 13:29:07 +00:00
|
|
|
rr->tilerect.xmax = partrct->xmax - re->disprect.xmin;
|
2012-03-24 02:51:46 +00:00
|
|
|
rr->tilerect.ymin = partrct->ymin - re->disprect.ymin;
|
2012-09-04 13:29:07 +00:00
|
|
|
rr->tilerect.ymax = partrct->ymax - re->disprect.ymin;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-08-04 15:37:18 +02:00
|
|
|
rr->passes_allocated = false;
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
render_result_views_new(rr, &re->r);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* check renderdata for amount of layers */
|
2018-02-28 10:05:38 +11:00
|
|
|
FOREACH_VIEW_LAYER_TO_RENDER_BEGIN (re, view_layer) {
|
2018-02-20 12:55:02 -03:00
|
|
|
if (layername && layername[0]) {
|
|
|
|
|
if (!STREQ(view_layer->name, layername)) {
|
2014-04-30 15:29:03 +09:00
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-11-16 13:39:25 -02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_addtail(&rr->layers, rl);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
BLI_strncpy(rl->name, view_layer->name, sizeof(rl->name));
|
|
|
|
|
rl->layflag = view_layer->layflag;
|
2019-07-02 22:17:22 +10:00
|
|
|
|
|
|
|
|
rl->passflag = view_layer->passflag;
|
|
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rl->rectx = rectx;
|
|
|
|
|
rl->recty = recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (rv = rr->views.first; rv; rv = rv->next) {
|
|
|
|
|
const char *view = rv->name;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (viewname && viewname[0]) {
|
|
|
|
|
if (!STREQ(view, viewname)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
#define RENDER_LAYER_ADD_PASS_SAFE(rr, rl, channels, name, viewname, chan_id) \
|
2019-03-25 11:55:36 +11:00
|
|
|
do { \
|
2021-09-29 21:13:03 +02:00
|
|
|
if (render_layer_add_pass(rr, rl, channels, name, viewname, chan_id, false) == NULL) { \
|
2019-03-25 11:55:36 +11:00
|
|
|
render_result_free(rr); \
|
|
|
|
|
return NULL; \
|
|
|
|
|
} \
|
|
|
|
|
} while (false)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* A renderlayer should always have a Combined pass. */
|
2021-09-29 21:13:03 +02:00
|
|
|
render_layer_add_pass(rr, rl, 4, "Combined", view, "RGBA", false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (view_layer->passflag & SCE_PASS_Z) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_Z, view, "Z");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_VECTOR) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 4, RE_PASSNAME_VECTOR, view, "XYZW");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_NORMAL) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_NORMAL, view, "XYZ");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (view_layer->passflag & SCE_PASS_POSITION) {
|
|
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_POSITION, view, "XYZ");
|
|
|
|
|
}
|
2019-04-22 09:08:06 +10:00
|
|
|
if (view_layer->passflag & SCE_PASS_UV) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_UV, view, "UVA");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_EMIT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_EMIT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_AO) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_AO, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_ENVIRONMENT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_ENVIRONMENT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_SHADOW) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SHADOW, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_INDEXOB) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXOB, view, "X");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_INDEXMA) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_INDEXMA, view, "X");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_MIST) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 1, RE_PASSNAME_MIST, view, "Z");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_DIFFUSE_DIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_DIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_DIFFUSE_INDIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_INDIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_DIFFUSE_COLOR) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_DIFFUSE_COLOR, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_GLOSSY_DIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_DIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_GLOSSY_INDIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_INDIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_GLOSSY_COLOR) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_GLOSSY_COLOR, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_TRANSM_DIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_DIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_TRANSM_INDIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_INDIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_TRANSM_COLOR) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_TRANSM_COLOR, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_SUBSURFACE_DIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_DIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_SUBSURFACE_INDIRECT) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_INDIRECT, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (view_layer->passflag & SCE_PASS_SUBSURFACE_COLOR) {
|
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
|
|
|
RENDER_LAYER_ADD_PASS_SAFE(rr, rl, 3, RE_PASSNAME_SUBSURFACE_COLOR, view, "RGB");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2016-03-03 13:21:04 +05:00
|
|
|
#undef RENDER_LAYER_ADD_PASS_SAFE
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2018-03-09 11:44:42 +11:00
|
|
|
FOREACH_VIEW_LAYER_TO_RENDER_END;
|
2018-02-20 12:55:02 -03:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Preview-render doesn't do layers, so we make a default one. */
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&rr->layers) && !(layername && layername[0])) {
|
2012-06-13 17:23:44 +00:00
|
|
|
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_addtail(&rr->layers, rl);
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rl->rectx = rectx;
|
|
|
|
|
rl->recty = recty;
|
2012-01-05 17:50:09 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (rv = rr->views.first; rv; rv = rv->next) {
|
|
|
|
|
const char *view = rv->name;
|
|
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (viewname && viewname[0]) {
|
2020-08-08 12:14:52 +10:00
|
|
|
if (!STREQ(view, viewname)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2015-05-12 11:36:52 -03:00
|
|
|
/* a renderlayer should always have a Combined pass */
|
2021-09-29 21:13:03 +02:00
|
|
|
render_layer_add_pass(rr, rl, 4, RE_PASSNAME_COMBINED, view, "RGBA", false);
|
2012-09-04 18:27:47 +00:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2022-03-28 15:53:19 -05:00
|
|
|
/* NOTE: this has to be in sync with `scene.cc`. */
|
2021-07-29 16:34:54 +02:00
|
|
|
rl->layflag = SCE_LAY_FLAG_DEFAULT;
|
2012-06-13 17:23:44 +00:00
|
|
|
rl->passflag = SCE_PASS_COMBINED;
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2017-11-22 10:52:39 -02:00
|
|
|
re->active_view_layer = 0;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2021-07-03 23:08:40 +10:00
|
|
|
/* Border render; calculate offset for use in compositor. compo is centralized coords. */
|
|
|
|
|
/* XXX(ton): obsolete? I now use it for drawing border render offset. */
|
2012-09-23 18:50:56 +00:00
|
|
|
rr->xof = re->disprect.xmin + BLI_rcti_cent_x(&re->disprect) - (re->winx / 2);
|
|
|
|
|
rr->yof = re->disprect.ymin + BLI_rcti_cent_y(&re->disprect) - (re->winy / 2);
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2022-03-22 15:51:41 +01:00
|
|
|
/* Preview does not support deferred render result allocation. */
|
|
|
|
|
if (re->r.scemode & R_BUTS_PREVIEW) {
|
|
|
|
|
render_result_passes_allocated_ensure(rr);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
return rr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 15:37:18 +02:00
|
|
|
void render_result_passes_allocated_ensure(RenderResult *rr)
|
|
|
|
|
{
|
2022-01-05 12:31:03 +01:00
|
|
|
if (rr == NULL) {
|
|
|
|
|
/* Happens when the result was not yet allocated for the current scene or slot configuration.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-04 15:37:18 +02:00
|
|
|
LISTBASE_FOREACH (RenderLayer *, rl, &rr->layers) {
|
|
|
|
|
LISTBASE_FOREACH (RenderPass *, rp, &rl->passes) {
|
|
|
|
|
if (rl->exrhandle != NULL && !STREQ(rp->name, RE_PASSNAME_COMBINED)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-29 21:13:03 +02:00
|
|
|
render_layer_allocate_pass(rr, rp);
|
2021-08-04 15:37:18 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rr->passes_allocated = true;
|
|
|
|
|
}
|
|
|
|
|
|
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 render_result_clone_passes(Render *re, RenderResult *rr, const char *viewname)
|
|
|
|
|
{
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *main_rp;
|
2019-04-17 06:17:24 +02: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
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next) {
|
|
|
|
|
RenderLayer *main_rl = BLI_findstring(
|
|
|
|
|
&re->result->layers, rl->name, offsetof(RenderLayer, name));
|
|
|
|
|
if (!main_rl) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
for (main_rp = main_rl->passes.first; main_rp; main_rp = main_rp->next) {
|
|
|
|
|
if (viewname && viewname[0] && !STREQ(main_rp->view, viewname)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
/* Compare fullname to make sure that the view also is equal. */
|
|
|
|
|
RenderPass *rp = BLI_findstring(
|
|
|
|
|
&rl->passes, main_rp->fullname, offsetof(RenderPass, fullname));
|
|
|
|
|
if (!rp) {
|
|
|
|
|
render_layer_add_pass(
|
2021-09-29 21:13:03 +02:00
|
|
|
rr, rl, main_rp->channels, main_rp->name, main_rp->view, main_rp->chan_id, false);
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-13 01:29:30 +01:00
|
|
|
void RE_create_render_pass(RenderResult *rr,
|
|
|
|
|
const char *name,
|
|
|
|
|
int channels,
|
|
|
|
|
const char *chan_id,
|
|
|
|
|
const char *layername,
|
2021-09-29 21:13:03 +02:00
|
|
|
const char *viewname,
|
|
|
|
|
const bool allocate)
|
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
|
|
|
{
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *rp;
|
|
|
|
|
RenderView *rv;
|
2019-04-17 06:17:24 +02: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
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next) {
|
|
|
|
|
if (layername && layername[0] && !STREQ(rl->name, layername)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
for (rv = rr->views.first; rv; rv = rv->next) {
|
|
|
|
|
const char *view = rv->name;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (viewname && viewname[0] && !STREQ(view, viewname)) {
|
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
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
/* Ensure that the pass doesn't exist yet. */
|
|
|
|
|
for (rp = rl->passes.first; rp; rp = rp->next) {
|
2019-04-22 09:08:06 +10:00
|
|
|
if (!STREQ(rp->name, name)) {
|
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
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (!STREQ(rp->view, view)) {
|
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
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-01-18 00:40:05 +01: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
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
if (!rp) {
|
2021-09-29 21:13:03 +02:00
|
|
|
render_layer_add_pass(rr, rl, channels, name, view, chan_id, allocate);
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-22 00:59:36 +01:00
|
|
|
void RE_render_result_full_channel_name(char *fullname,
|
|
|
|
|
const char *layname,
|
|
|
|
|
const char *passname,
|
|
|
|
|
const char *viewname,
|
|
|
|
|
const char *chan_id,
|
|
|
|
|
const int channel)
|
|
|
|
|
{
|
|
|
|
|
/* OpenEXR compatible full channel name. */
|
|
|
|
|
const char *strings[4];
|
|
|
|
|
int strings_len = 0;
|
|
|
|
|
|
|
|
|
|
if (layname && layname[0]) {
|
|
|
|
|
strings[strings_len++] = layname;
|
|
|
|
|
}
|
|
|
|
|
if (passname && passname[0]) {
|
|
|
|
|
strings[strings_len++] = passname;
|
|
|
|
|
}
|
|
|
|
|
if (viewname && viewname[0]) {
|
|
|
|
|
strings[strings_len++] = viewname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char token[2];
|
|
|
|
|
if (channel >= 0) {
|
|
|
|
|
ARRAY_SET_ITEMS(token, chan_id[channel], '\0');
|
|
|
|
|
strings[strings_len++] = token;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BLI_string_join_array_by_sep_char(fullname, EXR_PASS_MAXNAME, '.', strings, strings_len);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static int passtype_from_name(const char *name)
|
|
|
|
|
{
|
|
|
|
|
const char delim[] = {'.', '\0'};
|
|
|
|
|
const char *sep, *suf;
|
|
|
|
|
int len = BLI_str_partition(name, delim, &sep, &suf);
|
2019-04-17 06:17:24 +02: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
|
|
|
#define CHECK_PASS(NAME) \
|
2020-09-19 16:01:32 +10:00
|
|
|
if (STREQLEN(name, RE_PASSNAME_##NAME, len)) { \
|
|
|
|
|
return SCE_PASS_##NAME; \
|
|
|
|
|
} \
|
|
|
|
|
((void)0)
|
2019-04-17 06:17:24 +02: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
|
|
|
CHECK_PASS(COMBINED);
|
|
|
|
|
CHECK_PASS(Z);
|
|
|
|
|
CHECK_PASS(VECTOR);
|
|
|
|
|
CHECK_PASS(NORMAL);
|
|
|
|
|
CHECK_PASS(UV);
|
|
|
|
|
CHECK_PASS(EMIT);
|
|
|
|
|
CHECK_PASS(SHADOW);
|
|
|
|
|
CHECK_PASS(AO);
|
|
|
|
|
CHECK_PASS(ENVIRONMENT);
|
|
|
|
|
CHECK_PASS(INDEXOB);
|
|
|
|
|
CHECK_PASS(INDEXMA);
|
|
|
|
|
CHECK_PASS(MIST);
|
|
|
|
|
CHECK_PASS(DIFFUSE_DIRECT);
|
|
|
|
|
CHECK_PASS(DIFFUSE_INDIRECT);
|
|
|
|
|
CHECK_PASS(DIFFUSE_COLOR);
|
|
|
|
|
CHECK_PASS(GLOSSY_DIRECT);
|
|
|
|
|
CHECK_PASS(GLOSSY_INDIRECT);
|
|
|
|
|
CHECK_PASS(GLOSSY_COLOR);
|
|
|
|
|
CHECK_PASS(TRANSM_DIRECT);
|
|
|
|
|
CHECK_PASS(TRANSM_INDIRECT);
|
|
|
|
|
CHECK_PASS(TRANSM_COLOR);
|
|
|
|
|
CHECK_PASS(SUBSURFACE_DIRECT);
|
|
|
|
|
CHECK_PASS(SUBSURFACE_INDIRECT);
|
|
|
|
|
CHECK_PASS(SUBSURFACE_COLOR);
|
|
|
|
|
|
|
|
|
|
#undef CHECK_PASS
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* callbacks for render_result_new_from_exr */
|
2012-07-08 00:04:41 +00:00
|
|
|
static void *ml_addlayer_cb(void *base, const char *str)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2012-06-13 17:23:44 +00:00
|
|
|
RenderResult *rr = base;
|
2012-01-05 17:50:09 +00:00
|
|
|
RenderLayer *rl;
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_addtail(&rr->layers, rl);
|
2017-10-20 15:18:26 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_strncpy(rl->name, str, EXR_LAY_MAXNAME);
|
|
|
|
|
return 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
|
|
|
static void ml_addpass_cb(void *base,
|
|
|
|
|
void *lay,
|
|
|
|
|
const char *name,
|
|
|
|
|
float *rect,
|
|
|
|
|
int totchan,
|
|
|
|
|
const char *chan_id,
|
|
|
|
|
const char *view)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2015-04-06 10:40:12 -03:00
|
|
|
RenderResult *rr = base;
|
2012-06-13 17:23:44 +00:00
|
|
|
RenderLayer *rl = lay;
|
|
|
|
|
RenderPass *rpass = MEM_callocN(sizeof(RenderPass), "loaded pass");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_addtail(&rl->passes, rpass);
|
2012-06-13 17:23:44 +00:00
|
|
|
rpass->channels = totchan;
|
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
|
|
|
rl->passflag |= passtype_from_name(name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* channel id chars */
|
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
|
|
|
BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rpass->rect = rect;
|
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
|
|
|
BLI_strncpy(rpass->name, name, EXR_PASS_MAXNAME);
|
|
|
|
|
BLI_strncpy(rpass->view, view, sizeof(rpass->view));
|
2022-03-22 00:59:36 +01:00
|
|
|
RE_render_result_full_channel_name(rpass->fullname, NULL, name, view, rpass->chan_id, -1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (view[0] != '\0') {
|
|
|
|
|
rpass->view_id = BLI_findstringindex(&rr->views, view, offsetof(RenderView, name));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
rpass->view_id = 0;
|
|
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
static void *ml_addview_cb(void *base, const char *str)
|
|
|
|
|
{
|
|
|
|
|
RenderResult *rr = base;
|
|
|
|
|
RenderView *rv;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
rv = MEM_callocN(sizeof(RenderView), "new render view");
|
|
|
|
|
BLI_strncpy(rv->name, str, EXR_VIEW_MAXNAME);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* For stereo drawing we need to ensure:
|
|
|
|
|
* STEREO_LEFT_NAME == STEREO_LEFT_ID and
|
|
|
|
|
* STEREO_RIGHT_NAME == STEREO_RIGHT_ID */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (STREQ(str, STEREO_LEFT_NAME)) {
|
|
|
|
|
BLI_addhead(&rr->views, rv);
|
|
|
|
|
}
|
|
|
|
|
else if (STREQ(str, STEREO_RIGHT_NAME)) {
|
|
|
|
|
RenderView *left_rv = BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
if (left_rv == NULL) {
|
|
|
|
|
BLI_addhead(&rr->views, rv);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_insertlinkafter(&rr->views, left_rv, rv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BLI_addtail(&rr->views, rv);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
return rv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int order_render_passes(const void *a, const void *b)
|
|
|
|
|
{
|
2022-03-16 15:19:31 +11:00
|
|
|
/* 1 if `a` is after `b`. */
|
2019-03-25 11:55:36 +11:00
|
|
|
RenderPass *rpa = (RenderPass *)a;
|
|
|
|
|
RenderPass *rpb = (RenderPass *)b;
|
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
|
|
|
unsigned int passtype_a = passtype_from_name(rpa->name);
|
|
|
|
|
unsigned int passtype_b = passtype_from_name(rpb->name);
|
2019-04-17 06:17:24 +02: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
|
|
|
/* Render passes with default type always go first. */
|
2019-04-22 09:08:06 +10:00
|
|
|
if (passtype_b && !passtype_a) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 1;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (passtype_a && !passtype_b) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 0;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
if (passtype_a && passtype_b) {
|
2019-04-22 09:08:06 +10:00
|
|
|
if (passtype_a > passtype_b) {
|
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
|
|
|
return 1;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-08-07 13:37:22 +02:00
|
|
|
if (passtype_a < passtype_b) {
|
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
|
|
|
return 0;
|
2019-04-22 09:08:06 +10: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
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int cmp = strncmp(rpa->name, rpb->name, EXR_PASS_MAXNAME);
|
2019-04-22 09:08:06 +10:00
|
|
|
if (cmp > 0) {
|
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
|
|
|
return 1;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
if (cmp < 0) {
|
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
|
|
|
return 0;
|
2019-04-22 09:08:06 +10: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* they have the same type */
|
|
|
|
|
/* left first */
|
2019-04-22 09:08:06 +10:00
|
|
|
if (STREQ(rpa->view, STEREO_LEFT_NAME)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 0;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-08-07 13:37:22 +02:00
|
|
|
if (STREQ(rpb->view, STEREO_LEFT_NAME)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 1;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* right second */
|
2019-04-22 09:08:06 +10:00
|
|
|
if (STREQ(rpa->view, STEREO_RIGHT_NAME)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 0;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-08-07 13:37:22 +02:00
|
|
|
if (STREQ(rpb->view, STEREO_RIGHT_NAME)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return 1;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* remaining in ascending id order */
|
|
|
|
|
return (rpa->view_id < rpb->view_id);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
RenderResult *render_result_new_from_exr(
|
|
|
|
|
void *exrhandle, const char *colorspace, bool predivide, int rectx, int recty)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2012-07-08 00:04:41 +00:00
|
|
|
RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__);
|
2012-01-05 17:50:09 +00:00
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *rpass;
|
2012-09-23 18:50:56 +00:00
|
|
|
const char *to_colorspace = IMB_colormanagement_role_colorspace_name_get(
|
|
|
|
|
COLOR_ROLE_SCENE_LINEAR);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
rr->rectx = rectx;
|
|
|
|
|
rr->recty = recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
IMB_exr_multilayer_convert(exrhandle, rr, ml_addview_cb, ml_addlayer_cb, ml_addpass_cb);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next) {
|
|
|
|
|
rl->rectx = rectx;
|
|
|
|
|
rl->recty = recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
BLI_listbase_sort(&rl->passes, order_render_passes);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
|
|
|
|
|
rpass->rectx = rectx;
|
|
|
|
|
rpass->recty = recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-23 18:50:56 +00:00
|
|
|
if (rpass->channels >= 3) {
|
|
|
|
|
IMB_colormanagement_transform(rpass->rect,
|
|
|
|
|
rpass->rectx,
|
|
|
|
|
rpass->recty,
|
|
|
|
|
rpass->channels,
|
|
|
|
|
colorspace,
|
|
|
|
|
to_colorspace,
|
|
|
|
|
predivide);
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
return rr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 17:36:44 -03:00
|
|
|
void render_result_view_new(RenderResult *rr, const char *viewname)
|
|
|
|
|
{
|
|
|
|
|
RenderView *rv = MEM_callocN(sizeof(RenderView), "new render view");
|
|
|
|
|
BLI_addtail(&rr->views, rv);
|
|
|
|
|
BLI_strncpy(rv->name, viewname, sizeof(rv->name));
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-13 17:27:11 +11:00
|
|
|
void render_result_views_new(RenderResult *rr, const RenderData *rd)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
|
|
|
|
SceneRenderView *srv;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* clear previously existing views - for sequencer */
|
|
|
|
|
render_result_views_free(rr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* check renderdata for amount of views */
|
2021-08-05 16:48:29 +10:00
|
|
|
if (rd->scemode & R_MULTIVIEW) {
|
2015-04-06 10:40:12 -03:00
|
|
|
for (srv = rd->views.first; srv; srv = srv->next) {
|
2019-04-22 09:08:06 +10:00
|
|
|
if (BKE_scene_multiview_is_render_view_active(rd, srv) == false) {
|
2015-04-28 17:36:44 -03:00
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-28 17:36:44 -03:00
|
|
|
render_result_view_new(rr, srv->name);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* we always need at least one view */
|
2018-04-03 17:05:21 +02:00
|
|
|
if (BLI_listbase_count_at_most(&rr->views, 1) == 0) {
|
2015-04-29 16:35:19 -03:00
|
|
|
render_result_view_new(rr, "");
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/*********************************** Merge ***********************************/
|
|
|
|
|
|
|
|
|
|
static void do_merge_tile(
|
|
|
|
|
RenderResult *rr, RenderResult *rrpart, float *target, float *tile, int pixsize)
|
|
|
|
|
{
|
2015-04-30 12:10:58 +02:00
|
|
|
int y, tilex, tiley;
|
|
|
|
|
size_t ofs, copylen;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
copylen = tilex = rrpart->rectx;
|
|
|
|
|
tiley = rrpart->recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-16 16:16:50 +01:00
|
|
|
ofs = (((size_t)rrpart->tilerect.ymin) * rr->rectx + rrpart->tilerect.xmin);
|
|
|
|
|
target += pixsize * ofs;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
copylen *= sizeof(float) * pixsize;
|
2012-01-05 17:50:09 +00:00
|
|
|
tilex *= pixsize;
|
2012-06-13 17:23:44 +00:00
|
|
|
ofs = pixsize * rr->rectx;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
for (y = 0; y < tiley; y++) {
|
2012-01-05 17:50:09 +00:00
|
|
|
memcpy(target, tile, copylen);
|
2012-06-13 17:23:44 +00:00
|
|
|
target += ofs;
|
|
|
|
|
tile += tilex;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_result_merge(RenderResult *rr, RenderResult *rrpart)
|
|
|
|
|
{
|
|
|
|
|
RenderLayer *rl, *rlp;
|
|
|
|
|
RenderPass *rpass, *rpassp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next) {
|
2012-09-04 18:27:47 +00:00
|
|
|
rlp = RE_GetRenderLayer(rrpart, rl->name);
|
|
|
|
|
if (rlp) {
|
2019-06-18 12:47:16 +02:00
|
|
|
/* Passes are allocated in sync. */
|
2012-09-04 18:27:47 +00:00
|
|
|
for (rpass = rl->passes.first, rpassp = rlp->passes.first; rpass && rpassp;
|
2015-04-06 10:40:12 -03:00
|
|
|
rpass = rpass->next) {
|
2019-06-18 12:47:16 +02:00
|
|
|
/* For save buffers, skip any passes that are only saved to disk. */
|
|
|
|
|
if (rpass->rect == NULL || rpassp->rect == NULL) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
/* Renderresult have all passes, renderpart only the active view's passes. */
|
2020-08-08 12:14:52 +10:00
|
|
|
if (!STREQ(rpassp->fullname, rpass->fullname)) {
|
2015-04-06 10:40:12 -03:00
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 18:27:47 +00:00
|
|
|
do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/* manually get next render pass */
|
|
|
|
|
rpassp = rpassp->next;
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**************************** Single Layer Rendering *************************/
|
|
|
|
|
|
|
|
|
|
void render_result_single_layer_begin(Render *re)
|
|
|
|
|
{
|
|
|
|
|
/* all layers except the active one get temporally pushed away */
|
|
|
|
|
|
|
|
|
|
/* officially pushed result should be NULL... error can happen with do_seq */
|
|
|
|
|
RE_FreeRenderResult(re->pushedresult);
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
re->pushedresult = re->result;
|
|
|
|
|
re->result = NULL;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_result_single_layer_end(Render *re)
|
|
|
|
|
{
|
2017-11-22 10:52:39 -02:00
|
|
|
ViewLayer *view_layer;
|
2012-01-05 17:50:09 +00:00
|
|
|
RenderLayer *rlpush;
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
int nr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
if (re->result == NULL) {
|
2012-01-05 17:50:09 +00:00
|
|
|
printf("pop render result error; no current result!\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (!re->pushedresult) {
|
2012-01-05 17:50:09 +00:00
|
|
|
return;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
if (re->pushedresult->rectx == re->result->rectx &&
|
|
|
|
|
re->pushedresult->recty == re->result->recty) {
|
2012-01-05 17:50:09 +00:00
|
|
|
/* find which layer in re->pushedresult should be replaced */
|
2012-06-13 17:23:44 +00:00
|
|
|
rl = re->result->layers.first;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* render result should be empty after this */
|
|
|
|
|
BLI_remlink(&re->result->layers, rl);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* reconstruct render result layers */
|
2017-11-22 10:52:39 -02:00
|
|
|
for (nr = 0, view_layer = re->view_layers.first; view_layer;
|
|
|
|
|
view_layer = view_layer->next, nr++) {
|
|
|
|
|
if (nr == re->active_view_layer) {
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_addtail(&re->result->layers, rl);
|
2012-09-04 18:27:47 +00:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
else {
|
2017-11-22 10:52:39 -02:00
|
|
|
rlpush = RE_GetRenderLayer(re->pushedresult, view_layer->name);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (rlpush) {
|
2012-01-05 17:50:09 +00:00
|
|
|
BLI_remlink(&re->pushedresult->layers, rlpush);
|
|
|
|
|
BLI_addtail(&re->result->layers, rlpush);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
RE_FreeRenderResult(re->pushedresult);
|
2012-06-13 17:23:44 +00:00
|
|
|
re->pushedresult = NULL;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
int render_result_exr_file_read_path(RenderResult *rr,
|
|
|
|
|
RenderLayer *rl_single,
|
|
|
|
|
const char *filepath)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
|
|
|
|
RenderLayer *rl;
|
|
|
|
|
RenderPass *rpass;
|
2012-06-13 17:23:44 +00:00
|
|
|
void *exrhandle = IMB_exr_get_handle();
|
2012-01-05 17:50:09 +00:00
|
|
|
int rectx, recty;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-23 19:22:15 +02:00
|
|
|
if (!IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty, false)) {
|
2012-01-05 17:50:09 +00:00
|
|
|
printf("failed being read %s\n", filepath);
|
|
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
if (rr == NULL || rectx != rr->rectx || recty != rr->recty) {
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rr) {
|
2012-01-05 17:50:09 +00:00
|
|
|
printf("error in reading render result: dimensions don't match\n");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-01-05 17:50:09 +00:00
|
|
|
printf("error in reading render result: NULL result pointer\n");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-13 17:23:44 +00:00
|
|
|
for (rl = rr->layers.first; rl; rl = rl->next) {
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rl_single && rl_single != rl) {
|
2012-09-04 13:29:07 +00:00
|
|
|
continue;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* passes are allocated in sync */
|
2012-06-13 17:23:44 +00:00
|
|
|
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
|
2015-04-06 10:40:12 -03:00
|
|
|
const int xstride = rpass->channels;
|
|
|
|
|
int a;
|
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
|
|
|
char fullname[EXR_PASS_MAXNAME];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
for (a = 0; a < xstride; a++) {
|
2022-03-22 00:59:36 +01:00
|
|
|
RE_render_result_full_channel_name(
|
|
|
|
|
fullname, NULL, rpass->name, rpass->view, rpass->chan_id, a);
|
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
|
|
|
IMB_exr_set_channel(
|
2012-06-13 17:23:44 +00:00
|
|
|
exrhandle, rl->name, fullname, xstride, xstride * rectx, rpass->rect + a);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-22 00:59:36 +01:00
|
|
|
RE_render_result_full_channel_name(
|
|
|
|
|
rpass->fullname, NULL, rpass->name, rpass->view, rpass->chan_id, -1);
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
IMB_exr_read_channels(exrhandle);
|
|
|
|
|
IMB_exr_close(exrhandle);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-28 19:13:54 +02:00
|
|
|
static void render_result_exr_file_cache_path(Scene *sce, const char *root, char *r_path)
|
|
|
|
|
{
|
|
|
|
|
char filename_full[FILE_MAX + MAX_ID_NAME + 100], filename[FILE_MAXFILE], dirname[FILE_MAXDIR];
|
|
|
|
|
char path_digest[16] = {0};
|
|
|
|
|
char path_hexdigest[33];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-06-28 19:13:54 +02:00
|
|
|
/* If root is relative, use either current .blend file dir, or temp one if not saved. */
|
2018-06-05 15:10:33 +02:00
|
|
|
const char *blendfile_path = BKE_main_blendfile_path_from_global();
|
|
|
|
|
if (blendfile_path[0] != '\0') {
|
|
|
|
|
BLI_split_dirfile(blendfile_path, dirname, filename, sizeof(dirname), sizeof(filename));
|
2018-06-17 16:13:24 +02:00
|
|
|
BLI_path_extension_replace(filename, sizeof(filename), ""); /* strip '.blend' */
|
2018-06-05 15:10:33 +02:00
|
|
|
BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest);
|
2014-06-28 19:13:54 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2014-11-23 15:54:29 +01:00
|
|
|
BLI_strncpy(dirname, BKE_tempdir_base(), sizeof(dirname));
|
2014-06-28 19:13:54 +02:00
|
|
|
BLI_strncpy(filename, "UNSAVED", sizeof(filename));
|
|
|
|
|
}
|
2014-11-14 11:53:27 +01:00
|
|
|
BLI_hash_md5_to_hexdigest(path_digest, path_hexdigest);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-06-28 19:13:54 +02:00
|
|
|
/* Default to *non-volatile* tmp dir. */
|
|
|
|
|
if (*root == '\0') {
|
2014-11-23 15:54:29 +01:00
|
|
|
root = BKE_tempdir_base();
|
2014-06-28 19:13:54 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-06-28 19:13:54 +02:00
|
|
|
BLI_snprintf(filename_full,
|
|
|
|
|
sizeof(filename_full),
|
|
|
|
|
"cached_RR_%s_%s_%s.exr",
|
|
|
|
|
filename,
|
|
|
|
|
sce->id.name + 2,
|
|
|
|
|
path_hexdigest);
|
|
|
|
|
BLI_make_file_string(dirname, r_path, root, filename_full);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void render_result_exr_file_cache_write(Render *re)
|
|
|
|
|
{
|
|
|
|
|
RenderResult *rr = re->result;
|
|
|
|
|
char str[FILE_MAXFILE + FILE_MAXFILE + MAX_ID_NAME + 100];
|
|
|
|
|
char *root = U.render_cachedir;
|
|
|
|
|
|
|
|
|
|
render_result_exr_file_cache_path(re->scene, root, str);
|
|
|
|
|
printf("Caching exr file, %dx%d, %s\n", rr->rectx, rr->recty, str);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2022-03-09 15:38:17 +01:00
|
|
|
BKE_image_render_write_exr(NULL, rr, str, NULL, true, NULL, -1);
|
2014-06-28 19:13:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool render_result_exr_file_cache_read(Render *re)
|
|
|
|
|
{
|
2021-09-23 19:22:15 +02:00
|
|
|
/* File path to cache. */
|
|
|
|
|
char filepath[FILE_MAXFILE + MAX_ID_NAME + MAX_ID_NAME + 100] = "";
|
2014-06-28 19:13:54 +02:00
|
|
|
char *root = U.render_cachedir;
|
2021-09-23 19:22:15 +02:00
|
|
|
render_result_exr_file_cache_path(re->scene, root, filepath);
|
2014-06-28 19:13:54 +02:00
|
|
|
|
2021-09-23 19:22:15 +02:00
|
|
|
printf("read exr cache file: %s\n", filepath);
|
2014-06-28 19:13:54 +02:00
|
|
|
|
2021-09-23 19:22:15 +02:00
|
|
|
/* Try opening the file. */
|
|
|
|
|
void *exrhandle = IMB_exr_get_handle();
|
|
|
|
|
int rectx, recty;
|
2014-06-28 19:13:54 +02:00
|
|
|
|
2021-09-23 19:22:15 +02:00
|
|
|
if (!IMB_exr_begin_read(exrhandle, filepath, &rectx, &recty, true)) {
|
|
|
|
|
printf("cannot read: %s\n", filepath);
|
|
|
|
|
IMB_exr_close(exrhandle);
|
2014-06-28 19:13:54 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
2021-09-23 19:22:15 +02:00
|
|
|
|
|
|
|
|
/* Read file contents into render result. */
|
|
|
|
|
const char *colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_SCENE_LINEAR);
|
|
|
|
|
RE_FreeRenderResult(re->result);
|
|
|
|
|
|
|
|
|
|
IMB_exr_read_channels(exrhandle);
|
|
|
|
|
re->result = render_result_new_from_exr(exrhandle, colorspace, false, rectx, recty);
|
|
|
|
|
|
|
|
|
|
IMB_exr_close(exrhandle);
|
|
|
|
|
|
2014-06-28 19:13:54 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/*************************** Combined Pixel Rect *****************************/
|
|
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
ImBuf *RE_render_result_rect_to_ibuf(RenderResult *rr,
|
|
|
|
|
const ImageFormatData *imf,
|
|
|
|
|
const float dither,
|
|
|
|
|
const int view_id)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2022-03-18 21:28:04 +01:00
|
|
|
ImBuf *ibuf = IMB_allocImBuf(rr->rectx, rr->recty, imf->planes, 0);
|
2015-04-29 11:26:30 -03:00
|
|
|
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
/* if not exists, BKE_imbuf_write makes one */
|
2019-03-25 11:55:36 +11:00
|
|
|
ibuf->rect = (unsigned int *)rv->rect32;
|
2015-04-29 11:26:30 -03:00
|
|
|
ibuf->rect_float = rv->rectf;
|
|
|
|
|
ibuf->zbuf_float = rv->rectz;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* float factor for random dither, imbuf takes care of it */
|
2022-03-18 21:28:04 +01:00
|
|
|
ibuf->dither = dither;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
/* prepare to gamma correct to sRGB color space
|
|
|
|
|
* note that sequence editor can generate 8bpc render buffers
|
|
|
|
|
*/
|
|
|
|
|
if (ibuf->rect) {
|
2022-03-18 21:28:04 +01:00
|
|
|
if (BKE_imtype_valid_depths(imf->imtype) &
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
(R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_24 | R_IMF_CHAN_DEPTH_32)) {
|
2022-03-18 21:28:04 +01:00
|
|
|
if (imf->depth == R_IMF_CHAN_DEPTH_8) {
|
2013-11-22 16:48:08 +06:00
|
|
|
/* Higher depth bits are supported but not needed for current file output. */
|
|
|
|
|
ibuf->rect_float = NULL;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
IMB_float_from_rect(ibuf);
|
|
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2013-03-24 12:13:13 +00:00
|
|
|
else {
|
2013-02-10 09:27:25 +00:00
|
|
|
/* ensure no float buffer remained from previous frame */
|
|
|
|
|
ibuf->rect_float = NULL;
|
|
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-01-06 13:54:52 +11:00
|
|
|
/* Color -> gray-scale. */
|
2012-01-05 17:50:09 +00:00
|
|
|
/* editing directly would alter the render view */
|
2022-03-18 21:28:04 +01:00
|
|
|
if (imf->planes == R_IMF_PLANES_BW) {
|
2012-06-13 17:23:44 +00:00
|
|
|
ImBuf *ibuf_bw = IMB_dupImBuf(ibuf);
|
2012-01-05 17:50:09 +00:00
|
|
|
IMB_color_to_bw(ibuf_bw);
|
|
|
|
|
IMB_freeImBuf(ibuf);
|
2012-06-13 17:23:44 +00:00
|
|
|
ibuf = ibuf_bw;
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
return ibuf;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
void RE_render_result_rect_from_ibuf(RenderResult *rr, const ImBuf *ibuf, const int view_id)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2015-04-29 11:18:18 -03:00
|
|
|
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf->rect_float) {
|
2018-01-25 14:07:51 +01:00
|
|
|
rr->have_combined = true;
|
|
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (!rv->rectf) {
|
2020-08-08 13:29:21 +10:00
|
|
|
rv->rectf = MEM_mallocN(sizeof(float[4]) * rr->rectx * rr->recty, "render_seq rectf");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2020-08-08 13:29:21 +10:00
|
|
|
memcpy(rv->rectf, ibuf->rect_float, sizeof(float[4]) * rr->rectx * rr->recty);
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
|
2012-01-05 17:50:09 +00:00
|
|
|
/* TSK! Since sequence render doesn't free the *rr render result, the old rect32
|
2012-03-09 18:28:30 +00:00
|
|
|
* can hang around when sequence render has rendered a 32 bits one before */
|
2015-04-09 17:19:50 +10:00
|
|
|
MEM_SAFE_FREE(rv->rect32);
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ibuf->rect) {
|
2018-01-25 14:07:51 +01:00
|
|
|
rr->have_combined = true;
|
|
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (!rv->rect32) {
|
2015-04-06 10:40:12 -03:00
|
|
|
rv->rect32 = MEM_mallocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
memcpy(rv->rect32, ibuf->rect, 4 * rr->rectx * rr->recty);
|
2012-01-05 17:50:09 +00:00
|
|
|
|
|
|
|
|
/* Same things as above, old rectf can hang around from previous render. */
|
2015-04-09 17:19:50 +10:00
|
|
|
MEM_SAFE_FREE(rv->rectf);
|
2015-04-06 10:40:12 -03:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
void render_result_rect_fill_zero(RenderResult *rr, const int view_id)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2015-04-29 11:18:18 -03:00
|
|
|
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rv->rectf) {
|
2020-08-08 13:29:21 +10:00
|
|
|
memset(rv->rectf, 0, sizeof(float[4]) * rr->rectx * rr->recty);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
else if (rv->rect32) {
|
2015-04-06 10:40:12 -03:00
|
|
|
memset(rv->rect32, 0, 4 * rr->rectx * rr->recty);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2015-04-06 10:40:12 -03:00
|
|
|
rv->rect32 = MEM_callocN(sizeof(int) * rr->rectx * rr->recty, "render_seq rect");
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
2012-12-31 13:52:13 +00:00
|
|
|
void render_result_rect_get_pixels(RenderResult *rr,
|
|
|
|
|
unsigned int *rect,
|
|
|
|
|
int rectx,
|
|
|
|
|
int recty,
|
2015-04-06 10:40:12 -03:00
|
|
|
const ColorManagedViewSettings *view_settings,
|
|
|
|
|
const ColorManagedDisplaySettings *display_settings,
|
|
|
|
|
const int view_id)
|
2012-01-05 17:50:09 +00:00
|
|
|
{
|
2015-04-29 11:26:30 -03:00
|
|
|
RenderView *rv = RE_RenderViewGetById(rr, view_id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-20 11:30:19 +01:00
|
|
|
if (rv && rv->rect32) {
|
2015-04-29 11:26:30 -03:00
|
|
|
memcpy(rect, rv->rect32, sizeof(int) * rr->rectx * rr->recty);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2020-01-20 11:30:19 +01:00
|
|
|
else if (rv && rv->rectf) {
|
2019-03-25 11:55:36 +11:00
|
|
|
IMB_display_buffer_transform_apply((unsigned char *)rect,
|
|
|
|
|
rv->rectf,
|
|
|
|
|
rr->rectx,
|
|
|
|
|
rr->recty,
|
|
|
|
|
4,
|
2013-09-05 17:13:43 +00:00
|
|
|
view_settings,
|
|
|
|
|
display_settings,
|
|
|
|
|
true);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2012-01-05 17:50:09 +00:00
|
|
|
/* else fill with black */
|
2012-06-13 17:23:44 +00:00
|
|
|
memset(rect, 0, sizeof(int) * rectx * recty);
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2012-01-05 17:50:09 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-06 10:40:12 -03:00
|
|
|
/*************************** multiview functions *****************************/
|
|
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
bool RE_HasCombinedLayer(const RenderResult *rr)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
if (rr == NULL) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
const RenderView *rv = rr->views.first;
|
2019-04-22 09:08:06 +10:00
|
|
|
if (rv == NULL) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
2019-04-22 09:08:06 +10:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
return (rv->rect32 || rv->rectf);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
bool RE_HasFloatPixels(const RenderResult *rr)
|
2018-01-24 15:55:54 +01:00
|
|
|
{
|
2022-03-18 21:28:04 +01:00
|
|
|
for (const RenderView *rview = rr->views.first; rview; rview = rview->next) {
|
2018-01-24 15:55:54 +01:00
|
|
|
if (rview->rect32 && !rview->rectf) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 21:28:04 +01:00
|
|
|
bool RE_RenderResult_is_stereo(const RenderResult *rr)
|
2015-04-06 10:40:12 -03:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
if (!BLI_findstring(&rr->views, STEREO_LEFT_NAME, offsetof(RenderView, name))) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
2019-03-25 11:55:36 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
if (!BLI_findstring(&rr->views, STEREO_RIGHT_NAME, offsetof(RenderView, name))) {
|
2015-04-06 10:40:12 -03:00
|
|
|
return false;
|
2019-03-25 11:55:36 +11:00
|
|
|
}
|
2015-04-06 10:40:12 -03:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
RenderView *RE_RenderViewGetById(RenderResult *rr, const int view_id)
|
2015-04-29 11:18:18 -03:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
RenderView *rv = BLI_findlink(&rr->views, view_id);
|
|
|
|
|
BLI_assert(rr->views.first);
|
|
|
|
|
return rv ? rv : rr->views.first;
|
2015-04-29 11:18:18 -03:00
|
|
|
}
|
|
|
|
|
|
2020-09-04 20:59:13 +02:00
|
|
|
RenderView *RE_RenderViewGetByName(RenderResult *rr, const char *viewname)
|
2015-04-29 11:18:18 -03:00
|
|
|
{
|
2020-09-04 20:59:13 +02:00
|
|
|
RenderView *rv = BLI_findstring(&rr->views, viewname, offsetof(RenderView, name));
|
|
|
|
|
BLI_assert(rr->views.first);
|
|
|
|
|
return rv ? rv : rr->views.first;
|
2015-04-29 11:18:18 -03:00
|
|
|
}
|
2016-09-16 10:28:41 +02:00
|
|
|
|
|
|
|
|
static RenderPass *duplicate_render_pass(RenderPass *rpass)
|
|
|
|
|
{
|
|
|
|
|
RenderPass *new_rpass = MEM_mallocN(sizeof(RenderPass), "new render pass");
|
|
|
|
|
*new_rpass = *rpass;
|
|
|
|
|
new_rpass->next = new_rpass->prev = NULL;
|
|
|
|
|
if (new_rpass->rect != NULL) {
|
|
|
|
|
new_rpass->rect = MEM_dupallocN(new_rpass->rect);
|
|
|
|
|
}
|
|
|
|
|
return new_rpass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static RenderLayer *duplicate_render_layer(RenderLayer *rl)
|
|
|
|
|
{
|
|
|
|
|
RenderLayer *new_rl = MEM_mallocN(sizeof(RenderLayer), "new render layer");
|
|
|
|
|
*new_rl = *rl;
|
|
|
|
|
new_rl->next = new_rl->prev = NULL;
|
|
|
|
|
new_rl->passes.first = new_rl->passes.last = NULL;
|
|
|
|
|
new_rl->exrhandle = NULL;
|
|
|
|
|
for (RenderPass *rpass = rl->passes.first; rpass != NULL; rpass = rpass->next) {
|
|
|
|
|
RenderPass *new_rpass = duplicate_render_pass(rpass);
|
|
|
|
|
BLI_addtail(&new_rl->passes, new_rpass);
|
|
|
|
|
}
|
|
|
|
|
return new_rl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static RenderView *duplicate_render_view(RenderView *rview)
|
|
|
|
|
{
|
|
|
|
|
RenderView *new_rview = MEM_mallocN(sizeof(RenderView), "new render view");
|
|
|
|
|
*new_rview = *rview;
|
|
|
|
|
if (new_rview->rectf != NULL) {
|
|
|
|
|
new_rview->rectf = MEM_dupallocN(new_rview->rectf);
|
|
|
|
|
}
|
|
|
|
|
if (new_rview->rectz != NULL) {
|
|
|
|
|
new_rview->rectz = MEM_dupallocN(new_rview->rectz);
|
|
|
|
|
}
|
|
|
|
|
if (new_rview->rect32 != NULL) {
|
|
|
|
|
new_rview->rect32 = MEM_dupallocN(new_rview->rect32);
|
|
|
|
|
}
|
|
|
|
|
return new_rview;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderResult *RE_DuplicateRenderResult(RenderResult *rr)
|
|
|
|
|
{
|
2016-10-07 16:06:24 +02:00
|
|
|
RenderResult *new_rr = MEM_mallocN(sizeof(RenderResult), "new duplicated render result");
|
2016-09-16 10:28:41 +02:00
|
|
|
*new_rr = *rr;
|
|
|
|
|
new_rr->next = new_rr->prev = NULL;
|
|
|
|
|
new_rr->layers.first = new_rr->layers.last = NULL;
|
|
|
|
|
new_rr->views.first = new_rr->views.last = NULL;
|
|
|
|
|
for (RenderLayer *rl = rr->layers.first; rl != NULL; rl = rl->next) {
|
|
|
|
|
RenderLayer *new_rl = duplicate_render_layer(rl);
|
|
|
|
|
BLI_addtail(&new_rr->layers, new_rl);
|
|
|
|
|
}
|
|
|
|
|
for (RenderView *rview = rr->views.first; rview != NULL; rview = rview->next) {
|
|
|
|
|
RenderView *new_rview = duplicate_render_view(rview);
|
|
|
|
|
BLI_addtail(&new_rr->views, new_rview);
|
|
|
|
|
}
|
|
|
|
|
if (new_rr->rect32 != NULL) {
|
|
|
|
|
new_rr->rect32 = MEM_dupallocN(new_rr->rect32);
|
|
|
|
|
}
|
|
|
|
|
if (new_rr->rectf != NULL) {
|
|
|
|
|
new_rr->rectf = MEM_dupallocN(new_rr->rectf);
|
|
|
|
|
}
|
|
|
|
|
if (new_rr->rectz != NULL) {
|
|
|
|
|
new_rr->rectz = MEM_dupallocN(new_rr->rectz);
|
|
|
|
|
}
|
2019-02-25 19:51:36 +01:00
|
|
|
new_rr->stamp_data = BKE_stamp_data_copy(new_rr->stamp_data);
|
2016-09-16 10:28:41 +02:00
|
|
|
return new_rr;
|
|
|
|
|
}
|