2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
#include <cstdlib>
|
2014-01-02 19:05:07 -02:00
|
|
|
|
2019-05-02 15:45:31 +02:00
|
|
|
#include "device/device.h"
|
2024-12-26 17:53:59 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/background.h"
|
2024-12-26 17:53:59 +01:00
|
|
|
#include "scene/bake.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/camera.h"
|
|
|
|
|
#include "scene/film.h"
|
|
|
|
|
#include "scene/integrator.h"
|
|
|
|
|
#include "scene/light.h"
|
|
|
|
|
#include "scene/mesh.h"
|
|
|
|
|
#include "scene/object.h"
|
|
|
|
|
#include "scene/scene.h"
|
|
|
|
|
#include "scene/shader.h"
|
|
|
|
|
#include "scene/stats.h"
|
2024-12-26 17:53:59 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "session/buffers.h"
|
|
|
|
|
#include "session/session.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/hash.h"
|
|
|
|
|
#include "util/log.h"
|
|
|
|
|
#include "util/murmurhash.h"
|
|
|
|
|
#include "util/path.h"
|
|
|
|
|
#include "util/progress.h"
|
|
|
|
|
#include "util/time.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "blender/display_driver.h"
|
|
|
|
|
#include "blender/output_driver.h"
|
|
|
|
|
#include "blender/session.h"
|
|
|
|
|
#include "blender/sync.h"
|
|
|
|
|
#include "blender/util.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2020-10-02 00:48:01 +02:00
|
|
|
DeviceTypeMask BlenderSession::device_override = DEVICE_MASK_ALL;
|
2015-02-18 21:16:52 +05:00
|
|
|
bool BlenderSession::headless = false;
|
2018-07-27 15:46:13 +02:00
|
|
|
bool BlenderSession::print_render_stats = false;
|
2015-02-18 21:16:52 +05:00
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
|
2018-12-21 12:47:44 +11:00
|
|
|
BL::Preferences &b_userpref,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::BlendData &b_data,
|
2018-05-23 12:13:21 +02:00
|
|
|
bool preview_osl)
|
2024-12-26 17:53:55 +01:00
|
|
|
: session(nullptr),
|
|
|
|
|
scene(nullptr),
|
|
|
|
|
sync(nullptr),
|
2018-05-23 12:13:21 +02:00
|
|
|
b_engine(b_engine),
|
2016-01-30 14:18:29 +01:00
|
|
|
b_userpref(b_userpref),
|
|
|
|
|
b_data(b_data),
|
|
|
|
|
b_render(b_engine.render()),
|
2018-04-21 19:35:12 +02:00
|
|
|
b_depsgraph(PointerRNA_NULL),
|
2018-05-23 12:13:21 +02:00
|
|
|
b_scene(PointerRNA_NULL),
|
2016-01-30 14:18:29 +01:00
|
|
|
b_v3d(PointerRNA_NULL),
|
|
|
|
|
b_rv3d(PointerRNA_NULL),
|
2018-05-23 12:13:21 +02:00
|
|
|
width(0),
|
|
|
|
|
height(0),
|
|
|
|
|
preview_osl(preview_osl),
|
2024-12-26 17:53:55 +01:00
|
|
|
python_thread_state(nullptr),
|
2022-10-05 19:30:44 +02:00
|
|
|
use_developer_ui(b_userpref.experimental().use_cycles_debug() &&
|
|
|
|
|
b_userpref.view().show_developer_ui())
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
/* offline render */
|
|
|
|
|
background = true;
|
2013-04-24 20:12:12 +00:00
|
|
|
last_redraw_time = 0.0;
|
|
|
|
|
start_resize_time = 0.0;
|
2017-01-19 00:41:55 +01:00
|
|
|
last_status_time = 0.0;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSession::BlenderSession(BL::RenderEngine &b_engine,
|
2018-12-21 12:47:44 +11:00
|
|
|
BL::Preferences &b_userpref,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::BlendData &b_data,
|
|
|
|
|
BL::SpaceView3D &b_v3d,
|
|
|
|
|
BL::RegionView3D &b_rv3d,
|
2025-01-01 18:15:54 +01:00
|
|
|
const int width,
|
|
|
|
|
const int height)
|
2024-12-26 17:53:55 +01:00
|
|
|
: session(nullptr),
|
|
|
|
|
scene(nullptr),
|
|
|
|
|
sync(nullptr),
|
2018-05-23 12:13:21 +02:00
|
|
|
b_engine(b_engine),
|
2016-01-30 14:18:29 +01:00
|
|
|
b_userpref(b_userpref),
|
|
|
|
|
b_data(b_data),
|
2018-05-23 12:13:21 +02:00
|
|
|
b_render(b_engine.render()),
|
2018-04-21 19:35:12 +02:00
|
|
|
b_depsgraph(PointerRNA_NULL),
|
2018-05-23 12:13:21 +02:00
|
|
|
b_scene(PointerRNA_NULL),
|
2016-01-30 14:18:29 +01:00
|
|
|
b_v3d(b_v3d),
|
|
|
|
|
b_rv3d(b_rv3d),
|
|
|
|
|
width(width),
|
|
|
|
|
height(height),
|
2018-05-23 12:13:21 +02:00
|
|
|
preview_osl(false),
|
2024-12-26 17:53:55 +01:00
|
|
|
python_thread_state(nullptr),
|
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
|
|
|
use_developer_ui(b_userpref.experimental().use_cycles_debug() &&
|
|
|
|
|
b_userpref.view().show_developer_ui())
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
|
/* 3d view render */
|
|
|
|
|
background = false;
|
2013-04-24 20:12:12 +00:00
|
|
|
last_redraw_time = 0.0;
|
|
|
|
|
start_resize_time = 0.0;
|
2017-01-19 00:41:55 +01:00
|
|
|
last_status_time = 0.0;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlenderSession::~BlenderSession()
|
|
|
|
|
{
|
|
|
|
|
free_session();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderSession::create_session()
|
|
|
|
|
{
|
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 SessionParams session_params = BlenderSync::get_session_params(
|
2015-02-18 21:16:52 +05:00
|
|
|
b_engine, b_userpref, b_scene, background);
|
2022-08-11 16:59:29 +02:00
|
|
|
const SceneParams scene_params = BlenderSync::get_scene_params(
|
|
|
|
|
b_scene, background, use_developer_ui);
|
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 bool session_pause = BlenderSync::get_session_pause(b_scene, background);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-10-30 10:12:34 +00:00
|
|
|
/* reset status/progress */
|
2012-06-09 18:56:12 +00:00
|
|
|
last_status = "";
|
2014-12-05 21:27:52 +05:00
|
|
|
last_error = "";
|
2021-11-16 20:44:31 +01:00
|
|
|
last_progress = -1.0;
|
2013-04-24 20:12:12 +00:00
|
|
|
start_resize_time = 0.0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-20 05:08:26 +02:00
|
|
|
/* create session */
|
2024-12-29 23:13:45 +01:00
|
|
|
session = make_unique<Session>(session_params, scene_params);
|
2024-12-26 17:53:55 +01:00
|
|
|
session->progress.set_update_callback([this] { tag_redraw(); });
|
|
|
|
|
session->progress.set_cancel_callback([this] { test_cancel(); });
|
2017-10-20 05:08:26 +02:00
|
|
|
session->set_pause(session_pause);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* create scene */
|
2024-12-29 23:13:45 +01:00
|
|
|
scene = session->scene.get();
|
2018-11-09 16:04:53 +01:00
|
|
|
scene->name = b_scene.name();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* create sync */
|
2024-12-29 23:13:45 +01:00
|
|
|
sync = make_unique<BlenderSync>(
|
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
|
|
|
b_engine, b_data, b_scene, scene, !background, use_developer_ui, session->progress);
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Object b_camera_override(b_engine.camera_override());
|
2013-06-09 11:57:51 +00:00
|
|
|
if (b_v3d) {
|
2018-02-26 16:46:48 +01:00
|
|
|
sync->sync_view(b_v3d, b_rv3d, width, height);
|
2013-06-09 11:57:51 +00:00
|
|
|
}
|
2013-06-11 14:15:46 +00:00
|
|
|
else {
|
2016-03-11 12:57:02 +05:00
|
|
|
sync->sync_camera(b_render, b_camera_override, width, height, "");
|
2013-06-11 14:15:46 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-12-21 20:51:55 +00:00
|
|
|
/* set buffer parameters */
|
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 BufferParams buffer_params = BlenderSync::get_buffer_params(
|
|
|
|
|
b_v3d, b_rv3d, scene->camera, width, height);
|
|
|
|
|
session->reset(session_params, buffer_params);
|
2019-04-17 06:17:24 +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
|
|
|
/* Viewport and preview (as in, material preview) does not do tiled rendering, so can inform
|
|
|
|
|
* engine that no tracking of the tiles state is needed.
|
|
|
|
|
* The offline rendering will make a decision when tile is being written. The penalty of asking
|
|
|
|
|
* the engine to keep track of tiles state is minimal, so there is nothing to worry about here
|
|
|
|
|
* about possible single-tiled final render. */
|
|
|
|
|
if (!b_engine.is_preview() && !b_v3d) {
|
|
|
|
|
b_engine.use_highlight_tiles(true);
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-23 12:13:21 +02:00
|
|
|
void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph)
|
2012-11-09 08:46:53 +00:00
|
|
|
{
|
2020-05-27 18:00:59 +02:00
|
|
|
/* Update data, scene and depsgraph pointers. These can change after undo. */
|
2018-05-23 12:13:21 +02:00
|
|
|
this->b_data = b_data;
|
|
|
|
|
this->b_depsgraph = b_depsgraph;
|
|
|
|
|
this->b_scene = b_depsgraph.scene_eval();
|
2020-05-27 18:00:59 +02:00
|
|
|
if (sync) {
|
|
|
|
|
sync->reset(this->b_data, this->b_scene);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-15 17:19:26 +01:00
|
|
|
if (preview_osl) {
|
2018-05-23 12:13:21 +02:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
RNA_boolean_set(&cscene, "shading_system", preview_osl);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-15 17:19:26 +01:00
|
|
|
if (b_v3d) {
|
2018-05-23 12:13:21 +02:00
|
|
|
this->b_render = b_scene.render();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this->b_render = b_engine.render();
|
|
|
|
|
width = render_resolution_x(b_render);
|
|
|
|
|
height = render_resolution_y(b_render);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const bool is_new_session = (session == nullptr);
|
2019-08-26 17:09:26 +02:00
|
|
|
if (is_new_session) {
|
|
|
|
|
/* Initialize session and remember it was just created so not to
|
|
|
|
|
* re-create it below.
|
|
|
|
|
*/
|
|
|
|
|
create_session();
|
2018-05-23 12:13:21 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-15 17:19:26 +01:00
|
|
|
if (b_v3d) {
|
2018-05-23 12:13:21 +02:00
|
|
|
/* NOTE: We need to create session, but all the code from below
|
|
|
|
|
* will make viewport render to stuck on initialization.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +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
|
|
|
const SessionParams session_params = BlenderSync::get_session_params(
|
2015-02-18 21:16:52 +05:00
|
|
|
b_engine, b_userpref, b_scene, background);
|
2022-08-11 16:59:29 +02:00
|
|
|
const SceneParams scene_params = BlenderSync::get_scene_params(
|
|
|
|
|
b_scene, background, use_developer_ui);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-02-14 16:48:43 +00:00
|
|
|
if (scene->params.modified(scene_params) || session->params.modified(session_params) ||
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
!this->b_render.use_persistent_data())
|
|
|
|
|
{
|
2012-11-09 08:46:53 +00:00
|
|
|
/* if scene or session parameters changed, it's easier to simply re-create
|
|
|
|
|
* them rather than trying to distinguish which settings need to be updated
|
|
|
|
|
*/
|
2019-08-26 17:09:26 +02:00
|
|
|
if (!is_new_session) {
|
|
|
|
|
free_session();
|
|
|
|
|
create_session();
|
|
|
|
|
}
|
2012-11-09 08:46:53 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
session->progress.reset();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
/* peak memory usage should show current render peak, not peak for all renders
|
|
|
|
|
* made by this render session
|
|
|
|
|
*/
|
|
|
|
|
session->stats.mem_peak = session->stats.mem_used;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
if (is_new_session) {
|
|
|
|
|
/* Sync object should be re-created for new scene. */
|
2024-12-29 23:13:45 +01:00
|
|
|
sync = make_unique<BlenderSync>(
|
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
|
|
|
b_engine, b_data, b_scene, scene, !background, use_developer_ui, session->progress);
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* Sync recalculations to do just the required updates. */
|
|
|
|
|
sync->sync_recalc(b_depsgraph, b_v3d);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-03 20:11:34 +02:00
|
|
|
BL::Object b_camera_override(b_engine.camera_override());
|
|
|
|
|
sync->sync_camera(b_render, b_camera_override, width, height, "");
|
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::SpaceView3D b_null_space_view3d(PointerRNA_NULL);
|
|
|
|
|
BL::RegionView3D b_null_region_view3d(PointerRNA_NULL);
|
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 BufferParams buffer_params = BlenderSync::get_buffer_params(
|
|
|
|
|
b_null_space_view3d, b_null_region_view3d, scene->camera, width, height);
|
|
|
|
|
session->reset(session_params, buffer_params);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-24 20:12:12 +00:00
|
|
|
/* reset time */
|
|
|
|
|
start_resize_time = 0.0;
|
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
|
|
|
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(draw_state_.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
|
|
|
draw_state_.last_pass_index = -1;
|
|
|
|
|
}
|
2012-11-09 08:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void BlenderSession::free_session()
|
|
|
|
|
{
|
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 (session) {
|
|
|
|
|
session->cancel(true);
|
|
|
|
|
}
|
2020-11-11 18:39:46 +01:00
|
|
|
|
2024-12-29 23:13:45 +01:00
|
|
|
sync.reset();
|
|
|
|
|
session.reset();
|
2021-10-13 11:57:47 +02:00
|
|
|
|
|
|
|
|
display_driver_ = nullptr;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
void BlenderSession::full_buffer_written(string_view filename)
|
2012-09-04 13:29:07 +00:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
full_buffer_files_.emplace_back(filename);
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-07 04:05:47 +01:00
|
|
|
static void add_cryptomatte_layer(BL::RenderResult &b_rr, string name, string manifest)
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const string identifier = string_printf("%08x",
|
|
|
|
|
util_murmur_hash3(name.c_str(), name.length(), 0));
|
|
|
|
|
const string prefix = "cryptomatte/" + identifier.substr(0, 7) + "/";
|
2018-11-07 04:05:47 +01:00
|
|
|
|
|
|
|
|
render_add_metadata(b_rr, prefix + "name", name);
|
|
|
|
|
render_add_metadata(b_rr, prefix + "hash", "MurmurHash3_32");
|
|
|
|
|
render_add_metadata(b_rr, prefix + "conversion", "uint32_to_float32");
|
|
|
|
|
render_add_metadata(b_rr, prefix + "manifest", manifest);
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-13 14:33:29 +01:00
|
|
|
void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string &view_layer_name)
|
2019-02-06 11:49:41 +01:00
|
|
|
{
|
|
|
|
|
BL::RenderResult b_rr = b_engine.get_result();
|
2024-12-29 17:32:00 +01:00
|
|
|
const string prefix = "cycles." + view_layer_name + ".";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
/* Configured number of samples for the view layer. */
|
2019-02-13 14:33:29 +01:00
|
|
|
b_rr.stamp_data_add_field((prefix + "samples").c_str(),
|
|
|
|
|
to_string(session->params.samples).c_str());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-06 11:49:41 +01:00
|
|
|
/* Store ranged samples information. */
|
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
|
|
|
/* TODO(sergey): Need to bring this information back. */
|
|
|
|
|
#if 0
|
2019-02-06 11:49:41 +01:00
|
|
|
if (session->tile_manager.range_num_samples != -1) {
|
|
|
|
|
b_rr.stamp_data_add_field((prefix + "range_start_sample").c_str(),
|
|
|
|
|
to_string(session->tile_manager.range_start_sample).c_str());
|
|
|
|
|
b_rr.stamp_data_add_field((prefix + "range_num_samples").c_str(),
|
|
|
|
|
to_string(session->tile_manager.range_num_samples).c_str());
|
|
|
|
|
}
|
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
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-13 14:33:29 +01:00
|
|
|
/* Write cryptomatte metadata. */
|
2020-11-04 11:17:38 +01:00
|
|
|
if (scene->film->get_cryptomatte_passes() & CRYPT_OBJECT) {
|
2019-02-13 14:33:29 +01:00
|
|
|
add_cryptomatte_layer(b_rr,
|
|
|
|
|
view_layer_name + ".CryptoObject",
|
2019-03-04 09:51:36 +01:00
|
|
|
scene->object_manager->get_cryptomatte_objects(scene));
|
2019-02-13 14:33:29 +01:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (scene->film->get_cryptomatte_passes() & CRYPT_MATERIAL) {
|
2019-02-13 14:33:29 +01:00
|
|
|
add_cryptomatte_layer(b_rr,
|
|
|
|
|
view_layer_name + ".CryptoMaterial",
|
2019-03-04 09:51:36 +01:00
|
|
|
scene->shader_manager->get_cryptomatte_materials(scene));
|
2019-02-13 14:33:29 +01:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (scene->film->get_cryptomatte_passes() & CRYPT_ASSET) {
|
2019-02-13 14:33:29 +01:00
|
|
|
add_cryptomatte_layer(b_rr,
|
|
|
|
|
view_layer_name + ".CryptoAsset",
|
2019-03-04 09:51:36 +01:00
|
|
|
scene->object_manager->get_cryptomatte_assets(scene));
|
2019-02-13 14:33:29 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-04 11:31:20 +01:00
|
|
|
/* Store synchronization and bare-render times. */
|
2024-12-29 17:32:00 +01:00
|
|
|
double total_time;
|
|
|
|
|
double render_time;
|
2019-03-04 11:31:20 +01:00
|
|
|
session->progress.get_time(total_time, render_time);
|
|
|
|
|
b_rr.stamp_data_add_field((prefix + "total_time").c_str(),
|
2019-03-19 18:54:17 +01:00
|
|
|
time_human_readable_from_seconds(total_time).c_str());
|
2019-03-04 11:31:20 +01:00
|
|
|
b_rr.stamp_data_add_field((prefix + "render_time").c_str(),
|
2019-03-19 18:54:17 +01:00
|
|
|
time_human_readable_from_seconds(render_time).c_str());
|
2019-03-04 11:31:20 +01:00
|
|
|
b_rr.stamp_data_add_field((prefix + "synchronization_time").c_str(),
|
2019-03-19 18:54:17 +01:00
|
|
|
time_human_readable_from_seconds(total_time - render_time).c_str());
|
2019-02-06 11:49:41 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-21 19:35:12 +02:00
|
|
|
void BlenderSession::render(BL::Depsgraph &b_depsgraph_)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2018-04-21 19:35:12 +02:00
|
|
|
b_depsgraph = b_depsgraph_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-28 19:55:41 +01:00
|
|
|
if (session->progress.get_cancel()) {
|
|
|
|
|
update_status_progress();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 16:51:03 +02:00
|
|
|
/* Create driver to write out render results. */
|
2021-10-13 11:08:11 +02:00
|
|
|
ensure_display_driver_if_needed();
|
2021-09-30 16:51:03 +02:00
|
|
|
session->set_output_driver(make_unique<BlenderOutputDriver>(b_engine));
|
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
|
|
|
|
|
|
|
|
session->full_buffer_written_cb = [&](string_view filename) { full_buffer_written(filename); };
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
|
|
|
|
|
|
2011-12-21 20:51:55 +00:00
|
|
|
/* get buffer parameters */
|
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 SessionParams session_params = BlenderSync::get_session_params(
|
|
|
|
|
b_engine, b_userpref, b_scene, background);
|
2020-06-24 17:08:01 +02:00
|
|
|
BufferParams buffer_params = BlenderSync::get_buffer_params(
|
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
|
|
|
b_v3d, b_rv3d, scene->camera, width, height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* temporary render result to find needed passes and views */
|
2024-12-26 17:53:55 +01:00
|
|
|
BL::RenderResult b_rr = b_engine.begin_result(0, 0, 1, 1, b_view_layer.name().c_str(), nullptr);
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::RenderResult::layers_iterator b_single_rlay;
|
|
|
|
|
b_rr.layers.begin(b_single_rlay);
|
|
|
|
|
BL::RenderLayer b_rlay = *b_single_rlay;
|
2019-04-17 06:17:24 +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
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(draw_state_.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
|
|
|
b_rlay_name = b_view_layer.name();
|
2019-04-17 06:17:24 +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
|
|
|
/* Signal that the display pass is to be updated. */
|
|
|
|
|
draw_state_.last_pass_index = -1;
|
|
|
|
|
}
|
2020-05-31 23:49:10 +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
|
|
|
/* Compute render passes and film settings. */
|
|
|
|
|
sync->sync_render_passes(b_rlay, b_view_layer);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::RenderResult::views_iterator b_view_iter;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-25 11:05:04 -02:00
|
|
|
int num_views = 0;
|
|
|
|
|
for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter) {
|
|
|
|
|
num_views++;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
int view_index = 0;
|
|
|
|
|
for (b_rr.views.begin(b_view_iter); b_view_iter != b_rr.views.end(); ++b_view_iter, ++view_index)
|
|
|
|
|
{
|
|
|
|
|
b_rview_name = b_view_iter->name();
|
2019-04-17 06:17:24 +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
|
|
|
buffer_params.layer = b_view_layer.name();
|
|
|
|
|
buffer_params.view = b_rview_name;
|
|
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* set the current view */
|
|
|
|
|
b_engine.active_view_set(b_rview_name.c_str());
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-15 20:25:41 +01:00
|
|
|
/* Force update in this case, since the camera transform on each frame changes
|
|
|
|
|
* in different views. This could be optimized by somehow storing the animated
|
|
|
|
|
* camera transforms separate from the fixed stereo transform. */
|
|
|
|
|
if ((scene->need_motion() != Scene::MOTION_NONE) && view_index > 0) {
|
|
|
|
|
sync->tag_update();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* update scene */
|
|
|
|
|
BL::Object b_camera_override(b_engine.camera_override());
|
|
|
|
|
sync->sync_camera(b_render, b_camera_override, width, height, b_rview_name.c_str());
|
2024-03-08 16:26:52 +01:00
|
|
|
sync->sync_data(b_render,
|
|
|
|
|
b_depsgraph,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_camera_override,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
&python_thread_state,
|
2024-06-24 11:28:02 +02:00
|
|
|
session_params.denoise_device);
|
2024-04-15 17:40:53 +02:00
|
|
|
|
|
|
|
|
/* At the moment we only free if we are not doing multi-view
|
|
|
|
|
* (or if we are rendering the last view). See #58142/D4239 for discussion.
|
|
|
|
|
*/
|
|
|
|
|
const bool can_free_cache = (view_index == num_views - 1);
|
|
|
|
|
if (can_free_cache) {
|
|
|
|
|
sync->free_data_after_sync(b_depsgraph);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-11 16:29:49 +02:00
|
|
|
builtin_images_load();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-09 16:14:15 +01:00
|
|
|
/* Attempt to free all data which is held by Blender side, since at this
|
2019-08-02 12:00:07 +10:00
|
|
|
* point we know that we've got everything to render current view layer.
|
2018-11-09 16:14:15 +01:00
|
|
|
*/
|
2024-04-15 17:40:53 +02:00
|
|
|
if (can_free_cache) {
|
2019-01-25 11:05:04 -02:00
|
|
|
free_blender_memory_if_possible();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 21:14:11 +10:00
|
|
|
/* Make sure all views have different noise patterns. - hardcoded value just to make it random
|
|
|
|
|
*/
|
2018-02-26 16:46:48 +01:00
|
|
|
if (view_index != 0) {
|
2020-11-04 11:17:38 +01:00
|
|
|
int seed = scene->integrator->get_seed();
|
|
|
|
|
seed += hash_uint2(seed, hash_uint2(view_index * 0xdeadbeef, 0));
|
|
|
|
|
scene->integrator->set_seed(seed);
|
2018-02-26 16:46:48 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-28 18:37:05 +01:00
|
|
|
/* Update number of samples per layer. */
|
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 int samples = sync->get_layer_samples();
|
|
|
|
|
const bool bound_samples = sync->get_layer_bound_samples();
|
2019-04-17 06:17:24 +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
|
|
|
SessionParams effective_session_params = session_params;
|
|
|
|
|
if (samples != 0 && (!bound_samples || (samples < session_params.samples))) {
|
|
|
|
|
effective_session_params.samples = samples;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* Update session itself. */
|
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
|
|
|
session->reset(effective_session_params, buffer_params);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* render */
|
2020-10-01 23:16:01 +02:00
|
|
|
if (!b_engine.is_preview() && background && print_render_stats) {
|
|
|
|
|
scene->enable_update_stats();
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
session->start();
|
|
|
|
|
session->wait();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
if (!b_engine.is_preview() && background && print_render_stats) {
|
|
|
|
|
RenderStats stats;
|
2018-11-29 02:06:30 +01:00
|
|
|
session->collect_statistics(&stats);
|
2018-07-27 15:46:13 +02:00
|
|
|
printf("Render statistics:\n%s\n", stats.full_report().c_str());
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (session->progress.get_cancel()) {
|
2011-12-21 20:51:55 +00:00
|
|
|
break;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2011-12-21 20:51:55 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-13 14:33:29 +01:00
|
|
|
/* add metadata */
|
|
|
|
|
stamp_view_layer_metadata(scene, b_rlay_name);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
/* free result without merging */
|
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
|
|
|
b_engine.end_result(b_rr, true, false, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-23 10:41:06 +02:00
|
|
|
/* When tiled rendering is used there will be no "write" done for the tile. Forcefully clear
|
|
|
|
|
* highlighted tiles now, so that the highlight will be removed while processing full frame from
|
|
|
|
|
* file. */
|
|
|
|
|
b_engine.tile_highlight_clear_all();
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
double total_time;
|
|
|
|
|
double render_time;
|
2015-06-17 11:56:19 +02:00
|
|
|
session->progress.get_time(total_time, render_time);
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Total render time: " << total_time;
|
|
|
|
|
VLOG_INFO << "Render time (without synchronization): " << render_time;
|
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 BlenderSession::render_frame_finish()
|
|
|
|
|
{
|
|
|
|
|
/* Processing of all layers and views is done. Clear the strings so that we can communicate
|
|
|
|
|
* progress about reading files and denoising them. */
|
|
|
|
|
b_rlay_name = "";
|
|
|
|
|
b_rview_name = "";
|
|
|
|
|
|
|
|
|
|
if (!b_render.use_persistent_data()) {
|
|
|
|
|
/* Free the sync object so that it can properly dereference nodes from the scene graph before
|
|
|
|
|
* the graph is freed. */
|
2024-12-29 23:13:45 +01:00
|
|
|
sync.reset();
|
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
|
|
|
|
|
|
|
|
session->device_free();
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
for (const string_view filename : full_buffer_files_) {
|
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
|
|
|
session->process_full_buffer_from_disk(filename);
|
2021-09-23 17:20:59 +02:00
|
|
|
if (check_and_report_session_error()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
for (const string_view filename : full_buffer_files_) {
|
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
|
|
|
path_remove(filename);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-01-10 15:56:44 +01:00
|
|
|
/* Clear output driver. */
|
2021-09-30 16:51:03 +02:00
|
|
|
session->set_output_driver(nullptr);
|
2024-12-26 17:53:55 +01:00
|
|
|
session->full_buffer_written_cb = nullptr;
|
2021-10-04 11:53:46 +02:00
|
|
|
|
2022-02-18 14:31:39 +01:00
|
|
|
/* The display driver is the source of drawing context for both drawing and possible graphics
|
2022-11-01 12:24:06 +11:00
|
|
|
* interoperability objects in the path trace. Once the frame is finished the OpenGL context
|
|
|
|
|
* might be freed form Blender side. Need to ensure that all GPU resources are freed prior to
|
|
|
|
|
* that point.
|
2022-02-18 14:31:39 +01:00
|
|
|
* Ideally would only do this when OpenGL context is actually destroyed, but there is no way to
|
|
|
|
|
* know when this happens (at least in the code at the time when this comment was written).
|
|
|
|
|
* The penalty of re-creating resources on every frame is unlikely to be noticed. */
|
2022-01-10 15:56:44 +01:00
|
|
|
display_driver_ = nullptr;
|
|
|
|
|
session->set_display_driver(nullptr);
|
|
|
|
|
|
2021-10-04 11:53:46 +02:00
|
|
|
/* All the files are handled.
|
2021-10-04 12:01:57 +02:00
|
|
|
* Clear the list so that this session can be re-used by Persistent Data. */
|
2021-10-04 11:53:46 +02:00
|
|
|
full_buffer_files_.clear();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2023-06-14 02:38:35 +02:00
|
|
|
static bool bake_setup_pass(Scene *scene, const string &bake_type, const int bake_filter)
|
2016-01-15 13:00:56 -02:00
|
|
|
{
|
2022-04-28 18:29:13 +02:00
|
|
|
Integrator *integrator = scene->integrator;
|
2023-05-12 17:19:14 +02:00
|
|
|
Film *film = scene->film;
|
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
|
|
|
|
2023-06-14 02:39:24 +02:00
|
|
|
const bool filter_direct = (bake_filter & BL::BakeSettings::pass_filter_DIRECT) != 0;
|
|
|
|
|
const bool filter_indirect = (bake_filter & BL::BakeSettings::pass_filter_INDIRECT) != 0;
|
|
|
|
|
const bool filter_color = (bake_filter & BL::BakeSettings::pass_filter_COLOR) != 0;
|
|
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
PassType type = PASS_NONE;
|
|
|
|
|
bool use_direct_light = false;
|
|
|
|
|
bool use_indirect_light = false;
|
|
|
|
|
bool include_albedo = false;
|
|
|
|
|
|
|
|
|
|
/* Data passes. */
|
2023-06-14 02:38:35 +02:00
|
|
|
if (bake_type == "POSITION") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_POSITION;
|
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
|
|
|
}
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "NORMAL") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_NORMAL;
|
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
|
|
|
}
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "UV") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_UV;
|
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
|
|
|
}
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "ROUGHNESS") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_ROUGHNESS;
|
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
|
|
|
}
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "EMIT") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_EMISSION;
|
|
|
|
|
}
|
|
|
|
|
/* Environment pass. */
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "ENVIRONMENT") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_BACKGROUND;
|
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
|
|
|
}
|
2023-05-12 17:19:14 +02:00
|
|
|
/* AO pass. */
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "AO") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_AO;
|
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
|
|
|
}
|
2023-05-12 17:19:14 +02:00
|
|
|
/* Shadow pass. */
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "SHADOW") {
|
2023-05-12 17:19:14 +02:00
|
|
|
/* Bake as combined pass, together with marking the object as a shadow catcher. */
|
|
|
|
|
type = PASS_SHADOW_CATCHER;
|
|
|
|
|
film->set_use_approximate_shadow_catcher(true);
|
|
|
|
|
|
|
|
|
|
use_direct_light = true;
|
|
|
|
|
use_indirect_light = true;
|
|
|
|
|
include_albedo = true;
|
|
|
|
|
|
|
|
|
|
integrator->set_use_diffuse(true);
|
|
|
|
|
integrator->set_use_glossy(true);
|
|
|
|
|
integrator->set_use_transmission(true);
|
|
|
|
|
integrator->set_use_emission(true);
|
|
|
|
|
}
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Combined pass. */
|
2023-06-14 02:38:35 +02:00
|
|
|
else if (bake_type == "COMBINED") {
|
2022-04-28 18:29:13 +02:00
|
|
|
type = PASS_COMBINED;
|
2023-05-12 17:19:14 +02:00
|
|
|
film->set_use_approximate_shadow_catcher(true);
|
2022-04-28 18:29:13 +02:00
|
|
|
|
2023-06-14 02:39:24 +02:00
|
|
|
use_direct_light = filter_direct;
|
|
|
|
|
use_indirect_light = filter_indirect;
|
|
|
|
|
include_albedo = filter_color;
|
2022-04-28 18:29:13 +02:00
|
|
|
|
|
|
|
|
integrator->set_use_diffuse((bake_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0);
|
|
|
|
|
integrator->set_use_glossy((bake_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0);
|
|
|
|
|
integrator->set_use_transmission((bake_filter & BL::BakeSettings::pass_filter_TRANSMISSION) !=
|
|
|
|
|
0);
|
|
|
|
|
integrator->set_use_emission((bake_filter & BL::BakeSettings::pass_filter_EMIT) != 0);
|
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
|
|
|
}
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Light component passes. */
|
2023-06-14 02:39:24 +02:00
|
|
|
else if ((bake_type == "DIFFUSE") || (bake_type == "GLOSSY") || (bake_type == "TRANSMISSION")) {
|
|
|
|
|
use_direct_light = filter_direct;
|
|
|
|
|
use_indirect_light = filter_indirect;
|
|
|
|
|
include_albedo = filter_color;
|
|
|
|
|
|
2023-06-14 02:40:37 +02:00
|
|
|
integrator->set_use_diffuse(bake_type == "DIFFUSE");
|
|
|
|
|
integrator->set_use_glossy(bake_type == "GLOSSY");
|
|
|
|
|
integrator->set_use_transmission(bake_type == "TRANSMISSION");
|
|
|
|
|
|
2023-06-14 02:39:24 +02:00
|
|
|
if (bake_type == "DIFFUSE") {
|
|
|
|
|
if (filter_direct && filter_indirect) {
|
|
|
|
|
type = PASS_DIFFUSE;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_direct) {
|
|
|
|
|
type = PASS_DIFFUSE_DIRECT;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_indirect) {
|
|
|
|
|
type = PASS_DIFFUSE_INDIRECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
type = PASS_DIFFUSE_COLOR;
|
|
|
|
|
}
|
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
|
|
|
}
|
2023-06-14 02:39:24 +02:00
|
|
|
else if (bake_type == "GLOSSY") {
|
|
|
|
|
if (filter_direct && filter_indirect) {
|
|
|
|
|
type = PASS_GLOSSY;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_direct) {
|
|
|
|
|
type = PASS_GLOSSY_DIRECT;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_indirect) {
|
|
|
|
|
type = PASS_GLOSSY_INDIRECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
type = PASS_GLOSSY_COLOR;
|
|
|
|
|
}
|
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
|
|
|
}
|
2023-06-14 02:39:24 +02:00
|
|
|
else if (bake_type == "TRANSMISSION") {
|
|
|
|
|
if (filter_direct && filter_indirect) {
|
|
|
|
|
type = PASS_TRANSMISSION;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_direct) {
|
|
|
|
|
type = PASS_TRANSMISSION_DIRECT;
|
|
|
|
|
}
|
|
|
|
|
else if (filter_indirect) {
|
|
|
|
|
type = PASS_TRANSMISSION_INDIRECT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
type = PASS_TRANSMISSION_COLOR;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
}
|
2022-04-28 18:29:13 +02:00
|
|
|
|
|
|
|
|
if (type == PASS_NONE) {
|
|
|
|
|
return false;
|
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
|
|
|
}
|
|
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Create pass. */
|
|
|
|
|
Pass *pass = scene->create_node<Pass>();
|
|
|
|
|
pass->set_name(ustring("Combined"));
|
|
|
|
|
pass->set_type(type);
|
|
|
|
|
pass->set_include_albedo(include_albedo);
|
|
|
|
|
|
|
|
|
|
/* Disable direct indirect light for performance when not needed. */
|
|
|
|
|
integrator->set_use_direct_light(use_direct_light);
|
|
|
|
|
integrator->set_use_indirect_light(use_indirect_light);
|
|
|
|
|
|
2024-02-01 14:40:50 +01:00
|
|
|
/* Disable denoiser if the pass does not support it.
|
|
|
|
|
* For the passes which support denoising follow the user configuration. */
|
2024-01-25 15:56:20 +01:00
|
|
|
const PassInfo pass_info = Pass::get_info(type);
|
2024-02-01 14:40:50 +01:00
|
|
|
if (integrator->get_use_denoise() && !pass_info.support_denoise) {
|
|
|
|
|
integrator->set_use_denoise(false);
|
|
|
|
|
}
|
2024-01-25 15:56:20 +01:00
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
return true;
|
2016-01-15 13:00:56 -02:00
|
|
|
}
|
|
|
|
|
|
2018-04-21 19:35:12 +02:00
|
|
|
void BlenderSession::bake(BL::Depsgraph &b_depsgraph_,
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Object &b_object,
|
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 string &bake_type,
|
|
|
|
|
const int bake_filter,
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
const int bake_width,
|
|
|
|
|
const int bake_height)
|
2014-01-02 19:05:07 -02:00
|
|
|
{
|
2018-04-21 19:35:12 +02:00
|
|
|
b_depsgraph = b_depsgraph_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-03-08 16:26:52 +01:00
|
|
|
/* Get session parameters. */
|
|
|
|
|
const SessionParams session_params = BlenderSync::get_session_params(
|
|
|
|
|
b_engine, b_userpref, b_scene, background);
|
|
|
|
|
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
/* Initialize bake manager, before we load the baking kernels. */
|
2025-01-02 12:48:21 +01:00
|
|
|
scene->bake_manager->set_baking(scene, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-14 15:37:47 +02:00
|
|
|
session->set_display_driver(nullptr);
|
2021-09-30 16:51:03 +02:00
|
|
|
session->set_output_driver(make_unique<BlenderOutputDriver>(b_engine));
|
2022-08-30 17:20:00 +02:00
|
|
|
session->full_buffer_written_cb = [&](string_view filename) { full_buffer_written(filename); };
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Sync scene. */
|
|
|
|
|
BL::Object b_camera_override(b_engine.camera_override());
|
2025-01-02 12:48:21 +01:00
|
|
|
sync->set_bake_target(b_object);
|
2022-04-28 18:29:13 +02:00
|
|
|
sync->sync_camera(b_render, b_camera_override, width, height, "");
|
2024-03-08 16:26:52 +01:00
|
|
|
sync->sync_data(b_render,
|
|
|
|
|
b_depsgraph,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_camera_override,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
&python_thread_state,
|
2024-06-24 11:28:02 +02:00
|
|
|
session_params.denoise_device);
|
2021-11-18 16:07:47 +01:00
|
|
|
|
2024-02-01 14:40:50 +01:00
|
|
|
/* Save the current state of the denoiser, as it might be disabled by the pass configuration (for
|
|
|
|
|
* passed which do not support denoising). */
|
|
|
|
|
Integrator *integrator = scene->integrator;
|
|
|
|
|
const bool was_denoiser_enabled = integrator->get_use_denoise();
|
|
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Add render pass that we want to bake, and name it Combined so that it is
|
|
|
|
|
* used as that on the Blender side. */
|
|
|
|
|
if (!bake_setup_pass(scene, bake_type, bake_filter)) {
|
|
|
|
|
session->cancel(true);
|
|
|
|
|
}
|
2021-11-18 16:07:47 +01:00
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
/* Always use transparent background for baking. */
|
|
|
|
|
scene->background->set_transparent(true);
|
2021-11-18 16:07:47 +01:00
|
|
|
|
2022-04-28 18:29:13 +02:00
|
|
|
if (!session->progress.get_cancel()) {
|
2021-11-18 16:07:47 +01:00
|
|
|
/* Load built-in images from Blender. */
|
2018-06-11 16:29:49 +02:00
|
|
|
builtin_images_load();
|
2017-05-13 07:09:22 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
/* Object might have been disabled for rendering or excluded in some
|
|
|
|
|
* other way, in that case Blender will report a warning afterwards. */
|
2023-05-12 17:19:14 +02:00
|
|
|
Object *bake_object = nullptr;
|
2022-04-28 18:29:13 +02:00
|
|
|
if (!session->progress.get_cancel()) {
|
2025-01-02 12:48:21 +01:00
|
|
|
for (Object *ob : scene->objects) {
|
|
|
|
|
if (ob->get_is_bake_target()) {
|
2023-05-12 17:19:14 +02:00
|
|
|
bake_object = ob;
|
2022-04-28 18:29:13 +02:00
|
|
|
break;
|
|
|
|
|
}
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-12 17:19:14 +02:00
|
|
|
/* For the shadow pass, temporarily mark the object as a shadow catcher. */
|
|
|
|
|
const bool was_shadow_catcher = (bake_object) ? bake_object->get_is_shadow_catcher() : false;
|
|
|
|
|
if (bake_object && bake_type == "SHADOW") {
|
|
|
|
|
bake_object->set_is_shadow_catcher(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bake_object && !session->progress.get_cancel()) {
|
2024-03-08 16:26:52 +01:00
|
|
|
/* Get buffer parameters. */
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
BufferParams buffer_params;
|
|
|
|
|
buffer_params.width = bake_width;
|
|
|
|
|
buffer_params.height = bake_height;
|
2022-08-30 17:20:00 +02:00
|
|
|
buffer_params.window_width = bake_width;
|
|
|
|
|
buffer_params.window_height = bake_height;
|
|
|
|
|
/* Unique layer name for multi-image baking. */
|
2022-09-08 20:23:02 +02:00
|
|
|
buffer_params.layer = string_printf("bake_%d\n", bake_id++);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
/* Update session. */
|
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
|
|
|
session->reset(session_params, buffer_params);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:55 +01:00
|
|
|
session->progress.set_update_callback([this] { update_bake_progress(); });
|
2017-05-13 07:09:22 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-13 07:09:22 +02:00
|
|
|
/* Perform bake. Check cancel to avoid crash with incomplete scene data. */
|
2023-05-12 17:19:14 +02:00
|
|
|
if (bake_object && !session->progress.get_cancel()) {
|
Cycles: code refactor to bake using regular render session and tiles
There should be no user visible change from this, except that tile size
now affects performance. The goal here is to simplify bake denoising in
D3099, letting it reuse more denoising tiles and pass code.
A lot of code is now shared with regular rendering, with the two main
differences being that we read some render result passes from the bake API
when starting to render a tile, and call the bake kernel instead of the
path trace kernel.
With this kind of design where Cycles asks for tiles from the bake API,
it should eventually be easier to reduce memory usage, show tiles as
they are baked, or bake multiple passes at once, though there's still
quite some work needed for that.
Reviewers: #cycles
Subscribers: monio, wmatyjewicz, lukasstockner97, michaelknubben
Differential Revision: https://developer.blender.org/D3108
2019-05-10 21:39:58 +02:00
|
|
|
session->start();
|
|
|
|
|
session->wait();
|
2017-05-13 07:09:22 +02:00
|
|
|
}
|
2023-05-12 17:19:14 +02:00
|
|
|
|
|
|
|
|
/* Restore object state. */
|
|
|
|
|
if (bake_object) {
|
|
|
|
|
bake_object->set_is_shadow_catcher(was_shadow_catcher);
|
|
|
|
|
}
|
2024-02-01 14:40:50 +01:00
|
|
|
|
|
|
|
|
/* Restore the state of denoiser to before it was possibly disabled by the pass, so that the
|
|
|
|
|
* next baking pass can use the original value. */
|
|
|
|
|
integrator->set_use_denoise(was_denoiser_enabled);
|
2012-09-04 13:29:07 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-21 19:35:12 +02:00
|
|
|
void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2013-06-09 11:57:51 +00:00
|
|
|
/* only used for viewport render */
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!b_v3d) {
|
2013-06-09 11:57:51 +00:00
|
|
|
return;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* on session/scene parameter changes, we recreate session entirely */
|
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 SessionParams session_params = BlenderSync::get_session_params(
|
2015-02-18 21:16:52 +05:00
|
|
|
b_engine, b_userpref, b_scene, background);
|
2022-08-11 16:59:29 +02:00
|
|
|
const SceneParams scene_params = BlenderSync::get_scene_params(
|
|
|
|
|
b_scene, background, use_developer_ui);
|
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 bool session_pause = BlenderSync::get_session_pause(b_scene, background);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if (session->params.modified(session_params) || scene->params.modified(scene_params)) {
|
|
|
|
|
free_session();
|
|
|
|
|
create_session();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-13 11:57:47 +02:00
|
|
|
ensure_display_driver_if_needed();
|
|
|
|
|
|
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
|
|
|
/* increase samples and render time, but never decrease */
|
2011-09-16 13:14:02 +00:00
|
|
|
session->set_samples(session_params.samples);
|
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
|
|
|
session->set_time_limit(session_params.time_limit);
|
2014-08-01 16:39:05 +06:00
|
|
|
session->set_pause(session_pause);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* copy recalc flags, outside of mutex so we can decide to do the real
|
2012-06-09 17:22:52 +00:00
|
|
|
* synchronization at a later time to not block on running updates */
|
2019-08-27 15:47:30 +02:00
|
|
|
sync->sync_recalc(b_depsgraph_, b_v3d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-01 16:39:05 +06:00
|
|
|
/* don't do synchronization if on pause */
|
|
|
|
|
if (session_pause) {
|
|
|
|
|
tag_update();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* try to acquire mutex. if we don't want to or can't, come back later */
|
|
|
|
|
if (!session->ready_to_reset() || !session->scene->mutex.try_lock()) {
|
|
|
|
|
tag_update();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* data and camera synchronize */
|
2018-04-21 19:35:12 +02:00
|
|
|
b_depsgraph = b_depsgraph_;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Object b_camera_override(b_engine.camera_override());
|
2024-03-08 16:26:52 +01:00
|
|
|
sync->sync_data(b_render,
|
|
|
|
|
b_depsgraph,
|
|
|
|
|
b_v3d,
|
|
|
|
|
b_camera_override,
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
&python_thread_state,
|
2024-06-24 11:28:02 +02:00
|
|
|
session_params.denoise_device);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (b_rv3d) {
|
2011-04-27 11:58:34 +00:00
|
|
|
sync->sync_view(b_v3d, b_rv3d, width, height);
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
|
|
|
|
else {
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
sync->sync_camera(b_render, b_camera_override, width, height, "");
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-11 16:30:01 +01:00
|
|
|
/* get buffer parameters */
|
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 BufferParams buffer_params = BlenderSync::get_buffer_params(
|
|
|
|
|
b_v3d, b_rv3d, scene->camera, width, height);
|
2020-02-11 16:30:01 +01:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* reset if needed */
|
2011-12-20 12:25:37 +00:00
|
|
|
if (scene->need_reset()) {
|
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
|
|
|
session->reset(session_params, buffer_params);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-07 21:02:57 +02:00
|
|
|
/* After session reset, so device is not accessing image data anymore. */
|
|
|
|
|
builtin_images_load();
|
|
|
|
|
|
2013-04-24 20:12:12 +00:00
|
|
|
/* reset time */
|
|
|
|
|
start_resize_time = 0.0;
|
2011-12-20 12:25:37 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-07 21:02:57 +02:00
|
|
|
/* unlock */
|
|
|
|
|
session->scene->mutex.unlock();
|
|
|
|
|
|
2019-01-09 16:57:01 +01:00
|
|
|
/* Start rendering thread, if it's not running already. Do this
|
|
|
|
|
* after all scene data has been synced at least once. */
|
|
|
|
|
session->start();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
void BlenderSession::draw(BL::SpaceImageEditor &space_image)
|
|
|
|
|
{
|
|
|
|
|
if (!session || !session->scene) {
|
|
|
|
|
/* Offline render drawing does not force the render engine update, which means it's possible
|
|
|
|
|
* that the Session is not created yet. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(draw_state_.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
|
|
|
|
|
|
|
|
const int pass_index = space_image.image_user().multilayer_pass();
|
|
|
|
|
if (pass_index != draw_state_.last_pass_index) {
|
|
|
|
|
BL::RenderPass b_display_pass(b_engine.pass_by_index_get(b_rlay_name.c_str(), pass_index));
|
|
|
|
|
if (!b_display_pass) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-29 23:13:45 +01:00
|
|
|
Scene *scene = session->scene.get();
|
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
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const thread_scoped_lock lock(scene->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
|
|
|
|
|
|
|
|
const Pass *pass = Pass::find(scene->passes, b_display_pass.name());
|
|
|
|
|
if (!pass) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scene->film->set_display_pass(pass->get_type());
|
|
|
|
|
|
|
|
|
|
draw_state_.last_pass_index = pass_index;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 11:08:11 +02:00
|
|
|
if (display_driver_) {
|
|
|
|
|
BL::Array<float, 2> zoom = space_image.zoom();
|
|
|
|
|
display_driver_->set_zoom(zoom[0], zoom[1]);
|
|
|
|
|
}
|
2021-09-22 10:59:49 +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
|
|
|
session->draw();
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void BlenderSession::view_draw(const int w, const int h)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2013-04-28 12:31:24 +00:00
|
|
|
/* pause in redraw in case update is not being called due to final render */
|
|
|
|
|
session->set_pause(BlenderSync::get_session_pause(b_scene, background));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* before drawing, we verify camera and viewport size changes, because
|
2012-06-09 17:22:52 +00:00
|
|
|
* we do not get update callbacks for those, we must detect them here */
|
2011-04-27 11:58:34 +00:00
|
|
|
if (session->ready_to_reset()) {
|
|
|
|
|
bool reset = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-24 20:12:12 +00:00
|
|
|
/* if dimensions changed, reset */
|
|
|
|
|
if (width != w || height != h) {
|
|
|
|
|
if (start_resize_time == 0.0) {
|
|
|
|
|
/* don't react immediately to resizes to avoid flickery resizing
|
|
|
|
|
* of the viewport, and some window managers changing the window
|
|
|
|
|
* size temporarily on unminimize */
|
|
|
|
|
start_resize_time = time_dt();
|
|
|
|
|
tag_redraw();
|
|
|
|
|
}
|
2013-05-16 17:20:56 +00:00
|
|
|
else if (time_dt() - start_resize_time < 0.2) {
|
2013-04-24 20:12:12 +00:00
|
|
|
tag_redraw();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
width = w;
|
|
|
|
|
height = h;
|
|
|
|
|
reset = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2013-04-24 20:12:12 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* try to acquire mutex. if we can't, come back later */
|
|
|
|
|
if (!session->scene->mutex.try_lock()) {
|
|
|
|
|
tag_update();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* update camera from 3d view */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-24 20:12:12 +00:00
|
|
|
sync->sync_view(b_v3d, b_rv3d, width, height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-09-17 09:01:48 +10:00
|
|
|
if (scene->camera->is_modified()) {
|
2011-04-27 11:58:34 +00:00
|
|
|
reset = true;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
session->scene->mutex.unlock();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* reset if requested */
|
2011-08-28 13:55:59 +00:00
|
|
|
if (reset) {
|
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 SessionParams session_params = BlenderSync::get_session_params(
|
2015-02-18 21:16:52 +05:00
|
|
|
b_engine, b_userpref, b_scene, background);
|
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 BufferParams buffer_params = BlenderSync::get_buffer_params(
|
|
|
|
|
b_v3d, b_rv3d, scene->camera, width, height);
|
|
|
|
|
const bool session_pause = BlenderSync::get_session_pause(b_scene, background);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-08-01 16:39:05 +06:00
|
|
|
if (session_pause == false) {
|
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
|
|
|
session->reset(session_params, buffer_params);
|
2014-08-01 16:39:05 +06:00
|
|
|
start_resize_time = 0.0;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-08-01 16:39:05 +06:00
|
|
|
}
|
2013-02-15 09:15:14 +00:00
|
|
|
else {
|
|
|
|
|
tag_update();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-08-23 12:20:11 +00:00
|
|
|
/* update status and progress for 3d view draw */
|
|
|
|
|
update_status_progress();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-08-23 12:20:11 +00:00
|
|
|
/* draw */
|
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
|
|
|
session->draw();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderSession::get_status(string &status, string &substatus)
|
|
|
|
|
{
|
|
|
|
|
session->progress.get_status(status, substatus);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 20:44:31 +01:00
|
|
|
void BlenderSession::get_progress(double &progress, double &total_time, double &render_time)
|
2011-08-22 13:17:43 +00:00
|
|
|
{
|
Cycles: Refactor Progress system to provide better estimates
The Progress system in Cycles had two limitations so far:
- It just counted tiles, but ignored their size. For example, when rendering a 600x500 image with 512x512 tiles, the right 88x500 tile would count for 50% of the progress, although it only covers 15% of the image.
- Scene update time was incorrectly counted as rendering time - therefore, the remaining time started very long and gradually decreased.
This patch fixes both problems:
First of all, the Progress now has a function to ignore time spans, and that is used to ignore scene update time.
The larger change is the tile size: Instead of counting samples per tile, so that the final value is num_samples*num_tiles, the code now counts every sample for every pixel, so that the final value is num_samples*num_pixels.
Along with that, some unused variables were removed from the Progress and Session classes.
Reviewers: brecht, sergey, #cycles
Subscribers: brecht, candreacchio, sergey
Differential Revision: https://developer.blender.org/D2214
2016-11-26 04:22:34 +01:00
|
|
|
session->progress.get_time(total_time, render_time);
|
|
|
|
|
progress = session->progress.get_progress();
|
2011-08-22 13:17:43 +00:00
|
|
|
}
|
|
|
|
|
|
2014-07-22 18:41:01 -03:00
|
|
|
void BlenderSession::update_bake_progress()
|
|
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
const double progress = session->progress.get_progress();
|
2014-07-22 18:41:01 -03:00
|
|
|
|
|
|
|
|
if (progress != last_progress) {
|
2021-11-16 22:25:24 +01:00
|
|
|
b_engine.update_progress((float)progress);
|
2014-07-22 18:41:01 -03:00
|
|
|
last_progress = progress;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-23 12:20:11 +00:00
|
|
|
void BlenderSession::update_status_progress()
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2024-12-29 17:32:00 +01:00
|
|
|
string timestatus;
|
|
|
|
|
string status;
|
|
|
|
|
string substatus;
|
2024-12-26 17:53:59 +01:00
|
|
|
string scene_status;
|
2021-11-16 20:44:31 +01:00
|
|
|
double progress;
|
2024-12-29 17:32:00 +01:00
|
|
|
double total_time;
|
|
|
|
|
double remaining_time = 0;
|
|
|
|
|
double render_time;
|
|
|
|
|
const float mem_used = (float)session->stats.mem_used / 1024.0f / 1024.0f;
|
|
|
|
|
const float mem_peak = (float)session->stats.mem_peak / 1024.0f / 1024.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-08-22 13:17:43 +00:00
|
|
|
get_status(status, substatus);
|
2015-01-14 23:06:10 +05:00
|
|
|
get_progress(progress, total_time, render_time);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-24 16:16:16 +02:00
|
|
|
if (progress > 0) {
|
|
|
|
|
remaining_time = session->get_estimated_remaining_time();
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-01-14 23:06:10 +05:00
|
|
|
if (background) {
|
2023-09-17 09:01:48 +10:00
|
|
|
if (scene) {
|
2020-08-06 18:34:41 +02:00
|
|
|
scene_status += " | " + scene->name;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!b_rlay_name.empty()) {
|
2018-11-09 16:04:53 +01:00
|
|
|
scene_status += ", " + b_rlay_name;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!b_rview_name.empty()) {
|
2018-11-09 16:04:53 +01:00
|
|
|
scene_status += ", " + b_rview_name;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
if (remaining_time > 0) {
|
2019-03-19 18:54:17 +01:00
|
|
|
timestatus += "Remaining:" + time_human_readable_from_seconds(remaining_time) + " | ";
|
2018-10-25 11:47:37 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-10-25 11:47:37 +02:00
|
|
|
timestatus += string_printf("Mem:%.2fM, Peak:%.2fM", (double)mem_used, (double)mem_peak);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!status.empty()) {
|
2018-10-25 11:47:37 +02:00
|
|
|
status = " | " + status;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
if (!substatus.empty()) {
|
2018-10-25 11:47:37 +02:00
|
|
|
status += " | " + substatus;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2018-10-25 11:47:37 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const double current_time = time_dt();
|
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
|
|
|
/* When rendering in a window, redraw the status at least once per second to keep the elapsed
|
|
|
|
|
* and remaining time up-to-date. For headless rendering, only report when something
|
|
|
|
|
* significant changes to keep the console output readable. */
|
2017-01-19 00:41:55 +01:00
|
|
|
if (status != last_status || (!headless && (current_time - last_status_time) > 1.0)) {
|
2018-11-09 16:04:53 +01:00
|
|
|
b_engine.update_stats("", (timestatus + scene_status + status).c_str());
|
2012-11-05 08:04:57 +00:00
|
|
|
b_engine.update_memory_stats(mem_used, mem_peak);
|
2011-10-30 10:12:34 +00:00
|
|
|
last_status = status;
|
2017-01-19 00:41:55 +01:00
|
|
|
last_status_time = current_time;
|
2011-10-30 10:12:34 +00:00
|
|
|
}
|
|
|
|
|
if (progress != last_progress) {
|
2021-11-16 22:25:24 +01:00
|
|
|
b_engine.update_progress((float)progress);
|
2011-10-30 10:12:34 +00:00
|
|
|
last_progress = progress;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-09-23 17:20:59 +02:00
|
|
|
check_and_report_session_error();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool BlenderSession::check_and_report_session_error()
|
|
|
|
|
{
|
|
|
|
|
if (!session->progress.get_error()) {
|
|
|
|
|
return false;
|
2014-12-05 21:27:52 +05:00
|
|
|
}
|
2021-09-23 17:20:59 +02:00
|
|
|
|
|
|
|
|
const string error = session->progress.get_error_message();
|
|
|
|
|
if (error != last_error) {
|
|
|
|
|
/* TODO(sergey): Currently C++ RNA API doesn't let us to use mnemonic name for the variable.
|
|
|
|
|
* Would be nice to have this figured out.
|
|
|
|
|
*
|
|
|
|
|
* For until then, 1 << 5 means RPT_ERROR. */
|
|
|
|
|
b_engine.report(1 << 5, error.c_str());
|
|
|
|
|
b_engine.error_set(error.c_str());
|
|
|
|
|
last_error = error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2011-08-23 12:20:11 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-23 12:20:11 +00:00
|
|
|
void BlenderSession::tag_update()
|
|
|
|
|
{
|
|
|
|
|
/* tell blender that we want to get another update callback */
|
2012-10-22 17:34:16 +00:00
|
|
|
b_engine.tag_update();
|
2011-08-23 12:20:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderSession::tag_redraw()
|
|
|
|
|
{
|
2011-08-22 13:17:43 +00:00
|
|
|
if (background) {
|
2011-08-23 12:20:11 +00:00
|
|
|
/* update stats and progress, only for background here because
|
2012-06-09 17:22:52 +00:00
|
|
|
* in 3d view we do it in draw for thread safety reasons */
|
2011-08-23 12:20:11 +00:00
|
|
|
update_status_progress();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-08-22 13:17:43 +00:00
|
|
|
/* offline render, redraw if timeout passed */
|
2012-06-09 17:45:22 +00:00
|
|
|
if (time_dt() - last_redraw_time > 1.0) {
|
2012-10-22 17:34:16 +00:00
|
|
|
b_engine.tag_redraw();
|
2011-04-27 11:58:34 +00:00
|
|
|
last_redraw_time = time_dt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* tell blender that we want to redraw */
|
2012-10-22 17:34:16 +00:00
|
|
|
b_engine.tag_redraw();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BlenderSession::test_cancel()
|
|
|
|
|
{
|
|
|
|
|
/* test if we need to cancel rendering */
|
2023-09-17 09:01:48 +10:00
|
|
|
if (background) {
|
|
|
|
|
if (b_engine.test_break()) {
|
2011-04-27 11:58:34 +00:00
|
|
|
session->progress.set_cancel("Cancelled");
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-09 16:14:15 +01:00
|
|
|
void BlenderSession::free_blender_memory_if_possible()
|
|
|
|
|
{
|
2018-11-15 17:19:26 +01:00
|
|
|
if (!background) {
|
2018-11-09 16:14:15 +01:00
|
|
|
/* During interactive render we can not free anything: attempts to save
|
|
|
|
|
* memory would cause things to be allocated and evaluated for every
|
|
|
|
|
* updated sample.
|
|
|
|
|
*/
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
b_engine.free_blender_memory();
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-13 11:08:11 +02:00
|
|
|
void BlenderSession::ensure_display_driver_if_needed()
|
|
|
|
|
{
|
|
|
|
|
if (display_driver_) {
|
|
|
|
|
/* Driver is already created. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (headless) {
|
|
|
|
|
/* No display needed for headless. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (b_engine.is_preview()) {
|
|
|
|
|
/* TODO(sergey): Investigate whether DisplayDriver can be used for the preview as well. */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-20 13:36:12 +02:00
|
|
|
unique_ptr<BlenderDisplayDriver> display_driver = make_unique<BlenderDisplayDriver>(
|
|
|
|
|
b_engine, b_scene, background);
|
2021-10-13 11:08:11 +02:00
|
|
|
display_driver_ = display_driver.get();
|
2023-04-18 11:20:46 +02:00
|
|
|
session->set_display_driver(std::move(display_driver));
|
2021-10-13 11:08:11 +02:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 15:55:12 +02:00
|
|
|
CCL_NAMESPACE_END
|