2023-06-14 08:52:36 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 13:58:34 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2020-12-10 14:18:25 +01:00
|
|
|
#include "bvh/bvh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "device/device.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/alembic.h"
|
|
|
|
#include "scene/background.h"
|
|
|
|
#include "scene/bake.h"
|
|
|
|
#include "scene/camera.h"
|
|
|
|
#include "scene/curves.h"
|
2023-04-25 20:18:44 +02:00
|
|
|
#include "scene/devicescene.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/film.h"
|
|
|
|
#include "scene/integrator.h"
|
|
|
|
#include "scene/light.h"
|
|
|
|
#include "scene/mesh.h"
|
|
|
|
#include "scene/object.h"
|
|
|
|
#include "scene/osl.h"
|
|
|
|
#include "scene/particles.h"
|
2021-12-01 17:30:46 +01:00
|
|
|
#include "scene/pointcloud.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/procedural.h"
|
|
|
|
#include "scene/scene.h"
|
|
|
|
#include "scene/shader.h"
|
|
|
|
#include "scene/svm.h"
|
|
|
|
#include "scene/tables.h"
|
|
|
|
#include "scene/volume.h"
|
|
|
|
#include "session/session.h"
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/foreach.h"
|
|
|
|
#include "util/guarded_allocator.h"
|
|
|
|
#include "util/log.h"
|
|
|
|
#include "util/progress.h"
|
2011-04-27 13:58:34 +02:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2017-10-20 05:08:26 +02:00
|
|
|
Scene::Scene(const SceneParams ¶ms_, Device *device)
|
2020-03-18 17:54:24 +01:00
|
|
|
: name("Scene"),
|
2021-03-15 18:52:45 +01:00
|
|
|
bvh(NULL),
|
2020-03-18 17:54:24 +01:00
|
|
|
default_surface(NULL),
|
|
|
|
default_volume(NULL),
|
|
|
|
default_light(NULL),
|
|
|
|
default_background(NULL),
|
|
|
|
default_empty(NULL),
|
|
|
|
device(device),
|
|
|
|
dscene(device),
|
2020-10-01 23:16:01 +02:00
|
|
|
params(params_),
|
2021-03-15 18:52:45 +01:00
|
|
|
update_stats(NULL),
|
|
|
|
kernels_loaded(false),
|
|
|
|
/* TODO(sergey): Check if it's indeed optimal value for the split kernel. */
|
|
|
|
max_closure_global(1)
|
2011-04-27 13:58:34 +02:00
|
|
|
{
|
2018-06-11 12:54:17 +02:00
|
|
|
memset((void *)&dscene.data, 0, sizeof(dscene.data));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-11-09 14:25:32 +01:00
|
|
|
shader_manager = ShaderManager::create(
|
|
|
|
device->info.has_osl ? params.shadingsystem : SHADINGSYSTEM_SVM, device);
|
2021-03-15 18:52:45 +01:00
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
light_manager = new LightManager();
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager = new GeometryManager();
|
2011-04-27 13:58:34 +02:00
|
|
|
object_manager = new ObjectManager();
|
2017-10-20 05:08:26 +02:00
|
|
|
image_manager = new ImageManager(device->info);
|
2012-08-31 19:27:08 +02:00
|
|
|
particle_system_manager = new ParticleSystemManager();
|
2014-01-02 22:05:07 +01:00
|
|
|
bake_manager = new BakeManager();
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager = new ProceduralManager();
|
2020-08-18 10:46:12 +02:00
|
|
|
|
2021-03-15 18:52:45 +01:00
|
|
|
/* Create nodes after managers, since create_node() can tag the managers. */
|
|
|
|
camera = create_node<Camera>();
|
|
|
|
dicing_camera = create_node<Camera>();
|
|
|
|
lookup_tables = new LookupTables();
|
|
|
|
film = create_node<Film>();
|
|
|
|
background = create_node<Background>();
|
|
|
|
integrator = create_node<Integrator>();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 12:15:46 +02:00
|
|
|
film->add_default(this);
|
2020-03-11 17:49:00 +01:00
|
|
|
shader_manager->add_default(this);
|
2011-04-27 13:58:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Scene::~Scene()
|
|
|
|
{
|
2012-11-09 09:46:53 +01:00
|
|
|
free_memory(true);
|
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
void Scene::free_memory(bool final)
|
|
|
|
{
|
2020-12-10 14:18:25 +01:00
|
|
|
delete bvh;
|
|
|
|
bvh = NULL;
|
|
|
|
|
2021-05-02 02:23:34 +02:00
|
|
|
/* The order of deletion is important to make sure data is freed based on possible dependencies
|
|
|
|
* as the Nodes' reference counts are decremented in the destructors:
|
|
|
|
*
|
|
|
|
* - Procedurals can create and hold pointers to any other types.
|
|
|
|
* - Objects can hold pointers to Geometries and ParticleSystems
|
|
|
|
* - Lights and Geometries can hold pointers to Shaders.
|
|
|
|
*
|
|
|
|
* Similarly, we first delete all nodes and their associated device data, and then the managers
|
|
|
|
* and their associated device data.
|
|
|
|
*/
|
2021-01-25 14:56:57 +01:00
|
|
|
foreach (Procedural *p, procedurals)
|
|
|
|
delete p;
|
2011-04-27 13:58:34 +02:00
|
|
|
foreach (Object *o, objects)
|
|
|
|
delete o;
|
2021-05-02 02:23:34 +02:00
|
|
|
foreach (Geometry *g, geometry)
|
|
|
|
delete g;
|
2012-08-31 19:27:08 +02:00
|
|
|
foreach (ParticleSystem *p, particle_systems)
|
|
|
|
delete p;
|
2021-05-02 02:23:34 +02:00
|
|
|
foreach (Light *l, lights)
|
|
|
|
delete l;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
foreach (Pass *p, passes)
|
|
|
|
delete p;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry.clear();
|
2013-02-14 17:11:47 +01:00
|
|
|
objects.clear();
|
|
|
|
lights.clear();
|
|
|
|
particle_systems.clear();
|
2021-01-25 14:56:57 +01:00
|
|
|
procedurals.clear();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
passes.clear();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
if (device) {
|
2015-10-27 09:16:04 +01:00
|
|
|
camera->device_free(device, &dscene, this);
|
2013-04-01 22:26:43 +02:00
|
|
|
film->device_free(device, &dscene, this);
|
2012-11-09 09:46:53 +01:00
|
|
|
background->device_free(device, &dscene);
|
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
|
|
|
integrator->device_free(device, &dscene, true);
|
2021-05-02 02:23:34 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-02 02:23:34 +02:00
|
|
|
if (final) {
|
|
|
|
delete camera;
|
|
|
|
delete dicing_camera;
|
|
|
|
delete film;
|
|
|
|
delete background;
|
|
|
|
delete integrator;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Delete Shaders after every other nodes to ensure that we do not try to decrement the reference
|
|
|
|
* count on some dangling pointer. */
|
|
|
|
foreach (Shader *s, shaders)
|
|
|
|
delete s;
|
|
|
|
|
|
|
|
shaders.clear();
|
|
|
|
|
|
|
|
/* Now that all nodes have been deleted, we can safely delete managers and device data. */
|
|
|
|
if (device) {
|
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
|
|
|
object_manager->device_free(device, &dscene, true);
|
|
|
|
geometry_manager->device_free(device, &dscene, true);
|
2013-04-01 22:26:52 +02:00
|
|
|
shader_manager->device_free(device, &dscene, this);
|
2012-11-09 09:46:53 +01:00
|
|
|
light_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
particle_system_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-02 22:05:07 +01:00
|
|
|
bake_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (final) {
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_free(device);
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else {
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_free_builtin(device);
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 22:26:43 +02:00
|
|
|
lookup_tables->device_free(device, &dscene);
|
2012-11-09 09:46:53 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
if (final) {
|
2013-04-01 22:26:43 +02:00
|
|
|
delete lookup_tables;
|
2012-11-09 09:46:53 +01:00
|
|
|
delete object_manager;
|
2020-02-02 12:04:19 +01:00
|
|
|
delete geometry_manager;
|
2012-11-09 09:46:53 +01:00
|
|
|
delete shader_manager;
|
|
|
|
delete light_manager;
|
|
|
|
delete particle_system_manager;
|
|
|
|
delete image_manager;
|
2014-01-02 22:05:07 +01:00
|
|
|
delete bake_manager;
|
2020-10-01 23:16:01 +02:00
|
|
|
delete update_stats;
|
2021-01-25 14:56:57 +01:00
|
|
|
delete procedural_manager;
|
2012-11-09 09:46:53 +01:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::device_update(Device *device_, Progress &progress)
|
|
|
|
{
|
2023-09-17 01:01:48 +02:00
|
|
|
if (!device) {
|
2011-04-27 13:58:34 +02:00
|
|
|
device = device_;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2016-04-22 10:55:26 +02:00
|
|
|
|
|
|
|
bool print_stats = need_data_update();
|
|
|
|
|
2021-10-21 14:52:34 +02:00
|
|
|
if (update_stats) {
|
|
|
|
update_stats->clear();
|
|
|
|
}
|
|
|
|
|
2020-10-01 23:16:01 +02:00
|
|
|
scoped_callback_timer timer([this, print_stats](double time) {
|
|
|
|
if (update_stats) {
|
|
|
|
update_stats->scene.times.add_entry({"device_update", time});
|
|
|
|
|
|
|
|
if (print_stats) {
|
|
|
|
printf("Update statistics:\n%s\n", update_stats->full_report().c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
/* The order of updates is important, because there's dependencies between
|
|
|
|
* the different managers, using data computed by previous managers.
|
|
|
|
*
|
|
|
|
* - Image manager uploads images used by shaders.
|
2014-08-02 08:53:52 +02:00
|
|
|
* - Camera may be used for adaptive subdivision.
|
2011-04-27 13:58:34 +02:00
|
|
|
* - Displacement shader must have all shader data available.
|
2014-02-06 21:09:46 +01:00
|
|
|
* - Light manager needs lookup tables and final mesh data to compute emission CDF.
|
2014-03-12 18:20:42 +01:00
|
|
|
* - Lookup tables are done a second time to handle film tables
|
2011-04-27 13:58:34 +02:00
|
|
|
*/
|
|
|
|
|
2022-04-02 00:11:11 +02:00
|
|
|
if (film->update_lightgroups(this)) {
|
|
|
|
light_manager->tag_update(this, ccl::LightManager::LIGHT_MODIFIED);
|
|
|
|
object_manager->tag_update(this, ccl::ObjectManager::OBJECT_MODIFIED);
|
2024-02-04 16:25:52 +01:00
|
|
|
background->tag_modified();
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
2022-12-15 19:13:55 +01:00
|
|
|
if (film->exposure_is_modified()) {
|
|
|
|
integrator->tag_modified();
|
|
|
|
}
|
2022-04-02 00:11:11 +02:00
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
progress.set_status("Updating Shaders");
|
|
|
|
shader_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager->update(this, progress);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel()) {
|
2021-01-25 14:56:57 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2021-01-25 14:56:57 +01:00
|
|
|
|
2013-12-28 16:56:19 +01:00
|
|
|
progress.set_status("Updating Background");
|
|
|
|
background->device_update(device, &dscene, this);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2013-12-28 16:56:19 +01:00
|
|
|
|
2015-02-02 18:06:31 +01:00
|
|
|
progress.set_status("Updating Camera");
|
|
|
|
camera->device_update(device, &dscene, this);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2015-02-02 18:06:31 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2015-02-02 18:06:31 +01:00
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->device_update_preprocess(device, this, progress);
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2016-03-31 17:54:03 +02:00
|
|
|
progress.set_status("Updating Objects");
|
|
|
|
object_manager->device_update(device, &dscene, this, progress);
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2018-01-19 04:40:48 +01:00
|
|
|
progress.set_status("Updating Particle Systems");
|
|
|
|
particle_system_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2018-01-19 04:40:48 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2018-01-19 04:40:48 +01:00
|
|
|
|
2015-04-29 22:07:38 +02:00
|
|
|
progress.set_status("Updating Meshes");
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->device_update(device, &dscene, this, progress);
|
2014-10-03 12:11:19 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2014-10-03 12:11:19 +02:00
|
|
|
|
2015-04-29 22:07:38 +02:00
|
|
|
progress.set_status("Updating Objects Flags");
|
|
|
|
object_manager->device_update_flags(device, &dscene, this, progress);
|
2015-01-19 15:08:58 +01:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2021-11-29 16:06:22 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2021-11-29 16:06:22 +01:00
|
|
|
|
|
|
|
progress.set_status("Updating Primitive Offsets");
|
|
|
|
object_manager->device_update_prim_offsets(device, &dscene, this);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2015-01-19 15:08:58 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2015-01-19 15:08:58 +01:00
|
|
|
|
2015-04-02 17:37:57 +02:00
|
|
|
progress.set_status("Updating Images");
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_update(device, this, progress);
|
2015-04-02 17:37:57 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2015-04-02 17:37:57 +02:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2015-04-02 17:37:57 +02:00
|
|
|
|
2015-02-02 18:06:31 +01:00
|
|
|
progress.set_status("Updating Camera Volume");
|
|
|
|
camera->device_update_volume(device, &dscene, this);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2015-02-02 18:06:31 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2018-11-24 22:01:14 +01:00
|
|
|
|
2014-02-06 21:09:46 +01:00
|
|
|
progress.set_status("Updating Lookup Tables");
|
2020-10-01 23:16:01 +02:00
|
|
|
lookup_tables->device_update(device, &dscene, this);
|
2014-02-06 21:09:46 +01:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2014-02-06 21:09:46 +01:00
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
progress.set_status("Updating Lights");
|
|
|
|
light_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2016-04-13 10:39:21 +02:00
|
|
|
progress.set_status("Updating Integrator");
|
|
|
|
integrator->device_update(device, &dscene, this);
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2016-04-13 10:39:21 +02:00
|
|
|
progress.set_status("Updating Film");
|
|
|
|
film->device_update(device, &dscene, this);
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
|
2014-03-12 18:20:42 +01:00
|
|
|
progress.set_status("Updating Lookup Tables");
|
2020-10-01 23:16:01 +02:00
|
|
|
lookup_tables->device_update(device, &dscene, this);
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2014-01-02 22:05:07 +01:00
|
|
|
progress.set_status("Updating Baking");
|
|
|
|
bake_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
2023-09-17 01:01:48 +02:00
|
|
|
if (progress.get_cancel() || device->have_error()) {
|
2014-12-05 17:00:05 +01:00
|
|
|
return;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2014-01-02 22:05:07 +01:00
|
|
|
|
2014-12-05 17:00:05 +01:00
|
|
|
if (device->have_error() == false) {
|
2021-10-22 14:20:22 +02:00
|
|
|
dscene.data.volume_stack_size = get_volume_stack_size();
|
|
|
|
|
2014-12-05 17:00:05 +01:00
|
|
|
progress.set_status("Updating Device", "Writing constant memory");
|
2022-06-17 17:16:37 +02:00
|
|
|
device->const_copy_to("data", &dscene.data, sizeof(dscene.data));
|
2014-12-05 17:00:05 +01:00
|
|
|
}
|
2015-02-14 15:39:14 +01:00
|
|
|
|
2022-07-12 15:32:46 +02:00
|
|
|
device->optimize_for_scene(this);
|
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
if (print_stats) {
|
2016-05-30 00:02:05 +02:00
|
|
|
size_t mem_used = util_guarded_get_mem_used();
|
|
|
|
size_t mem_peak = util_guarded_get_mem_peak();
|
|
|
|
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "System memory statistics after full device sync:\n"
|
|
|
|
<< " Usage: " << string_human_readable_number(mem_used) << " ("
|
|
|
|
<< string_human_readable_size(mem_used) << ")\n"
|
|
|
|
<< " Peak: " << string_human_readable_number(mem_peak) << " ("
|
|
|
|
<< string_human_readable_size(mem_peak) << ")";
|
2016-04-22 10:55:26 +02:00
|
|
|
}
|
2011-04-27 13:58:34 +02:00
|
|
|
}
|
|
|
|
|
2022-04-19 16:28:14 +02:00
|
|
|
Scene::MotionType Scene::need_motion() const
|
2012-04-30 14:49:26 +02:00
|
|
|
{
|
2023-09-17 01:01:48 +02:00
|
|
|
if (integrator->get_motion_blur()) {
|
2018-01-12 19:56:52 +01:00
|
|
|
return MOTION_BLUR;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else if (Pass::contains(passes, PASS_MOTION)) {
|
2012-04-30 14:49:26 +02:00
|
|
|
return MOTION_PASS;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else {
|
2012-04-30 14:49:26 +02:00
|
|
|
return MOTION_NONE;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2012-04-30 14:49:26 +02:00
|
|
|
}
|
|
|
|
|
2016-07-16 18:56:59 +02:00
|
|
|
float Scene::motion_shutter_time()
|
|
|
|
{
|
2023-09-17 01:01:48 +02:00
|
|
|
if (need_motion() == Scene::MOTION_PASS) {
|
2016-07-16 18:56:59 +02:00
|
|
|
return 2.0f;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-11-04 11:17:38 +01:00
|
|
|
return camera->get_shuttertime();
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2016-07-16 18:56:59 +02:00
|
|
|
}
|
|
|
|
|
2012-04-30 14:49:26 +02:00
|
|
|
bool Scene::need_global_attribute(AttributeStandard std)
|
|
|
|
{
|
2023-09-17 01:01:48 +02:00
|
|
|
if (std == ATTR_STD_UV) {
|
2020-08-18 12:15:46 +02:00
|
|
|
return Pass::contains(passes, PASS_UV);
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else if (std == ATTR_STD_MOTION_VERTEX_POSITION) {
|
2014-03-29 13:03:46 +01:00
|
|
|
return need_motion() != MOTION_NONE;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
else if (std == ATTR_STD_MOTION_VERTEX_NORMAL) {
|
2014-03-29 13:03:46 +01:00
|
|
|
return need_motion() == MOTION_BLUR;
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2022-04-19 16:28:14 +02:00
|
|
|
else if (std == ATTR_STD_VOLUME_VELOCITY || std == ATTR_STD_VOLUME_VELOCITY_X ||
|
|
|
|
std == ATTR_STD_VOLUME_VELOCITY_Y || std == ATTR_STD_VOLUME_VELOCITY_Z)
|
|
|
|
{
|
|
|
|
return need_motion() != MOTION_NONE;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 14:49:26 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::need_global_attributes(AttributeRequestSet &attributes)
|
|
|
|
{
|
2023-09-17 01:01:48 +02:00
|
|
|
for (int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++) {
|
|
|
|
if (need_global_attribute((AttributeStandard)std)) {
|
2012-04-30 14:49:26 +02:00
|
|
|
attributes.add((AttributeStandard)std);
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
|
|
|
}
|
2012-04-30 14:49:26 +02:00
|
|
|
}
|
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
bool Scene::need_update()
|
|
|
|
{
|
2020-11-04 11:17:38 +01:00
|
|
|
return (need_reset() || film->is_modified());
|
2011-04-27 13:58:34 +02:00
|
|
|
}
|
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
bool Scene::need_data_update()
|
2011-04-27 13:58:34 +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
|
|
|
return (background->is_modified() || image_manager->need_update() ||
|
|
|
|
object_manager->need_update() || geometry_manager->need_update() ||
|
|
|
|
light_manager->need_update() || lookup_tables->need_update() ||
|
|
|
|
integrator->is_modified() || shader_manager->need_update() ||
|
|
|
|
particle_system_manager->need_update() || bake_manager->need_update() ||
|
2021-01-25 14:56:57 +01:00
|
|
|
film->is_modified() || procedural_manager->need_update());
|
2011-04-27 13:58:34 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
bool Scene::need_reset(const bool check_camera)
|
2016-04-22 10:55:26 +02:00
|
|
|
{
|
2022-09-21 17:58:34 +02:00
|
|
|
return need_data_update() || (check_camera && camera->is_modified());
|
2016-04-22 10:55:26 +02:00
|
|
|
}
|
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
void Scene::reset()
|
|
|
|
{
|
2013-02-14 17:11:47 +01:00
|
|
|
shader_manager->reset(this);
|
2012-11-09 09:46:53 +01:00
|
|
|
shader_manager->add_default(this);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
/* ensure all objects are updated */
|
2020-11-04 11:17:38 +01:00
|
|
|
camera->tag_modified();
|
|
|
|
dicing_camera->tag_modified();
|
|
|
|
film->tag_modified();
|
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
|
|
|
background->tag_modified();
|
|
|
|
|
2012-11-09 09:46:53 +01:00
|
|
|
background->tag_update(this);
|
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
|
|
|
integrator->tag_update(this, Integrator::UPDATE_ALL);
|
|
|
|
object_manager->tag_update(this, ObjectManager::UPDATE_ALL);
|
|
|
|
geometry_manager->tag_update(this, GeometryManager::UPDATE_ALL);
|
|
|
|
light_manager->tag_update(this, LightManager::UPDATE_ALL);
|
2014-06-05 17:39:16 +02:00
|
|
|
particle_system_manager->tag_update(this);
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager->tag_update();
|
2012-11-09 09:46:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::device_free()
|
|
|
|
{
|
|
|
|
free_memory(false);
|
|
|
|
}
|
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
void Scene::collect_statistics(RenderStats *stats)
|
|
|
|
{
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->collect_statistics(this, stats);
|
2018-07-27 15:46:13 +02:00
|
|
|
image_manager->collect_statistics(stats);
|
|
|
|
}
|
|
|
|
|
2020-10-01 23:16:01 +02:00
|
|
|
void Scene::enable_update_stats()
|
|
|
|
{
|
|
|
|
if (!update_stats) {
|
|
|
|
update_stats = new SceneUpdateStats();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
void Scene::update_kernel_features()
|
2020-08-18 10:46:12 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!need_update()) {
|
|
|
|
return;
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
|
2022-11-22 18:59:32 +01:00
|
|
|
thread_scoped_lock scene_lock(mutex);
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* These features are not being tweaked as often as shaders,
|
|
|
|
* so could be done selective magic for the viewport as well. */
|
|
|
|
uint kernel_features = shader_manager->get_kernel_features(this);
|
2020-08-18 10:46:12 +02:00
|
|
|
|
|
|
|
bool use_motion = need_motion() == Scene::MotionType::MOTION_BLUR;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_PATH_TRACING;
|
|
|
|
if (params.hair_shape == CURVE_THICK) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_HAIR_THICK;
|
|
|
|
}
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
|
2022-06-30 04:14:22 +02:00
|
|
|
/* Figure out whether the scene will use shader ray-trace we need at least
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
* one caustic light, one caustic caster and one caustic receiver to use
|
2022-06-30 04:14:22 +02:00
|
|
|
* and enable the MNEE code path. */
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
bool has_caustics_receiver = false;
|
|
|
|
bool has_caustics_caster = false;
|
|
|
|
bool has_caustics_light = false;
|
|
|
|
|
2020-08-18 10:46:12 +02:00
|
|
|
foreach (Object *object, objects) {
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
if (object->get_is_caustics_caster()) {
|
|
|
|
has_caustics_caster = true;
|
|
|
|
}
|
|
|
|
else if (object->get_is_caustics_receiver()) {
|
|
|
|
has_caustics_receiver = true;
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
Geometry *geom = object->get_geometry();
|
2020-08-18 10:46:12 +02:00
|
|
|
if (use_motion) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (object->use_motion() || geom->get_use_motion_blur()) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_OBJECT_MOTION;
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (object->get_is_shadow_catcher()) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_SHADOW_CATCHER;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (geom->is_mesh()) {
|
2020-08-18 10:46:12 +02:00
|
|
|
#ifdef WITH_OPENSUBDIV
|
2021-10-26 15:38:37 +02:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
2020-11-04 11:17:38 +01:00
|
|
|
if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_PATCH_EVALUATION;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
else if (geom->is_hair()) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_HAIR;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
2021-12-01 17:30:46 +01:00
|
|
|
else if (geom->is_pointcloud()) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_POINTCLOUD;
|
|
|
|
}
|
2023-05-26 12:21:44 +02:00
|
|
|
if (object->has_light_linking()) {
|
2023-05-24 13:36:13 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_LIGHT_LINKING;
|
|
|
|
}
|
2023-05-26 12:21:44 +02:00
|
|
|
if (object->has_shadow_linking()) {
|
2023-05-24 13:36:13 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_SHADOW_LINKING;
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
foreach (Light *light, lights) {
|
|
|
|
if (light->get_use_caustics()) {
|
|
|
|
has_caustics_light = true;
|
|
|
|
}
|
2023-05-26 12:21:44 +02:00
|
|
|
|
|
|
|
if (light->has_light_linking()) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_LIGHT_LINKING;
|
|
|
|
}
|
|
|
|
if (light->has_shadow_linking()) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_SHADOW_LINKING;
|
|
|
|
}
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
dscene.data.integrator.use_caustics = false;
|
|
|
|
if (has_caustics_caster && has_caustics_receiver && has_caustics_light) {
|
|
|
|
dscene.data.integrator.use_caustics = true;
|
2022-05-30 18:04:14 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_MNEE;
|
Cycles: approximate shadow caustics using manifold next event estimation
This adds support for selective rendering of caustics in shadows of refractive
objects. Example uses are rendering of underwater caustics and eye caustics.
This is based on "Manifold Next Event Estimation", a method developed for
production rendering. The idea is to selectively enable shadow caustics on a
few objects in the scene where they have a big visual impact, without impacting
render performance for the rest of the scene.
The Shadow Caustic option must be manually enabled on light, caustic receiver
and caster objects. For such light paths, the Filter Glossy option will be
ignored and replaced by sharp caustics.
Currently this method has a various limitations:
* Only caustics in shadows of refractive objects work, which means no caustics
from reflection or caustics that outside shadows. Only up to 4 refractive
caustic bounces are supported.
* Caustic caster objects should have smooth normals.
* Not currently support for Metal GPU rendering.
In the future this method may be extended for more general caustics.
TECHNICAL DETAILS
This code adds manifold next event estimation through refractive surface(s) as a
new sampling technique for direct lighting, i.e. finding the point on the
refractive surface(s) along the path to a light sample, which satisfies Fermat's
principle for a given microfacet normal and the path's end points. This
technique involves walking on the "specular manifold" using a pseudo newton
solver. Such a manifold is defined by the specular constraint matrix from the
manifold exploration framework [2]. For each refractive interface, this
constraint is defined by enforcing that the generalized half-vector projection
onto the interface local tangent plane is null. The newton solver guides the
walk by linearizing the manifold locally before reprojecting the linear solution
onto the refractive surface. See paper [1] for more details about the technique
itself and [3] for the half-vector light transport formulation, from which it is
derived.
[1] Manifold Next Event Estimation
Johannes Hanika, Marc Droske, and Luca Fascione. 2015.
Comput. Graph. Forum 34, 4 (July 2015), 87–97.
https://jo.dreggn.org/home/2015_mnee.pdf
[2] Manifold exploration: a Markov Chain Monte Carlo technique for rendering
scenes with difficult specular transport Wenzel Jakob and Steve Marschner.
2012. ACM Trans. Graph. 31, 4, Article 58 (July 2012), 13 pages.
https://www.cs.cornell.edu/projects/manifolds-sg12/
[3] The Natural-Constraint Representation of the Path Space for Efficient
Light Transport Simulation. Anton S. Kaplanyan, Johannes Hanika, and Carsten
Dachsbacher. 2014. ACM Trans. Graph. 33, 4, Article 102 (July 2014), 13 pages.
https://cg.ivd.kit.edu/english/HSLT.php
The code for this samping technique was inserted at the light sampling stage
(direct lighting). If the walk is successful, it turns off path regularization
using a specialized flag in the path state (PATH_MNEE_SUCCESS). This flag tells
the integrator not to blur the brdf roughness further down the path (in a child
ray created from BSDF sampling). In addition, using a cascading mechanism of
flag values, we cull connections to caustic lights for this and children rays,
which should be resolved through MNEE.
This mechanism also cancels the MIS bsdf counter part at the casutic receiver
depth, in essence leaving MNEE as the only sampling technique from receivers
through refractive casters to caustic lights. This choice might not be optimal
when the light gets large wrt to the receiver, though this is usually not when
you want to use MNEE.
This connection culling strategy removes a fair amount of fireflies, at the cost
of introducing a slight bias. Because of the selective nature of the culling
mechanism, reflective caustics still benefit from the native path
regularization, which further removes fireflies on other surfaces (bouncing
light off casters).
Differential Revision: https://developer.blender.org/D13533
2022-04-01 15:44:24 +02:00
|
|
|
}
|
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
if (integrator->get_guiding_params(device).use) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_PATH_GUIDING;
|
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (bake_manager->get_baking()) {
|
|
|
|
kernel_features |= KERNEL_FEATURE_BAKING;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= film->get_kernel_features(this);
|
2021-10-26 15:30:12 +02:00
|
|
|
kernel_features |= integrator->get_kernel_features();
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
dscene.data.kernel_features = kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Currently viewport render is faster with higher max_closures, needs investigating. */
|
|
|
|
const uint max_closures = (params.background) ? get_max_closure_count() : MAX_CLOSURE;
|
|
|
|
dscene.data.max_closures = max_closures;
|
|
|
|
dscene.data.max_shaders = shaders.size();
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool Scene::update(Progress &progress)
|
|
|
|
{
|
|
|
|
if (!need_update()) {
|
|
|
|
return false;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2021-10-21 14:52:34 +02:00
|
|
|
/* Upload scene data to the GPU. */
|
|
|
|
progress.set_status("Updating Scene");
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
MEM_GUARDED_CALL(&progress, device_update, device, progress);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void log_kernel_features(const uint features)
|
|
|
|
{
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Requested features:\n";
|
|
|
|
VLOG_INFO << "Use BSDF " << string_from_bool(features & KERNEL_FEATURE_NODE_BSDF) << "\n";
|
|
|
|
VLOG_INFO << "Use Emission " << string_from_bool(features & KERNEL_FEATURE_NODE_EMISSION)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Volume " << string_from_bool(features & KERNEL_FEATURE_NODE_VOLUME) << "\n";
|
|
|
|
VLOG_INFO << "Use Bump " << string_from_bool(features & KERNEL_FEATURE_NODE_BUMP) << "\n";
|
|
|
|
VLOG_INFO << "Use Voronoi " << string_from_bool(features & KERNEL_FEATURE_NODE_VORONOI_EXTRA)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Shader Raytrace " << string_from_bool(features & KERNEL_FEATURE_NODE_RAYTRACE)
|
|
|
|
<< "\n";
|
2023-04-24 08:49:14 +02:00
|
|
|
VLOG_INFO << "Use MNEE " << string_from_bool(features & KERNEL_FEATURE_MNEE) << "\n";
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Use Transparent " << string_from_bool(features & KERNEL_FEATURE_TRANSPARENT)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Denoising " << string_from_bool(features & KERNEL_FEATURE_DENOISING) << "\n";
|
|
|
|
VLOG_INFO << "Use Path Tracing " << string_from_bool(features & KERNEL_FEATURE_PATH_TRACING)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Hair " << string_from_bool(features & KERNEL_FEATURE_HAIR) << "\n";
|
|
|
|
VLOG_INFO << "Use Pointclouds " << string_from_bool(features & KERNEL_FEATURE_POINTCLOUD)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Object Motion " << string_from_bool(features & KERNEL_FEATURE_OBJECT_MOTION)
|
|
|
|
<< "\n";
|
|
|
|
VLOG_INFO << "Use Baking " << string_from_bool(features & KERNEL_FEATURE_BAKING) << "\n";
|
|
|
|
VLOG_INFO << "Use Subsurface " << string_from_bool(features & KERNEL_FEATURE_SUBSURFACE) << "\n";
|
|
|
|
VLOG_INFO << "Use Volume " << string_from_bool(features & KERNEL_FEATURE_VOLUME) << "\n";
|
|
|
|
VLOG_INFO << "Use Patch Evaluation "
|
|
|
|
<< string_from_bool(features & KERNEL_FEATURE_PATCH_EVALUATION) << "\n";
|
|
|
|
VLOG_INFO << "Use Shadow Catcher " << string_from_bool(features & KERNEL_FEATURE_SHADOW_CATCHER)
|
|
|
|
<< "\n";
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
2022-11-22 18:59:32 +01:00
|
|
|
bool Scene::load_kernels(Progress &progress)
|
2020-08-18 10:46:12 +02:00
|
|
|
{
|
2021-10-22 14:20:22 +02:00
|
|
|
update_kernel_features();
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const uint kernel_features = dscene.data.kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!kernels_loaded || loaded_kernel_features != kernel_features) {
|
2020-08-18 10:46:12 +02:00
|
|
|
progress.set_status("Loading render kernels (may take a few minutes the first time)");
|
|
|
|
|
|
|
|
scoped_timer timer;
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
log_kernel_features(kernel_features);
|
|
|
|
if (!device->load_kernels(kernel_features)) {
|
2020-08-18 10:46:12 +02:00
|
|
|
string message = device->error_message();
|
2023-09-17 01:01:48 +02:00
|
|
|
if (message.empty()) {
|
2020-08-18 10:46:12 +02:00
|
|
|
message = "Failed loading render kernel, see console for errors";
|
2023-09-17 01:01:48 +02:00
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
|
|
|
|
progress.set_error(message);
|
|
|
|
progress.set_status(message);
|
|
|
|
progress.set_update();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
kernels_loaded = true;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
loaded_kernel_features = kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Scene::get_max_closure_count()
|
|
|
|
{
|
|
|
|
if (shader_manager->use_osl()) {
|
|
|
|
/* OSL always needs the maximum as we can't predict the
|
|
|
|
* number of closures a shader might generate. */
|
|
|
|
return MAX_CLOSURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int max_closures = 0;
|
|
|
|
for (int i = 0; i < shaders.size(); i++) {
|
|
|
|
Shader *shader = shaders[i];
|
2021-05-02 02:34:56 +02:00
|
|
|
if (shader->reference_count()) {
|
2020-08-18 10:46:12 +02:00
|
|
|
int num_closures = shader->graph->get_num_closures();
|
|
|
|
max_closures = max(max_closures, num_closures);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
max_closure_global = max(max_closure_global, max_closures);
|
|
|
|
|
|
|
|
if (max_closure_global > MAX_CLOSURE) {
|
|
|
|
/* This is usually harmless as more complex shader tend to get many
|
|
|
|
* closures discarded due to mixing or low weights. We need to limit
|
|
|
|
* to MAX_CLOSURE as this is hardcoded in CPU/mega kernels, and it
|
|
|
|
* avoids excessive memory usage for split kernels. */
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_WARNING << "Maximum number of closures exceeded: " << max_closure_global << " > "
|
|
|
|
<< MAX_CLOSURE;
|
2020-08-18 10:46:12 +02:00
|
|
|
|
|
|
|
max_closure_global = MAX_CLOSURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return max_closure_global;
|
|
|
|
}
|
|
|
|
|
2021-10-05 15:05:12 +02:00
|
|
|
int Scene::get_volume_stack_size() const
|
|
|
|
{
|
2021-10-08 16:38:40 +02:00
|
|
|
int volume_stack_size = 0;
|
|
|
|
|
|
|
|
/* Space for background volume and terminator.
|
|
|
|
* Don't do optional here because camera ray initialization expects that there is space for
|
|
|
|
* at least those elements (avoiding extra condition to check if there is actual volume or not).
|
|
|
|
*/
|
|
|
|
volume_stack_size += 2;
|
|
|
|
|
2021-10-05 15:05:12 +02:00
|
|
|
/* Quick non-expensive check. Can over-estimate maximum possible nested level, but does not
|
|
|
|
* require expensive calculation during pre-processing. */
|
2021-10-22 14:20:22 +02:00
|
|
|
bool has_volume_object = false;
|
2021-10-05 15:05:12 +02:00
|
|
|
for (const Object *object : objects) {
|
2021-10-22 14:20:22 +02:00
|
|
|
if (!object->get_geometry()->has_volume) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (object->intersects_volume) {
|
|
|
|
/* Object intersects another volume, assume it's possible to go deeper in the stack. */
|
|
|
|
/* TODO(sergey): This might count nesting twice (A intersects B and B intersects A), but
|
2021-10-25 13:25:50 +02:00
|
|
|
* can't think of a computationally cheap algorithm. Dividing my 2 doesn't work because of
|
2021-10-22 14:20:22 +02:00
|
|
|
* Venn diagram example with 3 circles. */
|
|
|
|
++volume_stack_size;
|
|
|
|
}
|
|
|
|
else if (!has_volume_object) {
|
|
|
|
/* Allocate space for at least one volume object. */
|
2021-10-08 16:38:40 +02:00
|
|
|
++volume_stack_size;
|
2021-10-05 15:05:12 +02:00
|
|
|
}
|
|
|
|
|
2021-10-22 14:20:22 +02:00
|
|
|
has_volume_object = true;
|
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
if (volume_stack_size == MAX_VOLUME_STACK_SIZE) {
|
2021-10-05 15:05:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
volume_stack_size = min(volume_stack_size, MAX_VOLUME_STACK_SIZE);
|
2021-10-05 15:05:12 +02:00
|
|
|
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_WORK << "Detected required volume stack size " << volume_stack_size;
|
2021-10-22 14:20:22 +02:00
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
return volume_stack_size;
|
2021-10-05 15:05:12 +02:00
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool Scene::has_shadow_catcher()
|
|
|
|
{
|
|
|
|
if (shadow_catcher_modified_) {
|
|
|
|
has_shadow_catcher_ = false;
|
|
|
|
for (Object *object : objects) {
|
|
|
|
if (object->get_is_shadow_catcher()) {
|
|
|
|
has_shadow_catcher_ = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
shadow_catcher_modified_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return has_shadow_catcher_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scene::tag_shadow_catcher_modified()
|
|
|
|
{
|
|
|
|
shadow_catcher_modified_ = true;
|
|
|
|
}
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<> Light *Scene::create_node<Light>()
|
|
|
|
{
|
|
|
|
Light *node = new Light();
|
|
|
|
node->set_owner(this);
|
|
|
|
lights.push_back(node);
|
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
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> Mesh *Scene::create_node<Mesh>()
|
|
|
|
{
|
|
|
|
Mesh *node = new Mesh();
|
|
|
|
node->set_owner(this);
|
|
|
|
geometry.push_back(node);
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> Hair *Scene::create_node<Hair>()
|
|
|
|
{
|
|
|
|
Hair *node = new Hair();
|
|
|
|
node->set_owner(this);
|
|
|
|
geometry.push_back(node);
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::HAIR_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> Volume *Scene::create_node<Volume>()
|
|
|
|
{
|
|
|
|
Volume *node = new Volume();
|
|
|
|
node->set_owner(this);
|
|
|
|
geometry.push_back(node);
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-12-01 17:30:46 +01:00
|
|
|
template<> PointCloud *Scene::create_node<PointCloud>()
|
|
|
|
{
|
|
|
|
PointCloud *node = new PointCloud();
|
|
|
|
node->set_owner(this);
|
|
|
|
geometry.push_back(node);
|
|
|
|
geometry_manager->tag_update(this, GeometryManager::POINT_ADDED);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<> Object *Scene::create_node<Object>()
|
|
|
|
{
|
|
|
|
Object *node = new Object();
|
|
|
|
node->set_owner(this);
|
|
|
|
objects.push_back(node);
|
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
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> ParticleSystem *Scene::create_node<ParticleSystem>()
|
|
|
|
{
|
|
|
|
ParticleSystem *node = new ParticleSystem();
|
|
|
|
node->set_owner(this);
|
|
|
|
particle_systems.push_back(node);
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> Shader *Scene::create_node<Shader>()
|
|
|
|
{
|
|
|
|
Shader *node = new Shader();
|
|
|
|
node->set_owner(this);
|
|
|
|
shaders.push_back(node);
|
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
|
|
|
shader_manager->tag_update(this, ShaderManager::SHADER_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:12:00 +01:00
|
|
|
template<> AlembicProcedural *Scene::create_node<AlembicProcedural>()
|
|
|
|
{
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
AlembicProcedural *node = new AlembicProcedural();
|
|
|
|
node->set_owner(this);
|
|
|
|
procedurals.push_back(node);
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
return node;
|
|
|
|
#else
|
|
|
|
return nullptr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> Pass *Scene::create_node<Pass>()
|
|
|
|
{
|
|
|
|
Pass *node = new Pass();
|
|
|
|
node->set_owner(this);
|
|
|
|
passes.push_back(node);
|
|
|
|
film->tag_modified();
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<typename T> void delete_node_from_array(vector<T> &nodes, T node)
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < nodes.size(); ++i) {
|
|
|
|
if (nodes[i] == node) {
|
|
|
|
std::swap(nodes[i], nodes[nodes.size() - 1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes.resize(nodes.size() - 1);
|
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
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
delete node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Light *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(lights, node);
|
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
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Mesh *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Hair *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::HAIR_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Volume *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
2021-12-01 17:30:46 +01:00
|
|
|
template<> void Scene::delete_node_impl(PointCloud *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
|
|
|
geometry_manager->tag_update(this, GeometryManager::POINT_REMOVED);
|
|
|
|
}
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<> void Scene::delete_node_impl(Geometry *node)
|
|
|
|
{
|
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
|
|
|
uint flag;
|
|
|
|
if (node->is_hair()) {
|
|
|
|
flag = GeometryManager::HAIR_REMOVED;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
flag = GeometryManager::MESH_REMOVED;
|
|
|
|
}
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
delete_node_from_array(geometry, node);
|
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
|
|
|
geometry_manager->tag_update(this, flag);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Object *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(objects, node);
|
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
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(ParticleSystem *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(particle_systems, node);
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
}
|
|
|
|
|
2021-05-02 02:34:56 +02:00
|
|
|
template<> void Scene::delete_node_impl(Shader *shader)
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
{
|
|
|
|
/* don't delete unused shaders, not supported */
|
2021-05-02 02:34:56 +02:00
|
|
|
shader->clear_reference_count();
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
template<> void Scene::delete_node_impl(Procedural *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(procedurals, node);
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:12:00 +01:00
|
|
|
template<> void Scene::delete_node_impl(AlembicProcedural *node)
|
|
|
|
{
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
delete_node_impl(static_cast<Procedural *>(node));
|
|
|
|
#else
|
|
|
|
(void)node;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> void Scene::delete_node_impl(Pass *node)
|
|
|
|
{
|
|
|
|
delete_node_from_array(passes, node);
|
|
|
|
film->tag_modified();
|
|
|
|
}
|
|
|
|
|
2020-10-29 14:40:29 +01:00
|
|
|
template<typename T>
|
|
|
|
static void remove_nodes_in_set(const set<T *> &nodes_set,
|
|
|
|
vector<T *> &nodes_array,
|
|
|
|
const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
size_t new_size = nodes_array.size();
|
|
|
|
|
|
|
|
for (size_t i = 0; i < new_size; ++i) {
|
|
|
|
T *node = nodes_array[i];
|
|
|
|
|
|
|
|
if (nodes_set.find(node) != nodes_set.end()) {
|
|
|
|
std::swap(nodes_array[i], nodes_array[new_size - 1]);
|
|
|
|
|
|
|
|
assert(node->get_owner() == owner);
|
|
|
|
delete node;
|
|
|
|
|
|
|
|
i -= 1;
|
|
|
|
new_size -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes_array.resize(new_size);
|
|
|
|
(void)owner;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Light *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, lights, owner);
|
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
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Geometry *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, geometry, owner);
|
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
|
|
|
geometry_manager->tag_update(this, GeometryManager::GEOMETRY_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Object *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, objects, owner);
|
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
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<ParticleSystem *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, particle_systems, owner);
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
}
|
|
|
|
|
2021-05-02 02:34:56 +02:00
|
|
|
template<> void Scene::delete_nodes(const set<Shader *> &nodes, const NodeOwner * /*owner*/)
|
2020-10-29 14:40:29 +01:00
|
|
|
{
|
|
|
|
/* don't delete unused shaders, not supported */
|
2021-05-02 02:34:56 +02:00
|
|
|
for (Shader *shader : nodes) {
|
|
|
|
shader->clear_reference_count();
|
|
|
|
}
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
template<> void Scene::delete_nodes(const set<Procedural *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, procedurals, owner);
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
}
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> void Scene::delete_nodes(const set<Pass *> &nodes, const NodeOwner *owner)
|
|
|
|
{
|
|
|
|
remove_nodes_in_set(nodes, passes, owner);
|
|
|
|
film->tag_modified();
|
|
|
|
}
|
|
|
|
|
2011-04-27 13:58:34 +02:00
|
|
|
CCL_NAMESPACE_END
|