2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 02:50:24 +01:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/background.h"
|
|
|
|
|
#include "render/camera.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "render/curves.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/film.h"
|
|
|
|
|
#include "render/graph.h"
|
|
|
|
|
#include "render/integrator.h"
|
|
|
|
|
#include "render/light.h"
|
|
|
|
|
#include "render/mesh.h"
|
|
|
|
|
#include "render/nodes.h"
|
|
|
|
|
#include "render/object.h"
|
2021-01-25 14:56:57 +01:00
|
|
|
#include "render/procedural.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/scene.h"
|
|
|
|
|
#include "render/shader.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/device.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2019-02-06 16:15:45 +01:00
|
|
|
#include "blender/blender_device.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "blender/blender_session.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "blender/blender_sync.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "blender/blender_util.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_debug.h"
|
|
|
|
|
#include "util/util_foreach.h"
|
|
|
|
|
#include "util/util_hash.h"
|
2020-09-18 12:03:22 +02:00
|
|
|
#include "util/util_logging.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "util/util_opengl.h"
|
2020-06-01 00:11:17 +02:00
|
|
|
#include "util/util_openimagedenoise.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2018-10-28 05:37:41 -04:00
|
|
|
static const char *cryptomatte_prefix = "Crypto";
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Constructor */
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSync::BlenderSync(BL::RenderEngine &b_engine,
|
|
|
|
|
BL::BlendData &b_data,
|
|
|
|
|
BL::Scene &b_scene,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
bool preview,
|
2017-10-08 04:32:25 +02:00
|
|
|
Progress &progress)
|
2016-01-30 14:18:29 +01:00
|
|
|
: b_engine(b_engine),
|
|
|
|
|
b_data(b_data),
|
|
|
|
|
b_scene(b_scene),
|
2020-10-29 14:40:29 +01:00
|
|
|
shader_map(scene),
|
|
|
|
|
object_map(scene),
|
|
|
|
|
geometry_map(scene),
|
|
|
|
|
light_map(scene),
|
|
|
|
|
particle_system_map(scene),
|
2011-04-27 11:58:34 +00:00
|
|
|
world_map(NULL),
|
2011-12-01 16:33:21 +00:00
|
|
|
world_recalc(false),
|
2016-01-30 14:18:29 +01:00
|
|
|
scene(scene),
|
|
|
|
|
preview(preview),
|
2012-09-04 13:29:07 +00:00
|
|
|
experimental(false),
|
2016-04-17 20:15:50 +02:00
|
|
|
dicing_rate(1.0f),
|
2016-04-18 22:35:49 +02:00
|
|
|
max_subdivisions(12),
|
2021-05-17 18:23:44 +02:00
|
|
|
progress(progress),
|
|
|
|
|
has_updates_(true)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2016-04-17 20:15:50 +02:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
|
|
|
|
|
RNA_float_get(&cscene, "dicing_rate");
|
2016-04-18 22:35:49 +02:00
|
|
|
max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlenderSync::~BlenderSync()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-27 18:00:59 +02:00
|
|
|
void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene)
|
|
|
|
|
{
|
|
|
|
|
/* Update data and scene pointers in case they change in session reset,
|
2021-05-17 18:23:44 +02:00
|
|
|
* for example after undo.
|
|
|
|
|
* Note that we do not modify the `has_updates_` flag here because the sync
|
|
|
|
|
* reset is also used during viewport navigation. */
|
2020-05-27 18:00:59 +02:00
|
|
|
this->b_data = b_data;
|
|
|
|
|
this->b_scene = b_scene;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Sync */
|
|
|
|
|
|
2019-08-27 15:47:30 +02:00
|
|
|
void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2018-05-29 15:57:14 +02:00
|
|
|
/* Sync recalc flags from blender to cycles. Actual update is done separate,
|
|
|
|
|
* so we can do it later on if doing it immediate is not suitable. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
if (experimental) {
|
2019-04-04 20:06:22 +02:00
|
|
|
/* Mark all meshes as needing to be exported again if dicing changed. */
|
2016-09-18 12:04:12 -04:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2019-04-04 20:06:22 +02:00
|
|
|
bool dicing_prop_changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
float updated_dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
|
|
|
|
|
RNA_float_get(&cscene, "dicing_rate");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
if (dicing_rate != updated_dicing_rate) {
|
|
|
|
|
dicing_rate = updated_dicing_rate;
|
|
|
|
|
dicing_prop_changed = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
int updated_max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
if (max_subdivisions != updated_max_subdivisions) {
|
|
|
|
|
max_subdivisions = updated_max_subdivisions;
|
|
|
|
|
dicing_prop_changed = true;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-04 20:06:22 +02:00
|
|
|
if (dicing_prop_changed) {
|
2021-05-17 18:23:44 +02:00
|
|
|
has_updates_ = true;
|
|
|
|
|
|
2020-04-30 12:19:37 +02:00
|
|
|
for (const pair<const GeometryKey, Geometry *> &iter : geometry_map.key_to_scene_data()) {
|
2020-02-02 12:04:19 +01:00
|
|
|
Geometry *geom = iter.second;
|
2020-11-04 11:17:38 +01:00
|
|
|
if (geom->is_mesh()) {
|
2020-02-02 12:04:19 +01:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
2020-11-04 11:17:38 +01:00
|
|
|
if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
|
2020-02-02 12:04:19 +01:00
|
|
|
PointerRNA id_ptr;
|
|
|
|
|
RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr);
|
|
|
|
|
geometry_map.set_recalc(BL::ID(id_ptr));
|
|
|
|
|
}
|
2019-04-04 20:06:22 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-18 12:04:12 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-29 15:57:14 +02:00
|
|
|
/* Iterate over all IDs in this depsgraph. */
|
2021-01-25 16:20:10 +01:00
|
|
|
for (BL::DepsgraphUpdate &b_update : b_depsgraph.updates) {
|
2021-05-17 18:23:44 +02:00
|
|
|
/* TODO(sergey): Can do more selective filter here. For example, ignore changes made to
|
|
|
|
|
* screen datablock. Note that sync_data() needs to be called after object deletion, and
|
|
|
|
|
* currently this is ensured by the scene ID tagged for update, which sets the `has_updates_`
|
|
|
|
|
* flag. */
|
|
|
|
|
has_updates_ = true;
|
|
|
|
|
|
2021-01-25 16:20:10 +01:00
|
|
|
BL::ID b_id(b_update.id());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-29 15:57:14 +02:00
|
|
|
/* Material */
|
2018-11-15 17:19:26 +01:00
|
|
|
if (b_id.is_a(&RNA_Material)) {
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::Material b_mat(b_id);
|
2018-05-29 15:57:14 +02:00
|
|
|
shader_map.set_recalc(b_mat);
|
|
|
|
|
}
|
2018-06-27 14:41:53 +02:00
|
|
|
/* Light */
|
2018-11-15 17:19:26 +01:00
|
|
|
else if (b_id.is_a(&RNA_Light)) {
|
2018-06-27 14:41:53 +02:00
|
|
|
BL::Light b_light(b_id);
|
|
|
|
|
shader_map.set_recalc(b_light);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2018-05-29 15:57:14 +02:00
|
|
|
/* Object */
|
2018-11-15 17:19:26 +01:00
|
|
|
else if (b_id.is_a(&RNA_Object)) {
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::Object b_ob(b_id);
|
2020-07-09 18:54:42 +02:00
|
|
|
const bool is_geometry = object_is_geometry(b_ob);
|
|
|
|
|
const bool is_light = !is_geometry && object_is_light(b_ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-25 16:20:10 +01:00
|
|
|
if (b_ob.is_instancer() && b_update.is_updated_shading()) {
|
2020-10-15 15:18:30 +02:00
|
|
|
/* Needed for e.g. object color updates on instancer. */
|
|
|
|
|
object_map.set_recalc(b_ob);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 18:54:42 +02:00
|
|
|
if (is_geometry || is_light) {
|
2021-01-25 16:20:10 +01:00
|
|
|
const bool updated_geometry = b_update.is_updated_geometry();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-09 18:54:42 +02:00
|
|
|
/* Geometry (mesh, hair, volume). */
|
|
|
|
|
if (is_geometry) {
|
2021-01-25 16:20:10 +01:00
|
|
|
if (b_update.is_updated_transform() || b_update.is_updated_shading()) {
|
2020-07-09 18:54:42 +02:00
|
|
|
object_map.set_recalc(b_ob);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updated_geometry ||
|
|
|
|
|
(object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
|
|
|
|
|
BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
|
|
|
|
|
geometry_map.set_recalc(key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (updated_geometry) {
|
|
|
|
|
BL::Object::particle_systems_iterator b_psys;
|
|
|
|
|
for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end();
|
|
|
|
|
++b_psys) {
|
|
|
|
|
particle_system_map.set_recalc(b_ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-29 15:57:14 +02:00
|
|
|
}
|
2020-07-09 18:54:42 +02:00
|
|
|
/* Light */
|
|
|
|
|
else if (is_light) {
|
2021-01-25 16:20:10 +01:00
|
|
|
if (b_update.is_updated_transform() || b_update.is_updated_shading()) {
|
2020-07-09 18:54:42 +02:00
|
|
|
object_map.set_recalc(b_ob);
|
|
|
|
|
light_map.set_recalc(b_ob);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-09 18:54:42 +02:00
|
|
|
if (updated_geometry) {
|
|
|
|
|
light_map.set_recalc(b_ob);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
2018-05-29 15:57:14 +02:00
|
|
|
/* Mesh */
|
2018-11-15 17:19:26 +01:00
|
|
|
else if (b_id.is_a(&RNA_Mesh)) {
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::Mesh b_mesh(b_id);
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_map.set_recalc(b_mesh);
|
2011-09-27 20:37:24 +00:00
|
|
|
}
|
2018-05-29 15:57:14 +02:00
|
|
|
/* World */
|
2018-11-15 17:19:26 +01:00
|
|
|
else if (b_id.is_a(&RNA_World)) {
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::World b_world(b_id);
|
2018-05-29 15:57:14 +02:00
|
|
|
if (world_map == b_world.ptr.data) {
|
|
|
|
|
world_recalc = true;
|
|
|
|
|
}
|
2012-08-31 17:27:08 +00:00
|
|
|
}
|
2020-03-17 16:52:14 +01:00
|
|
|
/* Volume */
|
|
|
|
|
else if (b_id.is_a(&RNA_Volume)) {
|
|
|
|
|
BL::Volume b_volume(b_id);
|
|
|
|
|
geometry_map.set_recalc(b_volume);
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
if (b_v3d) {
|
|
|
|
|
BlenderViewportParameters new_viewport_parameters(b_v3d);
|
2021-05-26 11:16:47 +02:00
|
|
|
|
2021-05-27 11:16:40 +02:00
|
|
|
if (viewport_parameters.shader_modified(new_viewport_parameters)) {
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
world_recalc = true;
|
2021-05-26 11:16:47 +02:00
|
|
|
has_updates_ = true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-27 11:31:03 +02:00
|
|
|
has_updates_ |= viewport_parameters.modified(new_viewport_parameters);
|
2019-08-27 15:47:30 +02:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_data(BL::RenderSettings &b_render,
|
2018-06-25 12:39:30 +02:00
|
|
|
BL::Depsgraph &b_depsgraph,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::SpaceView3D &b_v3d,
|
|
|
|
|
BL::Object &b_override,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width,
|
|
|
|
|
int height,
|
2018-02-26 16:46:48 +01:00
|
|
|
void **python_thread_state)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2021-05-17 18:23:44 +02:00
|
|
|
if (!has_updates_) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-18 12:03:22 +02:00
|
|
|
scoped_timer timer;
|
|
|
|
|
|
2018-04-25 10:13:09 +02:00
|
|
|
BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-26 10:45:27 +02:00
|
|
|
sync_view_layer(b_view_layer);
|
2012-02-28 16:44:45 +00:00
|
|
|
sync_integrator();
|
2019-09-05 12:47:20 +02:00
|
|
|
sync_film(b_v3d);
|
2019-08-27 15:47:30 +02:00
|
|
|
sync_shaders(b_depsgraph, b_v3d);
|
2015-04-02 19:24:14 +05:00
|
|
|
sync_images();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_synced.clear(); /* use for objects and motion sync */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-29 17:40:13 +02:00
|
|
|
if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE ||
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->camera->get_motion_position() == Camera::MOTION_POSITION_CENTER) {
|
2019-08-27 15:47:30 +02:00
|
|
|
sync_objects(b_depsgraph, b_v3d);
|
2015-06-29 17:40:13 +02:00
|
|
|
}
|
2019-08-27 15:47:30 +02:00
|
|
|
sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_synced.clear();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-26 14:28:26 +02:00
|
|
|
/* Shader sync done at the end, since object sync uses it.
|
|
|
|
|
* false = don't delete unused shaders, not supported. */
|
2020-10-29 14:40:29 +01:00
|
|
|
shader_map.post_sync(false);
|
2019-06-26 14:28:26 +02:00
|
|
|
|
2018-07-18 16:09:19 +02:00
|
|
|
free_data_after_sync(b_depsgraph);
|
2020-09-18 12:03:22 +02:00
|
|
|
|
|
|
|
|
VLOG(1) << "Total time spent synchronizing data: " << timer.get_time();
|
2021-05-17 18:23:44 +02:00
|
|
|
|
|
|
|
|
has_updates_ = false;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Integrator */
|
|
|
|
|
|
2012-02-28 16:44:45 +00:00
|
|
|
void BlenderSync::sync_integrator()
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
BL::RenderSettings r = b_scene.render();
|
2011-04-27 11:58:34 +00:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-02-10 03:25:53 +05:00
|
|
|
experimental = (get_enum(cscene, "feature_set") != 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Integrator *integrator = scene->integrator;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_min_bounce(get_int(cscene, "min_light_bounces"));
|
|
|
|
|
integrator->set_max_bounce(get_int(cscene, "max_bounces"));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_max_diffuse_bounce(get_int(cscene, "diffuse_bounces"));
|
|
|
|
|
integrator->set_max_glossy_bounce(get_int(cscene, "glossy_bounces"));
|
|
|
|
|
integrator->set_max_transmission_bounce(get_int(cscene, "transmission_bounces"));
|
|
|
|
|
integrator->set_max_volume_bounce(get_int(cscene, "volume_bounces"));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_transparent_min_bounce(get_int(cscene, "min_transparent_bounces"));
|
|
|
|
|
integrator->set_transparent_max_bounce(get_int(cscene, "transparent_max_bounces"));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_volume_max_steps(get_int(cscene, "volume_max_steps"));
|
|
|
|
|
float volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") :
|
|
|
|
|
get_float(cscene, "volume_step_rate");
|
|
|
|
|
integrator->set_volume_step_rate(volume_step_rate);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_caustics_reflective(get_boolean(cscene, "caustics_reflective"));
|
|
|
|
|
integrator->set_caustics_refractive(get_boolean(cscene, "caustics_refractive"));
|
|
|
|
|
integrator->set_filter_glossy(get_float(cscene, "blur_glossy"));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
int seed = get_int(cscene, "seed");
|
2016-11-08 11:16:37 +01:00
|
|
|
if (get_boolean(cscene, "use_animated_seed")) {
|
2020-11-04 11:17:38 +01:00
|
|
|
seed = hash_uint2(b_scene.frame_current(), get_int(cscene, "seed"));
|
2016-11-16 15:12:31 +01:00
|
|
|
if (b_scene.frame_subframe() != 0.0f) {
|
|
|
|
|
/* TODO(sergey): Ideally should be some sort of hash_merge,
|
|
|
|
|
* but this is good enough for now.
|
|
|
|
|
*/
|
2020-11-04 11:17:38 +01:00
|
|
|
seed += hash_uint2((int)(b_scene.frame_subframe() * (float)INT_MAX),
|
|
|
|
|
get_int(cscene, "seed"));
|
2016-11-08 11:16:37 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_seed(seed);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
|
|
|
|
|
integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
|
2012-11-15 21:52:17 +00:00
|
|
|
if (!preview) {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_motion_blur(r.use_motion_blur());
|
2012-11-15 21:52:17 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_method((Integrator::Method)get_enum(
|
|
|
|
|
cscene, "progressive", Integrator::NUM_METHODS, Integrator::PATH));
|
|
|
|
|
|
|
|
|
|
integrator->set_sample_all_lights_direct(get_boolean(cscene, "sample_all_lights_direct"));
|
|
|
|
|
integrator->set_sample_all_lights_indirect(get_boolean(cscene, "sample_all_lights_indirect"));
|
|
|
|
|
integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold"));
|
|
|
|
|
|
|
|
|
|
SamplingPattern sampling_pattern = (SamplingPattern)get_enum(
|
|
|
|
|
cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
int adaptive_min_samples = INT_MAX;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-05 12:05:42 +01:00
|
|
|
if (RNA_boolean_get(&cscene, "use_adaptive_sampling")) {
|
2020-11-04 11:17:38 +01:00
|
|
|
sampling_pattern = SAMPLING_PATTERN_PMJ;
|
|
|
|
|
adaptive_min_samples = get_int(cscene, "adaptive_min_samples");
|
|
|
|
|
integrator->set_adaptive_threshold(get_float(cscene, "adaptive_threshold"));
|
2020-03-05 12:05:42 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_adaptive_threshold(0.0f);
|
2020-03-05 12:05:42 +01:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_sampling_pattern(sampling_pattern);
|
|
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
int diffuse_samples = get_int(cscene, "diffuse_samples");
|
|
|
|
|
int glossy_samples = get_int(cscene, "glossy_samples");
|
|
|
|
|
int transmission_samples = get_int(cscene, "transmission_samples");
|
|
|
|
|
int ao_samples = get_int(cscene, "ao_samples");
|
|
|
|
|
int mesh_light_samples = get_int(cscene, "mesh_light_samples");
|
|
|
|
|
int subsurface_samples = get_int(cscene, "subsurface_samples");
|
|
|
|
|
int volume_samples = get_int(cscene, "volume_samples");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
if (get_boolean(cscene, "use_square_samples")) {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_diffuse_samples(diffuse_samples * diffuse_samples);
|
|
|
|
|
integrator->set_glossy_samples(glossy_samples * glossy_samples);
|
|
|
|
|
integrator->set_transmission_samples(transmission_samples * transmission_samples);
|
|
|
|
|
integrator->set_ao_samples(ao_samples * ao_samples);
|
|
|
|
|
integrator->set_mesh_light_samples(mesh_light_samples * mesh_light_samples);
|
|
|
|
|
integrator->set_subsurface_samples(subsurface_samples * subsurface_samples);
|
|
|
|
|
integrator->set_volume_samples(volume_samples * volume_samples);
|
|
|
|
|
adaptive_min_samples = min(adaptive_min_samples * adaptive_min_samples, INT_MAX);
|
2018-07-06 10:17:58 +02:00
|
|
|
}
|
2017-08-20 23:46:05 +02:00
|
|
|
else {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_diffuse_samples(diffuse_samples);
|
|
|
|
|
integrator->set_glossy_samples(glossy_samples);
|
|
|
|
|
integrator->set_transmission_samples(transmission_samples);
|
|
|
|
|
integrator->set_ao_samples(ao_samples);
|
|
|
|
|
integrator->set_mesh_light_samples(mesh_light_samples);
|
|
|
|
|
integrator->set_subsurface_samples(subsurface_samples);
|
|
|
|
|
integrator->set_volume_samples(volume_samples);
|
2017-08-20 23:46:05 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_adaptive_min_samples(adaptive_min_samples);
|
|
|
|
|
|
2021-04-04 15:01:00 +02:00
|
|
|
if (get_boolean(cscene, "use_fast_gi")) {
|
2016-11-25 18:59:43 +01:00
|
|
|
if (preview) {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_ao_bounces(get_int(cscene, "ao_bounces"));
|
2016-11-25 18:59:43 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_ao_bounces(get_int(cscene, "ao_bounces_render"));
|
2016-11-25 18:59:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-05-23 10:34:03 +02:00
|
|
|
else {
|
2020-11-04 11:17:38 +01:00
|
|
|
integrator->set_ao_bounces(0);
|
2017-05-23 10:34:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
/* UPDATE_NONE as we don't want to tag the integrator as modified, just tag dependent things */
|
|
|
|
|
integrator->tag_update(scene, Integrator::UPDATE_NONE);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Film */
|
|
|
|
|
|
2019-09-05 12:47:20 +02:00
|
|
|
void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Film *film = scene->film;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 12:15:46 +02:00
|
|
|
vector<Pass> prevpasses = scene->passes;
|
|
|
|
|
|
2019-09-05 12:47:20 +02:00
|
|
|
if (b_v3d) {
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_display_pass(update_viewport_display_passes(b_v3d, scene->passes));
|
2019-09-05 12:47:20 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_exposure(get_float(cscene, "film_exposure"));
|
|
|
|
|
film->set_filter_type(
|
|
|
|
|
(FilterType)get_enum(cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS));
|
|
|
|
|
float filter_width = (film->get_filter_type() == FILTER_BOX) ? 1.0f :
|
|
|
|
|
get_float(cscene, "filter_width");
|
|
|
|
|
film->set_filter_width(filter_width);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-09 18:05:53 +00:00
|
|
|
if (b_scene.world()) {
|
|
|
|
|
BL::WorldMistSettings b_mist = b_scene.world().mist_settings();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_mist_start(b_mist.start());
|
|
|
|
|
film->set_mist_depth(b_mist.depth());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-09 18:05:53 +00:00
|
|
|
switch (b_mist.falloff()) {
|
|
|
|
|
case BL::WorldMistSettings::falloff_QUADRATIC:
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_mist_falloff(2.0f);
|
2013-06-09 18:05:53 +00:00
|
|
|
break;
|
|
|
|
|
case BL::WorldMistSettings::falloff_LINEAR:
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_mist_falloff(1.0f);
|
2013-06-09 18:05:53 +00:00
|
|
|
break;
|
|
|
|
|
case BL::WorldMistSettings::falloff_INVERSE_QUADRATIC:
|
2020-11-04 11:17:38 +01:00
|
|
|
film->set_mist_falloff(0.5f);
|
2013-06-09 18:05:53 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2013-06-07 12:45:26 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 12:15:46 +02:00
|
|
|
if (!Pass::equals(prevpasses, scene->passes)) {
|
|
|
|
|
film->tag_passes_update(scene, prevpasses, false);
|
2020-11-04 11:17:38 +01:00
|
|
|
film->tag_modified();
|
2019-09-05 12:47:20 +02:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-12 13:13:56 +00:00
|
|
|
/* Render Layer */
|
|
|
|
|
|
2021-05-26 10:45:27 +02:00
|
|
|
void BlenderSync::sync_view_layer(BL::ViewLayer &b_view_layer)
|
2011-09-12 13:13:56 +00:00
|
|
|
{
|
2018-02-26 16:46:48 +01:00
|
|
|
view_layer.name = b_view_layer.name();
|
2020-10-01 14:28:29 +02:00
|
|
|
|
|
|
|
|
/* Filter. */
|
2018-02-26 16:46:48 +01:00
|
|
|
view_layer.use_background_shader = b_view_layer.use_sky();
|
|
|
|
|
view_layer.use_background_ao = b_view_layer.use_ao();
|
2020-10-01 14:28:29 +02:00
|
|
|
/* Always enable surfaces for baking, otherwise there is nothing to bake to. */
|
|
|
|
|
view_layer.use_surfaces = b_view_layer.use_solid() || scene->bake_manager->get_baking();
|
2018-02-26 16:46:48 +01:00
|
|
|
view_layer.use_hair = b_view_layer.use_strand();
|
2020-03-11 11:22:13 +01:00
|
|
|
view_layer.use_volumes = b_view_layer.use_volumes();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-28 18:37:05 +01:00
|
|
|
/* Material override. */
|
|
|
|
|
view_layer.material_override = b_view_layer.material_override();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-28 18:37:05 +01:00
|
|
|
/* Sample override. */
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
int use_layer_samples = get_enum(cscene, "use_layer_samples");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-28 18:37:05 +01:00
|
|
|
view_layer.bound_samples = (use_layer_samples == 1);
|
|
|
|
|
view_layer.samples = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-28 18:37:05 +01:00
|
|
|
if (use_layer_samples != 2) {
|
|
|
|
|
int samples = b_view_layer.samples();
|
|
|
|
|
if (get_boolean(cscene, "use_square_samples"))
|
|
|
|
|
view_layer.samples = samples * samples;
|
|
|
|
|
else
|
|
|
|
|
view_layer.samples = samples;
|
|
|
|
|
}
|
2011-09-12 13:13:56 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
/* Images */
|
|
|
|
|
void BlenderSync::sync_images()
|
|
|
|
|
{
|
|
|
|
|
/* Sync is a convention for this API, but currently it frees unused buffers. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
const bool is_interface_locked = b_engine.render() && b_engine.render().use_lock_interface();
|
|
|
|
|
if (is_interface_locked == false && BlenderSession::headless == false) {
|
|
|
|
|
/* If interface is not locked, it's possible image is needed for
|
|
|
|
|
* the display.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* Free buffers used by images which are not needed for render. */
|
2021-01-25 16:20:10 +01:00
|
|
|
for (BL::Image &b_image : b_data.images) {
|
2015-04-02 19:24:14 +05:00
|
|
|
/* TODO(sergey): Consider making it an utility function to check
|
|
|
|
|
* whether image is considered builtin.
|
|
|
|
|
*/
|
2021-01-25 16:20:10 +01:00
|
|
|
const bool is_builtin = b_image.packed_file() ||
|
|
|
|
|
b_image.source() == BL::Image::source_GENERATED ||
|
|
|
|
|
b_image.source() == BL::Image::source_MOVIE || b_engine.is_preview();
|
2015-04-02 19:24:14 +05:00
|
|
|
if (is_builtin == false) {
|
2021-01-25 16:20:10 +01:00
|
|
|
b_image.buffers_free();
|
2015-04-02 19:24:14 +05:00
|
|
|
}
|
|
|
|
|
/* TODO(sergey): Free builtin images not used by any shader. */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
/* Passes */
|
|
|
|
|
PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass)
|
|
|
|
|
{
|
|
|
|
|
string name = b_pass.name();
|
|
|
|
|
#define MAP_PASS(passname, passtype) \
|
2020-09-19 16:01:32 +10:00
|
|
|
if (name == passname) { \
|
|
|
|
|
return passtype; \
|
|
|
|
|
} \
|
|
|
|
|
((void)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
|
|
|
/* NOTE: Keep in sync with defined names from DNA_scene_types.h */
|
|
|
|
|
MAP_PASS("Combined", PASS_COMBINED);
|
|
|
|
|
MAP_PASS("Depth", PASS_DEPTH);
|
|
|
|
|
MAP_PASS("Mist", PASS_MIST);
|
|
|
|
|
MAP_PASS("Normal", PASS_NORMAL);
|
|
|
|
|
MAP_PASS("IndexOB", PASS_OBJECT_ID);
|
|
|
|
|
MAP_PASS("UV", PASS_UV);
|
|
|
|
|
MAP_PASS("Vector", PASS_MOTION);
|
|
|
|
|
MAP_PASS("IndexMA", PASS_MATERIAL_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
|
|
|
MAP_PASS("DiffDir", PASS_DIFFUSE_DIRECT);
|
|
|
|
|
MAP_PASS("GlossDir", PASS_GLOSSY_DIRECT);
|
|
|
|
|
MAP_PASS("TransDir", PASS_TRANSMISSION_DIRECT);
|
2017-11-14 07:21:07 +01:00
|
|
|
MAP_PASS("VolumeDir", PASS_VOLUME_DIRECT);
|
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
|
|
|
MAP_PASS("DiffInd", PASS_DIFFUSE_INDIRECT);
|
|
|
|
|
MAP_PASS("GlossInd", PASS_GLOSSY_INDIRECT);
|
|
|
|
|
MAP_PASS("TransInd", PASS_TRANSMISSION_INDIRECT);
|
2017-11-14 07:21:07 +01:00
|
|
|
MAP_PASS("VolumeInd", PASS_VOLUME_INDIRECT);
|
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
|
|
|
MAP_PASS("DiffCol", PASS_DIFFUSE_COLOR);
|
|
|
|
|
MAP_PASS("GlossCol", PASS_GLOSSY_COLOR);
|
|
|
|
|
MAP_PASS("TransCol", PASS_TRANSMISSION_COLOR);
|
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
|
|
|
MAP_PASS("Emit", PASS_EMISSION);
|
|
|
|
|
MAP_PASS("Env", PASS_BACKGROUND);
|
|
|
|
|
MAP_PASS("AO", PASS_AO);
|
|
|
|
|
MAP_PASS("Shadow", PASS_SHADOW);
|
|
|
|
|
|
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
|
|
|
MAP_PASS("BakePrimitive", PASS_BAKE_PRIMITIVE);
|
|
|
|
|
MAP_PASS("BakeDifferential", PASS_BAKE_DIFFERENTIAL);
|
|
|
|
|
|
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
|
|
|
#ifdef __KERNEL_DEBUG__
|
|
|
|
|
MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES);
|
|
|
|
|
MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES);
|
|
|
|
|
MAP_PASS("Debug BVH Intersections", PASS_BVH_INTERSECTIONS);
|
|
|
|
|
MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES);
|
|
|
|
|
#endif
|
2017-11-17 14:23:48 +01:00
|
|
|
MAP_PASS("Debug Render Time", PASS_RENDER_TIME);
|
2020-03-05 12:05:42 +01:00
|
|
|
MAP_PASS("AdaptiveAuxBuffer", PASS_ADAPTIVE_AUX_BUFFER);
|
|
|
|
|
MAP_PASS("Debug Sample Count", PASS_SAMPLE_COUNT);
|
2018-10-28 05:37:41 -04:00
|
|
|
if (string_startswith(name, cryptomatte_prefix)) {
|
|
|
|
|
return PASS_CRYPTOMATTE;
|
|
|
|
|
}
|
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
|
|
|
#undef MAP_PASS
|
|
|
|
|
|
|
|
|
|
return PASS_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-07 14:40:58 +02:00
|
|
|
int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass)
|
|
|
|
|
{
|
|
|
|
|
string name = b_pass.name();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 12:42:10 +01:00
|
|
|
if (name == "Noisy Image")
|
|
|
|
|
return DENOISING_PASS_PREFILTERED_COLOR;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-07 14:40:58 +02:00
|
|
|
if (name.substr(0, 10) != "Denoising ") {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
name = name.substr(10);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-07 14:40:58 +02:00
|
|
|
#define MAP_PASS(passname, offset) \
|
2020-09-19 16:01:32 +10:00
|
|
|
if (name == passname) { \
|
|
|
|
|
return offset; \
|
|
|
|
|
} \
|
|
|
|
|
((void)0)
|
2019-02-06 12:42:10 +01:00
|
|
|
MAP_PASS("Normal", DENOISING_PASS_PREFILTERED_NORMAL);
|
|
|
|
|
MAP_PASS("Albedo", DENOISING_PASS_PREFILTERED_ALBEDO);
|
|
|
|
|
MAP_PASS("Depth", DENOISING_PASS_PREFILTERED_DEPTH);
|
|
|
|
|
MAP_PASS("Shadowing", DENOISING_PASS_PREFILTERED_SHADOWING);
|
|
|
|
|
MAP_PASS("Variance", DENOISING_PASS_PREFILTERED_VARIANCE);
|
|
|
|
|
MAP_PASS("Intensity", DENOISING_PASS_PREFILTERED_INTENSITY);
|
2018-08-25 09:20:25 -07:00
|
|
|
MAP_PASS("Clean", DENOISING_PASS_CLEAN);
|
2017-05-07 14:40:58 +02:00
|
|
|
#undef MAP_PASS
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 19:52:01 +02:00
|
|
|
vector<Pass> BlenderSync::sync_render_passes(BL::Scene &b_scene,
|
|
|
|
|
BL::RenderLayer &b_rlay,
|
2020-03-05 12:05:42 +01:00
|
|
|
BL::ViewLayer &b_view_layer,
|
2020-05-31 23:49:10 +02:00
|
|
|
bool adaptive_sampling,
|
|
|
|
|
const DenoiseParams &denoising)
|
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
|
|
|
{
|
2018-10-28 05:37:41 -04:00
|
|
|
vector<Pass> passes;
|
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
|
|
|
/* loop over passes */
|
2021-01-25 16:20:10 +01:00
|
|
|
for (BL::RenderPass &b_pass : b_rlay.passes) {
|
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
|
|
|
PassType pass_type = get_pass_type(b_pass);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-04-12 20:57:18 +02:00
|
|
|
if (pass_type == PASS_MOTION && b_scene.render().use_motion_blur())
|
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;
|
|
|
|
|
if (pass_type != PASS_NONE)
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(pass_type, passes, b_pass.name().c_str());
|
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
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
int denoising_flags = 0;
|
2020-05-31 23:49:10 +02:00
|
|
|
if (denoising.use || denoising.store_passes) {
|
|
|
|
|
if (denoising.type == DENOISER_NLM) {
|
2018-08-25 09:20:25 -07:00
|
|
|
#define MAP_OPTION(name, flag) \
|
2020-09-19 16:01:32 +10:00
|
|
|
if (!get_boolean(crl, name)) { \
|
2020-11-04 11:17:38 +01:00
|
|
|
denoising_flags |= flag; \
|
2020-09-19 16:01:32 +10:00
|
|
|
} \
|
|
|
|
|
((void)0)
|
2019-12-11 18:11:46 +01:00
|
|
|
MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR);
|
|
|
|
|
MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND);
|
|
|
|
|
MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR);
|
|
|
|
|
MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND);
|
|
|
|
|
MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR);
|
|
|
|
|
MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND);
|
2018-08-25 09:20:25 -07:00
|
|
|
#undef MAP_OPTION
|
2019-12-11 18:11:46 +01:00
|
|
|
}
|
2018-10-28 16:41:30 +01:00
|
|
|
b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str());
|
2018-10-29 15:45:58 +01:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->film->set_denoising_flags(denoising_flags);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
if (denoising.store_passes) {
|
2018-10-30 14:13:47 +01:00
|
|
|
b_engine.add_pass("Denoising Normal", 3, "XYZ", b_view_layer.name().c_str());
|
|
|
|
|
b_engine.add_pass("Denoising Albedo", 3, "RGB", b_view_layer.name().c_str());
|
|
|
|
|
b_engine.add_pass("Denoising Depth", 1, "Z", b_view_layer.name().c_str());
|
2020-05-31 23:49:10 +02:00
|
|
|
if (denoising.type == DENOISER_NLM) {
|
2019-12-11 18:11:46 +01:00
|
|
|
b_engine.add_pass("Denoising Shadowing", 1, "X", b_view_layer.name().c_str());
|
|
|
|
|
b_engine.add_pass("Denoising Variance", 3, "RGB", b_view_layer.name().c_str());
|
|
|
|
|
b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str());
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
if (scene->film->get_denoising_flags() & DENOISING_CLEAN_ALL_PASSES) {
|
2018-10-30 14:13:47 +01:00
|
|
|
b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str());
|
2018-08-25 09:20:25 -07:00
|
|
|
}
|
2017-05-07 14:40:58 +02:00
|
|
|
}
|
2019-12-11 18:11:46 +01:00
|
|
|
|
2017-05-07 14:40:58 +02:00
|
|
|
#ifdef __KERNEL_DEBUG__
|
2020-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_bvh_traversed_nodes")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes");
|
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-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_bvh_traversed_instances")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances");
|
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-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_bvh_intersections")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections");
|
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-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_ray_bounces")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces");
|
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
|
|
|
}
|
|
|
|
|
#endif
|
2020-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_render_time")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time");
|
2017-11-17 14:23:48 +01:00
|
|
|
}
|
2020-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "pass_debug_sample_count")) {
|
2020-03-05 12:05:42 +01:00
|
|
|
b_engine.add_pass("Debug Sample Count", 1, "X", b_view_layer.name().c_str());
|
|
|
|
|
Pass::add(PASS_SAMPLE_COUNT, passes, "Debug Sample Count");
|
|
|
|
|
}
|
2020-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "use_pass_volume_direct")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir");
|
2017-11-14 07:21:07 +01:00
|
|
|
}
|
2020-05-31 23:49:10 +02:00
|
|
|
if (get_boolean(crl, "use_pass_volume_indirect")) {
|
2017-11-23 13:51:49 -02:00
|
|
|
b_engine.add_pass("VolumeInd", 3, "RGB", b_view_layer.name().c_str());
|
2019-12-04 19:57:28 +01:00
|
|
|
Pass::add(PASS_VOLUME_INDIRECT, passes, "VolumeInd");
|
2017-11-14 07:21:07 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-28 05:37:41 -04:00
|
|
|
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
|
2019-04-29 14:14:14 +10:00
|
|
|
* User facing parameter is the number of pairs. */
|
2020-12-07 07:50:14 +01:00
|
|
|
int crypto_depth = divide_up(min(16, b_view_layer.pass_cryptomatte_depth()), 2);
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->film->set_cryptomatte_depth(crypto_depth);
|
|
|
|
|
CryptomatteType cryptomatte_passes = CRYPT_NONE;
|
2020-12-07 07:50:14 +01:00
|
|
|
if (b_view_layer.use_pass_cryptomatte_object()) {
|
2020-04-03 01:47:23 +02:00
|
|
|
for (int i = 0; i < crypto_depth; i++) {
|
|
|
|
|
string passname = cryptomatte_prefix + string_printf("Object%02d", i);
|
2018-10-28 16:41:30 +01:00
|
|
|
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
2018-10-28 05:37:41 -04:00
|
|
|
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
|
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
2020-12-07 07:50:14 +01:00
|
|
|
if (b_view_layer.use_pass_cryptomatte_material()) {
|
2020-04-03 01:47:23 +02:00
|
|
|
for (int i = 0; i < crypto_depth; i++) {
|
|
|
|
|
string passname = cryptomatte_prefix + string_printf("Material%02d", i);
|
2018-10-28 16:41:30 +01:00
|
|
|
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
2018-10-28 05:37:41 -04:00
|
|
|
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
|
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
2020-12-07 07:50:14 +01:00
|
|
|
if (b_view_layer.use_pass_cryptomatte_asset()) {
|
2020-04-03 01:47:23 +02:00
|
|
|
for (int i = 0; i < crypto_depth; i++) {
|
|
|
|
|
string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
|
2018-10-28 16:41:30 +01:00
|
|
|
b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
2018-10-28 05:37:41 -04:00
|
|
|
Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
|
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
2020-12-07 07:50:14 +01:00
|
|
|
if (b_view_layer.use_pass_cryptomatte_accurate() && cryptomatte_passes != CRYPT_NONE) {
|
2020-11-04 11:17:38 +01:00
|
|
|
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ACCURATE);
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->film->set_cryptomatte_passes(cryptomatte_passes);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-05 12:05:42 +01:00
|
|
|
if (adaptive_sampling) {
|
|
|
|
|
Pass::add(PASS_ADAPTIVE_AUX_BUFFER, passes);
|
2020-05-31 23:49:10 +02:00
|
|
|
if (!get_boolean(crl, "pass_debug_sample_count")) {
|
2020-03-05 12:05:42 +01:00
|
|
|
Pass::add(PASS_SAMPLE_COUNT, passes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-12 11:29:50 +01:00
|
|
|
BL::ViewLayer::aovs_iterator b_aov_iter;
|
|
|
|
|
for (b_view_layer.aovs.begin(b_aov_iter); b_aov_iter != b_view_layer.aovs.end(); ++b_aov_iter) {
|
|
|
|
|
BL::AOV b_aov(*b_aov_iter);
|
|
|
|
|
if (!b_aov.is_valid()) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string name = b_aov.name();
|
|
|
|
|
bool is_color = b_aov.type() == BL::AOV::type_COLOR;
|
2019-12-04 19:57:28 +01:00
|
|
|
|
|
|
|
|
if (is_color) {
|
|
|
|
|
b_engine.add_pass(name.c_str(), 4, "RGBA", b_view_layer.name().c_str());
|
|
|
|
|
Pass::add(PASS_AOV_COLOR, passes, name.c_str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
b_engine.add_pass(name.c_str(), 1, "X", b_view_layer.name().c_str());
|
|
|
|
|
Pass::add(PASS_AOV_VALUE, passes, name.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->film->set_denoising_data_pass(denoising.use || denoising.store_passes);
|
|
|
|
|
scene->film->set_denoising_clean_pass(scene->film->get_denoising_flags() &
|
|
|
|
|
DENOISING_CLEAN_ALL_PASSES);
|
|
|
|
|
scene->film->set_denoising_prefiltered_pass(denoising.store_passes &&
|
|
|
|
|
denoising.type == DENOISER_NLM);
|
2020-07-28 13:01:31 +02:00
|
|
|
|
2020-11-04 11:17:38 +01:00
|
|
|
scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold());
|
2020-07-28 13:01:31 +02:00
|
|
|
scene->film->tag_passes_update(scene, passes);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
scene->integrator->tag_update(scene, Integrator::UPDATE_ALL);
|
2020-07-28 13:01:31 +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
|
|
|
return passes;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-18 16:09:19 +02:00
|
|
|
void BlenderSync::free_data_after_sync(BL::Depsgraph &b_depsgraph)
|
|
|
|
|
{
|
|
|
|
|
/* When viewport display is not needed during render we can force some
|
|
|
|
|
* caches to be releases from blender side in order to reduce peak memory
|
|
|
|
|
* footprint during synchronization process.
|
|
|
|
|
*/
|
2021-05-11 17:17:00 +02:00
|
|
|
|
2018-07-18 16:09:19 +02:00
|
|
|
const bool is_interface_locked = b_engine.render() && b_engine.render().use_lock_interface();
|
2021-05-11 17:17:00 +02:00
|
|
|
const bool is_persistent_data = b_engine.render() && b_engine.render().use_persistent_data();
|
|
|
|
|
const bool can_free_caches =
|
|
|
|
|
(BlenderSession::headless || is_interface_locked) &&
|
|
|
|
|
/* Baking re-uses the depsgraph multiple times, clearing crashes
|
|
|
|
|
* reading un-evaluated mesh data which isn't aligned with the
|
|
|
|
|
* geometry we're baking, see T71012. */
|
|
|
|
|
!scene->bake_manager->get_baking() &&
|
|
|
|
|
/* Persistent data must main caches for performance and correctness. */
|
|
|
|
|
!is_persistent_data;
|
|
|
|
|
|
2018-11-15 17:19:26 +01:00
|
|
|
if (!can_free_caches) {
|
2018-07-18 16:09:19 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/* TODO(sergey): We can actually remove the whole dependency graph,
|
|
|
|
|
* but that will need some API support first.
|
|
|
|
|
*/
|
2021-01-25 16:20:10 +01:00
|
|
|
for (BL::Object &b_ob : b_depsgraph.objects) {
|
|
|
|
|
b_ob.cache_release();
|
2018-07-18 16:09:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Scene Parameters */
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
SceneParams BlenderSync::get_scene_params(BL::Scene &b_scene, bool background)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
SceneParams params;
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if (shadingsystem == 0)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_SVM;
|
2011-04-27 11:58:34 +00:00
|
|
|
else if (shadingsystem == 1)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_OSL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-21 15:09:03 +02:00
|
|
|
if (background || DebugFlags().viewport_static_bvh)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.bvh_type = SceneParams::BVH_STATIC;
|
2011-11-04 15:46:15 +00:00
|
|
|
else
|
2017-08-21 15:09:03 +02:00
|
|
|
params.bvh_type = SceneParams::BVH_DYNAMIC;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
|
2016-07-07 18:04:16 +02:00
|
|
|
params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
|
2017-01-17 15:13:01 +01:00
|
|
|
params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-10 19:07:07 +02:00
|
|
|
PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves");
|
|
|
|
|
params.hair_subdivisions = get_int(csscene, "subdivisions");
|
|
|
|
|
params.hair_shape = (CurveShapeType)get_enum(
|
|
|
|
|
csscene, "shape", CURVE_NUM_SHAPE_TYPES, CURVE_THICK);
|
|
|
|
|
|
2016-11-17 12:13:22 +01:00
|
|
|
int texture_limit;
|
|
|
|
|
if (background) {
|
|
|
|
|
texture_limit = RNA_enum_get(&cscene, "texture_limit_render");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
texture_limit = RNA_enum_get(&cscene, "texture_limit");
|
|
|
|
|
}
|
|
|
|
|
if (texture_limit > 0 && b_scene.render().use_simplify()) {
|
|
|
|
|
params.texture_limit = 1 << (texture_limit + 6);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
params.texture_limit = 0;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-10 18:55:33 +02:00
|
|
|
params.bvh_layout = DebugFlags().cpu.bvh_layout;
|
2014-12-25 00:53:26 +05:00
|
|
|
|
Add support for tiled images and the UDIM naming scheme
This patch contains the work that I did during my week at the Code Quest - adding support for tiled images to Blender.
With this patch, images now contain a list of tiles. By default, this just contains one tile, but if the source type is set to Tiled, the user can add additional tiles. When acquiring an ImBuf, the tile to be loaded is specified in the ImageUser.
Therefore, code that is not yet aware of tiles will just access the default tile as usual.
The filenames of the additional tiles are derived from the original filename according to the UDIM naming scheme - the filename contains an index that is calculated as (1001 + 10*<y coordinate of the tile> + <x coordinate of the tile>), where the x coordinate never goes above 9.
Internally, the various tiles are stored in a cache just like sequences. When acquired for the first time, the code will try to load the corresponding file from disk. Alternatively, a new operator can be used to initialize the tile similar to the New Image operator.
The following features are supported so far:
- Automatic detection and loading of all tiles when opening the first tile (1001)
- Saving all tiles
- Adding and removing tiles
- Filling tiles with generated images
- Drawing all tiles in the Image Editor
- Viewing a tiled grid even if no image is selected
- Rendering tiled images in Eevee
- Rendering tiled images in Cycles (in SVM mode)
- Automatically skipping loading of unused tiles in Cycles
- 2D texture painting (also across tiles)
- 3D texture painting (also across tiles, only limitation: individual faces can not cross tile borders)
- Assigning custom labels to individual tiles (drawn in the Image Editor instead of the ID)
- Different resolutions between tiles
There still are some missing features that will be added later (see T72390):
- Workbench engine support
- Packing/Unpacking support
- Baking support
- Cycles OSL support
- many other Blender features that rely on images
Thanks to Brecht for the review and to all who tested the intermediate versions!
Differential Revision: https://developer.blender.org/D3509
2019-12-12 16:06:08 +01:00
|
|
|
params.background = background;
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return params;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Session Parameters */
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
bool BlenderSync::get_session_pause(BL::Scene &b_scene, bool background)
|
2011-08-29 16:54:13 +00:00
|
|
|
{
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
return (background) ? false : get_boolean(cscene, "preview_pause");
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
|
2019-02-11 13:37:45 +01:00
|
|
|
BL::Preferences &b_preferences,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Scene &b_scene,
|
2020-05-31 23:49:10 +02:00
|
|
|
bool background,
|
|
|
|
|
BL::ViewLayer b_view_layer)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
SessionParams params;
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-01 16:33:21 +00:00
|
|
|
/* feature set */
|
2016-02-10 03:25:53 +05:00
|
|
|
params.experimental = (get_enum(cscene, "feature_set") != 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-21 18:58:59 +02:00
|
|
|
/* Background */
|
|
|
|
|
params.background = background;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 16:15:45 +01:00
|
|
|
/* Device */
|
|
|
|
|
params.threads = blender_device_threads(b_scene);
|
2019-02-11 13:37:45 +01:00
|
|
|
params.device = blender_device_info(b_preferences, b_scene, params.background);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
/* samples */
|
2013-07-19 22:51:48 +00:00
|
|
|
int samples = get_int(cscene, "samples");
|
|
|
|
|
int aa_samples = get_int(cscene, "aa_samples");
|
|
|
|
|
int preview_samples = get_int(cscene, "preview_samples");
|
|
|
|
|
int preview_aa_samples = get_int(cscene, "preview_aa_samples");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
if (get_boolean(cscene, "use_square_samples")) {
|
|
|
|
|
aa_samples = aa_samples * aa_samples;
|
|
|
|
|
preview_aa_samples = preview_aa_samples * preview_aa_samples;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
samples = samples * samples;
|
|
|
|
|
preview_samples = preview_samples * preview_samples;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-01-20 13:03:09 +01:00
|
|
|
if (get_enum(cscene, "progressive") == 0 && params.device.has_branched_path) {
|
2012-06-13 11:44:48 +00:00
|
|
|
if (background) {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = aa_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = preview_aa_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
if (params.samples == 0)
|
2016-03-11 21:33:56 +01:00
|
|
|
params.samples = INT_MAX;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2011-08-28 13:55:59 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2012-06-13 11:44:48 +00:00
|
|
|
if (background) {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = preview_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
if (params.samples == 0)
|
2016-03-11 21:33:56 +01:00
|
|
|
params.samples = INT_MAX;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2011-08-28 13:55:59 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-14 17:29:18 +01:00
|
|
|
/* Clamp samples. */
|
|
|
|
|
params.samples = min(params.samples, Integrator::MAX_SAMPLES);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-17 19:24:51 +02:00
|
|
|
/* Adaptive sampling. */
|
|
|
|
|
params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
|
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
/* tiles */
|
2018-11-29 02:06:30 +01:00
|
|
|
const bool is_cpu = (params.device.type == DEVICE_CPU);
|
|
|
|
|
if (!is_cpu && !background) {
|
2012-09-04 13:29:07 +00:00
|
|
|
/* currently GPU could be much slower than CPU when using tiles,
|
|
|
|
|
* still need to be investigated, but meanwhile make it possible
|
|
|
|
|
* to work in viewport smoothly
|
|
|
|
|
*/
|
|
|
|
|
int debug_tile_size = get_int(cscene, "debug_tile_size");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
params.tile_size = make_int2(debug_tile_size, debug_tile_size);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int tile_x = b_engine.tile_x();
|
|
|
|
|
int tile_y = b_engine.tile_y();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
params.tile_size = make_int2(tile_x, tile_y);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-01 23:52:37 +01:00
|
|
|
if ((BlenderSession::headless == false) && background) {
|
2016-02-10 03:25:53 +05:00
|
|
|
params.tile_order = (TileOrder)get_enum(cscene, "tile_order");
|
2015-02-17 16:23:03 +05:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
params.tile_order = TILE_BOTTOM_TO_TOP;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
/* Denoising */
|
|
|
|
|
params.denoising = get_denoise_params(b_scene, b_view_layer, background);
|
|
|
|
|
|
|
|
|
|
if (params.denoising.use) {
|
|
|
|
|
/* Add additional denoising devices if we are rendering and denoising
|
|
|
|
|
* with different devices. */
|
|
|
|
|
params.device.add_denoising_devices(params.denoising.type);
|
|
|
|
|
|
|
|
|
|
/* Check if denoiser is supported by device. */
|
|
|
|
|
if (!(params.device.denoisers & params.denoising.type)) {
|
|
|
|
|
params.denoising.use = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Viewport Performance */
|
2012-09-17 10:55:18 +00:00
|
|
|
params.start_resolution = get_int(cscene, "preview_start_resolution");
|
2017-08-15 00:11:52 +02:00
|
|
|
params.pixel_size = b_engine.get_preview_pixel_size(b_scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* other parameters */
|
2016-05-22 19:11:26 +02:00
|
|
|
params.cancel_timeout = (double)get_float(cscene, "debug_cancel_timeout");
|
|
|
|
|
params.reset_timeout = (double)get_float(cscene, "debug_reset_timeout");
|
|
|
|
|
params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-10 02:28:23 +02:00
|
|
|
/* progressive refine */
|
2019-02-06 16:15:45 +01:00
|
|
|
BL::RenderSettings b_r = b_scene.render();
|
2020-02-11 16:30:01 +01:00
|
|
|
params.progressive_refine = b_engine.is_preview() ||
|
|
|
|
|
get_boolean(cscene, "use_progressive_refine");
|
2021-05-17 19:24:51 +02:00
|
|
|
if (b_r.use_save_buffers() || params.adaptive_sampling)
|
2020-02-11 16:30:01 +01:00
|
|
|
params.progressive_refine = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if (background) {
|
2012-10-13 12:38:32 +00:00
|
|
|
if (params.progressive_refine)
|
|
|
|
|
params.progressive = true;
|
|
|
|
|
else
|
|
|
|
|
params.progressive = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-17 10:55:18 +00:00
|
|
|
params.start_resolution = INT_MAX;
|
2017-08-15 00:11:52 +02:00
|
|
|
params.pixel_size = 1;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
params.progressive = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-10-26 09:25:02 +00:00
|
|
|
/* shading system - scene level needs full refresh */
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-10-26 09:25:02 +00:00
|
|
|
if (shadingsystem == 0)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_SVM;
|
2012-10-26 09:25:02 +00:00
|
|
|
else if (shadingsystem == 1)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_OSL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Color management. */
|
2018-08-21 00:38:54 +02:00
|
|
|
params.display_buffer_linear = b_engine.support_display_space_shader(b_scene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-02-21 17:29:27 +05:00
|
|
|
if (b_engine.is_preview()) {
|
|
|
|
|
/* For preview rendering we're using same timeout as
|
|
|
|
|
* blender's job update.
|
|
|
|
|
*/
|
|
|
|
|
params.progressive_update_timeout = 0.1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-29 02:06:30 +01:00
|
|
|
params.use_profiling = params.device.has_profiling && !b_engine.is_preview() && background &&
|
|
|
|
|
BlenderSession::print_render_stats;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return params;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene,
|
|
|
|
|
BL::ViewLayer &b_view_layer,
|
|
|
|
|
bool background)
|
|
|
|
|
{
|
|
|
|
|
DenoiseParams denoising;
|
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
|
|
|
|
|
if (background) {
|
|
|
|
|
/* Final Render Denoising */
|
|
|
|
|
denoising.use = get_boolean(cscene, "use_denoising");
|
|
|
|
|
denoising.type = (DenoiserType)get_enum(cscene, "denoiser", DENOISER_NUM, DENOISER_NONE);
|
|
|
|
|
|
|
|
|
|
if (b_view_layer) {
|
|
|
|
|
PointerRNA clayer = RNA_pointer_get(&b_view_layer.ptr, "cycles");
|
|
|
|
|
if (!get_boolean(clayer, "use_denoising")) {
|
|
|
|
|
denoising.use = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
denoising.radius = get_int(clayer, "denoising_radius");
|
|
|
|
|
denoising.strength = get_float(clayer, "denoising_strength");
|
|
|
|
|
denoising.feature_strength = get_float(clayer, "denoising_feature_strength");
|
|
|
|
|
denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca");
|
2020-07-13 16:45:15 +02:00
|
|
|
|
|
|
|
|
denoising.input_passes = (DenoiserInput)get_enum(
|
|
|
|
|
clayer,
|
|
|
|
|
(denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" :
|
|
|
|
|
"denoising_openimagedenoise_input_passes",
|
|
|
|
|
DENOISER_INPUT_NUM,
|
|
|
|
|
DENOISER_INPUT_RGB_ALBEDO_NORMAL);
|
2020-05-31 23:49:10 +02:00
|
|
|
|
|
|
|
|
denoising.store_passes = get_boolean(clayer, "denoising_store_passes");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Viewport Denoising */
|
|
|
|
|
denoising.use = get_boolean(cscene, "use_preview_denoising");
|
|
|
|
|
denoising.type = (DenoiserType)get_enum(
|
|
|
|
|
cscene, "preview_denoiser", DENOISER_NUM, DENOISER_NONE);
|
|
|
|
|
denoising.start_sample = get_int(cscene, "preview_denoising_start_sample");
|
|
|
|
|
|
2021-02-22 18:09:48 +01:00
|
|
|
denoising.input_passes = (DenoiserInput)get_enum(
|
|
|
|
|
cscene, "preview_denoising_input_passes", DENOISER_INPUT_NUM, (int)denoising.input_passes);
|
|
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
/* Auto select fastest denoiser. */
|
|
|
|
|
if (denoising.type == DENOISER_NONE) {
|
|
|
|
|
if (!Device::available_devices(DEVICE_MASK_OPTIX).empty()) {
|
|
|
|
|
denoising.type = DENOISER_OPTIX;
|
|
|
|
|
}
|
2020-06-01 00:11:17 +02:00
|
|
|
else if (openimagedenoise_supported()) {
|
|
|
|
|
denoising.type = DENOISER_OPENIMAGEDENOISE;
|
|
|
|
|
}
|
2020-05-31 23:49:10 +02:00
|
|
|
else {
|
|
|
|
|
denoising.use = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return denoising;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|