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
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/device.h"
|
2021-11-18 16:07:47 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/background.h"
|
2021-11-18 16:07:47 +01:00
|
|
|
#include "scene/bake.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/camera.h"
|
|
|
|
|
#include "scene/film.h"
|
2021-11-18 16:07:47 +01:00
|
|
|
#include "scene/integrator.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/light.h"
|
|
|
|
|
#include "scene/object.h"
|
|
|
|
|
#include "scene/scene.h"
|
|
|
|
|
#include "scene/shader.h"
|
|
|
|
|
#include "scene/stats.h"
|
2022-12-13 19:14:29 +01:00
|
|
|
#include "scene/tabulated_sobol.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "kernel/types.h"
|
2020-03-02 15:12:44 +01:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/hash.h"
|
|
|
|
|
#include "util/log.h"
|
|
|
|
|
#include "util/task.h"
|
|
|
|
|
#include "util/time.h"
|
2011-10-29 14:27:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
NODE_DEFINE(Integrator)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2016-05-07 20:05:21 +02:00
|
|
|
NodeType *type = NodeType::add("integrator", create);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-28 17:06:32 +02:00
|
|
|
SOCKET_INT(min_bounce, "Min Bounce", 0);
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(max_bounce, "Max Bounce", 7);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(max_diffuse_bounce, "Max Diffuse Bounce", 7);
|
|
|
|
|
SOCKET_INT(max_glossy_bounce, "Max Glossy Bounce", 7);
|
|
|
|
|
SOCKET_INT(max_transmission_bounce, "Max Transmission Bounce", 7);
|
|
|
|
|
SOCKET_INT(max_volume_bounce, "Max Volume Bounce", 7);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-28 17:06:32 +02:00
|
|
|
SOCKET_INT(transparent_min_bounce, "Transparent Min Bounce", 0);
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(transparent_max_bounce, "Transparent Max Bounce", 7);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-17 17:26:46 +01:00
|
|
|
#ifdef WITH_CYCLES_DEBUG
|
|
|
|
|
static NodeEnum direct_light_sampling_type_enum;
|
|
|
|
|
direct_light_sampling_type_enum.insert("multiple_importance_sampling",
|
|
|
|
|
DIRECT_LIGHT_SAMPLING_MIS);
|
|
|
|
|
direct_light_sampling_type_enum.insert("forward_path_tracing", DIRECT_LIGHT_SAMPLING_FORWARD);
|
|
|
|
|
direct_light_sampling_type_enum.insert("next_event_estimation", DIRECT_LIGHT_SAMPLING_NEE);
|
|
|
|
|
SOCKET_ENUM(direct_light_sampling_type,
|
|
|
|
|
"Direct Light Sampling Type",
|
|
|
|
|
direct_light_sampling_type_enum,
|
|
|
|
|
DIRECT_LIGHT_SAMPLING_MIS);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-11-25 18:59:43 +01:00
|
|
|
SOCKET_INT(ao_bounces, "AO Bounces", 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
|
|
|
SOCKET_FLOAT(ao_factor, "AO Factor", 0.0f);
|
|
|
|
|
SOCKET_FLOAT(ao_distance, "AO Distance", FLT_MAX);
|
2021-10-21 17:42:15 +02:00
|
|
|
SOCKET_FLOAT(ao_additive_factor, "AO Additive Factor", 0.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(volume_max_steps, "Volume Max Steps", 1024);
|
2020-03-07 14:38:52 +01:00
|
|
|
SOCKET_FLOAT(volume_step_rate, "Volume Step Rate", 1.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-09 15:06:34 +02:00
|
|
|
static NodeEnum guiding_distribution_enum;
|
|
|
|
|
guiding_distribution_enum.insert("PARALLAX_AWARE_VMM", GUIDING_TYPE_PARALLAX_AWARE_VMM);
|
|
|
|
|
guiding_distribution_enum.insert("DIRECTIONAL_QUAD_TREE", GUIDING_TYPE_DIRECTIONAL_QUAD_TREE);
|
|
|
|
|
guiding_distribution_enum.insert("VMM", GUIDING_TYPE_VMM);
|
|
|
|
|
|
|
|
|
|
static NodeEnum guiding_directional_sampling_type_enum;
|
|
|
|
|
guiding_directional_sampling_type_enum.insert("MIS",
|
|
|
|
|
GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT_MIS);
|
|
|
|
|
guiding_directional_sampling_type_enum.insert("RIS", GUIDING_DIRECTIONAL_SAMPLING_TYPE_RIS);
|
|
|
|
|
guiding_directional_sampling_type_enum.insert("ROUGHNESS",
|
|
|
|
|
GUIDING_DIRECTIONAL_SAMPLING_TYPE_ROUGHNESS);
|
2022-09-21 17:58:34 +02:00
|
|
|
|
|
|
|
|
SOCKET_BOOLEAN(use_guiding, "Guiding", false);
|
|
|
|
|
SOCKET_BOOLEAN(deterministic_guiding, "Deterministic Guiding", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_surface_guiding, "Surface Guiding", true);
|
|
|
|
|
SOCKET_FLOAT(surface_guiding_probability, "Surface Guiding Probability", 0.5f);
|
|
|
|
|
SOCKET_BOOLEAN(use_volume_guiding, "Volume Guiding", true);
|
|
|
|
|
SOCKET_FLOAT(volume_guiding_probability, "Volume Guiding Probability", 0.5f);
|
|
|
|
|
SOCKET_INT(guiding_training_samples, "Training Samples", 128);
|
|
|
|
|
SOCKET_BOOLEAN(use_guiding_direct_light, "Guide Direct Light", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_guiding_mis_weights, "Use MIS Weights", true);
|
|
|
|
|
SOCKET_ENUM(guiding_distribution_type,
|
|
|
|
|
"Guiding Distribution Type",
|
2023-05-09 15:06:34 +02:00
|
|
|
guiding_distribution_enum,
|
2022-09-21 17:58:34 +02:00
|
|
|
GUIDING_TYPE_PARALLAX_AWARE_VMM);
|
2023-05-09 15:06:34 +02:00
|
|
|
SOCKET_ENUM(guiding_directional_sampling_type,
|
|
|
|
|
"Guiding Directional Sampling Type",
|
|
|
|
|
guiding_directional_sampling_type_enum,
|
|
|
|
|
GUIDING_DIRECTIONAL_SAMPLING_TYPE_RIS);
|
|
|
|
|
SOCKET_FLOAT(guiding_roughness_threshold, "Guiding Roughness Threshold", 0.05f);
|
2022-09-21 17:58:34 +02:00
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_BOOLEAN(caustics_reflective, "Reflective Caustics", true);
|
|
|
|
|
SOCKET_BOOLEAN(caustics_refractive, "Refractive Caustics", true);
|
|
|
|
|
SOCKET_FLOAT(filter_glossy, "Filter Glossy", 0.0f);
|
2021-11-12 18:26:30 +01:00
|
|
|
|
|
|
|
|
SOCKET_BOOLEAN(use_direct_light, "Use Direct Light", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_indirect_light, "Use Indirect Light", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_diffuse, "Use Diffuse", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_glossy, "Use Glossy", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_transmission, "Use Transmission", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_emission, "Use Emission", true);
|
|
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(seed, "Seed", 0);
|
|
|
|
|
SOCKET_FLOAT(sample_clamp_direct, "Sample Clamp Direct", 0.0f);
|
2022-04-17 21:36:26 +02:00
|
|
|
SOCKET_FLOAT(sample_clamp_indirect, "Sample Clamp Indirect", 10.0f);
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_BOOLEAN(motion_blur, "Motion Blur", false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
SOCKET_INT(aa_samples, "AA Samples", 0);
|
2025-01-15 07:41:16 +01:00
|
|
|
SOCKET_BOOLEAN(use_sample_subset, "Use Sample Subset", false);
|
|
|
|
|
SOCKET_INT(sample_subset_offset, "Sample Subset Offset", 0);
|
|
|
|
|
SOCKET_INT(sample_subset_length, "Sample Subset Length", MAX_SAMPLES);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-04-17 21:36:26 +02:00
|
|
|
SOCKET_BOOLEAN(use_adaptive_sampling, "Use Adaptive Sampling", true);
|
|
|
|
|
SOCKET_FLOAT(adaptive_threshold, "Adaptive Threshold", 0.01f);
|
2020-03-05 12:05:42 +01:00
|
|
|
SOCKET_INT(adaptive_min_samples, "Adaptive Min Samples", 0);
|
|
|
|
|
|
2022-12-02 19:04:00 +01:00
|
|
|
SOCKET_BOOLEAN(use_light_tree, "Use light tree to optimize many light sampling", true);
|
|
|
|
|
SOCKET_FLOAT(light_sampling_threshold, "Light Sampling Threshold", 0.0f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
static NodeEnum sampling_pattern_enum;
|
2022-08-18 20:45:09 +02:00
|
|
|
sampling_pattern_enum.insert("sobol_burley", SAMPLING_PATTERN_SOBOL_BURLEY);
|
2022-12-13 19:14:29 +01:00
|
|
|
sampling_pattern_enum.insert("tabulated_sobol", SAMPLING_PATTERN_TABULATED_SOBOL);
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
sampling_pattern_enum.insert("blue_noise_pure", SAMPLING_PATTERN_BLUE_NOISE_PURE);
|
|
|
|
|
sampling_pattern_enum.insert("blue_noise_round", SAMPLING_PATTERN_BLUE_NOISE_ROUND);
|
|
|
|
|
sampling_pattern_enum.insert("blue_noise_first", SAMPLING_PATTERN_BLUE_NOISE_FIRST);
|
2022-12-13 19:14:29 +01:00
|
|
|
SOCKET_ENUM(sampling_pattern,
|
|
|
|
|
"Sampling Pattern",
|
|
|
|
|
sampling_pattern_enum,
|
|
|
|
|
SAMPLING_PATTERN_TABULATED_SOBOL);
|
2021-10-26 08:30:15 +02:00
|
|
|
SOCKET_FLOAT(scrambling_distance, "Scrambling Distance", 1.0f);
|
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
|
|
|
static NodeEnum denoiser_type_enum;
|
2025-01-08 00:05:42 +01:00
|
|
|
denoiser_type_enum.insert("none", DENOISER_NONE);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
denoiser_type_enum.insert("optix", DENOISER_OPTIX);
|
|
|
|
|
denoiser_type_enum.insert("openimagedenoise", DENOISER_OPENIMAGEDENOISE);
|
|
|
|
|
|
|
|
|
|
static NodeEnum denoiser_prefilter_enum;
|
|
|
|
|
denoiser_prefilter_enum.insert("none", DENOISER_PREFILTER_NONE);
|
|
|
|
|
denoiser_prefilter_enum.insert("fast", DENOISER_PREFILTER_FAST);
|
|
|
|
|
denoiser_prefilter_enum.insert("accurate", DENOISER_PREFILTER_ACCURATE);
|
|
|
|
|
|
2024-02-06 20:46:48 +01:00
|
|
|
static NodeEnum denoiser_quality_enum;
|
|
|
|
|
denoiser_quality_enum.insert("high", DENOISER_QUALITY_HIGH);
|
|
|
|
|
denoiser_quality_enum.insert("balanced", DENOISER_QUALITY_BALANCED);
|
2024-05-06 18:56:16 +02:00
|
|
|
denoiser_quality_enum.insert("fast", DENOISER_QUALITY_FAST);
|
2024-02-06 20:46:48 +01: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
|
|
|
/* Default to accurate denoising with OpenImageDenoise. For interactive viewport
|
|
|
|
|
* it's best use OptiX and disable the normal pass since it does not always have
|
|
|
|
|
* the desired effect for that denoiser. */
|
|
|
|
|
SOCKET_BOOLEAN(use_denoise, "Use Denoiser", false);
|
|
|
|
|
SOCKET_ENUM(denoiser_type, "Denoiser Type", denoiser_type_enum, DENOISER_OPENIMAGEDENOISE);
|
|
|
|
|
SOCKET_INT(denoise_start_sample, "Start Sample to Denoise", 0);
|
|
|
|
|
SOCKET_BOOLEAN(use_denoise_pass_albedo, "Use Albedo Pass for Denoiser", true);
|
|
|
|
|
SOCKET_BOOLEAN(use_denoise_pass_normal, "Use Normal Pass for Denoiser", true);
|
2022-03-24 11:01:12 +01:00
|
|
|
SOCKET_ENUM(denoiser_prefilter,
|
|
|
|
|
"Denoiser Prefilter",
|
|
|
|
|
denoiser_prefilter_enum,
|
|
|
|
|
DENOISER_PREFILTER_ACCURATE);
|
2024-02-06 17:46:21 +01:00
|
|
|
SOCKET_BOOLEAN(denoise_use_gpu, "Denoise on GPU", true);
|
2024-02-06 20:46:48 +01:00
|
|
|
SOCKET_ENUM(denoiser_quality, "Denoiser Quality", denoiser_quality_enum, DENOISER_QUALITY_HIGH);
|
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
|
|
|
|
2016-05-07 20:05:21 +02:00
|
|
|
return type;
|
|
|
|
|
}
|
2013-06-07 16:06:22 +00:00
|
|
|
|
2023-03-29 16:50:54 +02:00
|
|
|
Integrator::Integrator() : Node(get_node_type()) {}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
Integrator::~Integrator() = default;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-06-13 11:44:48 +00:00
|
|
|
void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2023-09-17 09:01:48 +10:00
|
|
|
if (!is_modified()) {
|
2011-04-27 11:58:34 +00:00
|
|
|
return;
|
2023-09-17 09:01:48 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const scoped_callback_timer timer([scene](double time) {
|
2020-10-01 23:16:01 +02:00
|
|
|
if (scene->update_stats) {
|
|
|
|
|
scene->update_stats->integrator.times.add_entry({"device_update", 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
|
|
|
KernelIntegrator *kintegrator = &dscene->data.integrator;
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
device_free(device, dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* integrator parameters */
|
2025-05-05 18:38:02 +02:00
|
|
|
|
|
|
|
|
/* Plus one so that a bounce of 0 indicates no global illumination, only direct illumination. */
|
2019-06-28 17:06:32 +02:00
|
|
|
kintegrator->min_bounce = min_bounce + 1;
|
2011-09-01 15:53:36 +00:00
|
|
|
kintegrator->max_bounce = max_bounce + 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-01 15:53:36 +00:00
|
|
|
kintegrator->max_diffuse_bounce = max_diffuse_bounce + 1;
|
|
|
|
|
kintegrator->max_glossy_bounce = max_glossy_bounce + 1;
|
|
|
|
|
kintegrator->max_transmission_bounce = max_transmission_bounce + 1;
|
2014-08-31 14:00:51 +02:00
|
|
|
kintegrator->max_volume_bounce = max_volume_bounce + 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-06-28 17:06:32 +02:00
|
|
|
kintegrator->transparent_min_bounce = transparent_min_bounce + 1;
|
2025-05-05 18:38:02 +02:00
|
|
|
|
|
|
|
|
/* Unlike other type of bounces, 0 transparent bounce means there is no transparent bounce in the
|
|
|
|
|
* scene. */
|
|
|
|
|
kintegrator->transparent_max_bounce = transparent_max_bounce;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-12-09 18:17:48 +01:00
|
|
|
kintegrator->ao_bounces = (ao_factor != 0.0f) ? ao_bounces : 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
|
|
|
kintegrator->ao_bounces_distance = ao_distance;
|
|
|
|
|
kintegrator->ao_bounces_factor = ao_factor;
|
2021-10-21 17:42:15 +02:00
|
|
|
kintegrator->ao_additive_factor = ao_additive_factor;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-17 17:26:46 +01:00
|
|
|
#ifdef WITH_CYCLES_DEBUG
|
|
|
|
|
kintegrator->direct_light_sampling_type = direct_light_sampling_type;
|
|
|
|
|
#else
|
|
|
|
|
kintegrator->direct_light_sampling_type = DIRECT_LIGHT_SAMPLING_MIS;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-09-11 14:50:31 +02:00
|
|
|
/* Transparent Shadows
|
2018-07-06 10:17:58 +02:00
|
|
|
* We only need to enable transparent shadows, if we actually have
|
2014-09-11 14:50:31 +02:00
|
|
|
* transparent shaders in the scene. Otherwise we can disable it
|
|
|
|
|
* to improve performance a bit. */
|
2017-08-02 15:23:50 +02:00
|
|
|
kintegrator->transparent_shadows = false;
|
2024-12-26 19:41:25 +01:00
|
|
|
for (Shader *shader : scene->shaders) {
|
2017-08-02 15:23:50 +02:00
|
|
|
/* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */
|
2020-11-04 11:17:38 +01:00
|
|
|
if ((shader->has_surface_transparent && shader->get_use_transparent_shadow()) ||
|
2017-08-02 15:23:50 +02:00
|
|
|
shader->has_volume)
|
|
|
|
|
{
|
|
|
|
|
kintegrator->transparent_shadows = true;
|
|
|
|
|
break;
|
2014-09-11 14:50:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-29 22:19:38 +01:00
|
|
|
kintegrator->volume_max_steps = volume_max_steps;
|
2020-03-07 14:38:52 +01:00
|
|
|
kintegrator->volume_step_rate = volume_step_rate;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-09-05 20:39:35 +02:00
|
|
|
kintegrator->caustics_reflective = caustics_reflective;
|
|
|
|
|
kintegrator->caustics_refractive = caustics_refractive;
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
kintegrator->filter_glossy = (filter_glossy == 0.0f) ? FLT_MAX : 1.0f / filter_glossy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-11-12 18:26:30 +01:00
|
|
|
kintegrator->filter_closures = 0;
|
|
|
|
|
if (!use_direct_light) {
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_DIRECT_LIGHT;
|
|
|
|
|
}
|
|
|
|
|
if (!use_indirect_light) {
|
|
|
|
|
kintegrator->min_bounce = 1;
|
|
|
|
|
kintegrator->max_bounce = 1;
|
|
|
|
|
}
|
|
|
|
|
if (!use_diffuse) {
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_DIFFUSE;
|
|
|
|
|
}
|
|
|
|
|
if (!use_glossy) {
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_GLOSSY;
|
|
|
|
|
}
|
|
|
|
|
if (!use_transmission) {
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_TRANSMISSION;
|
|
|
|
|
}
|
|
|
|
|
if (!use_emission) {
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_EMISSION;
|
|
|
|
|
}
|
2021-11-18 16:07:47 +01:00
|
|
|
if (scene->bake_manager->get_baking()) {
|
|
|
|
|
/* Baking does not need to trace through transparency, we only want to bake
|
|
|
|
|
* the object itself. */
|
|
|
|
|
kintegrator->filter_closures |= FILTER_CLOSURE_TRANSPARENT;
|
|
|
|
|
}
|
2021-11-12 18:26:30 +01:00
|
|
|
|
2024-12-29 17:32:00 +01:00
|
|
|
const GuidingParams guiding_params = get_guiding_params(device);
|
2022-09-21 17:58:34 +02:00
|
|
|
kintegrator->use_guiding = guiding_params.use;
|
|
|
|
|
kintegrator->train_guiding = kintegrator->use_guiding;
|
|
|
|
|
kintegrator->use_surface_guiding = guiding_params.use_surface_guiding;
|
|
|
|
|
kintegrator->use_volume_guiding = guiding_params.use_volume_guiding;
|
|
|
|
|
kintegrator->surface_guiding_probability = surface_guiding_probability;
|
|
|
|
|
kintegrator->volume_guiding_probability = volume_guiding_probability;
|
|
|
|
|
kintegrator->use_guiding_direct_light = use_guiding_direct_light;
|
|
|
|
|
kintegrator->use_guiding_mis_weights = use_guiding_mis_weights;
|
|
|
|
|
kintegrator->guiding_distribution_type = guiding_params.type;
|
2023-05-09 15:06:34 +02:00
|
|
|
kintegrator->guiding_directional_sampling_type = guiding_params.sampling_type;
|
|
|
|
|
kintegrator->guiding_roughness_threshold = guiding_params.roughness_threshold;
|
2022-09-21 17:58:34 +02:00
|
|
|
|
2014-02-10 21:44:49 +01:00
|
|
|
kintegrator->sample_clamp_direct = (sample_clamp_direct == 0.0f) ? FLT_MAX :
|
|
|
|
|
sample_clamp_direct * 3.0f;
|
|
|
|
|
kintegrator->sample_clamp_indirect = (sample_clamp_indirect == 0.0f) ?
|
|
|
|
|
FLT_MAX :
|
|
|
|
|
sample_clamp_indirect * 3.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2025-01-15 07:41:16 +01:00
|
|
|
const int clamped_aa_samples = min(aa_samples, MAX_SAMPLES);
|
|
|
|
|
|
2022-09-02 17:32:34 +02:00
|
|
|
kintegrator->sampling_pattern = sampling_pattern;
|
2021-10-26 08:30:15 +02:00
|
|
|
kintegrator->scrambling_distance = scrambling_distance;
|
2025-01-15 07:41:16 +01:00
|
|
|
kintegrator->sobol_index_mask = reverse_integer_bits(next_power_of_two(clamped_aa_samples - 1) -
|
|
|
|
|
1);
|
|
|
|
|
kintegrator->blue_noise_sequence_length = clamped_aa_samples;
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
if (kintegrator->sampling_pattern == SAMPLING_PATTERN_BLUE_NOISE_ROUND) {
|
2025-01-15 07:41:16 +01:00
|
|
|
if (!is_power_of_two(clamped_aa_samples)) {
|
|
|
|
|
kintegrator->blue_noise_sequence_length = next_power_of_two(clamped_aa_samples);
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
}
|
|
|
|
|
kintegrator->sampling_pattern = SAMPLING_PATTERN_BLUE_NOISE_PURE;
|
|
|
|
|
}
|
|
|
|
|
if (kintegrator->sampling_pattern == SAMPLING_PATTERN_BLUE_NOISE_FIRST) {
|
|
|
|
|
kintegrator->blue_noise_sequence_length -= 1;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2024-06-15 22:05:18 +02:00
|
|
|
/* The blue-noise sampler needs a randomized seed to scramble properly, providing e.g. 0 won't
|
|
|
|
|
* work properly. Therefore, hash the seed in those cases. */
|
|
|
|
|
if (kintegrator->sampling_pattern == SAMPLING_PATTERN_BLUE_NOISE_FIRST ||
|
|
|
|
|
kintegrator->sampling_pattern == SAMPLING_PATTERN_BLUE_NOISE_PURE)
|
|
|
|
|
{
|
|
|
|
|
kintegrator->seed = hash_uint(seed);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
kintegrator->seed = seed;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 16:50:06 +01:00
|
|
|
/* NOTE: The kintegrator->use_light_tree is assigned to the efficient value in the light manager,
|
|
|
|
|
* and the synchronization code is expected to tag the light manager for update when the
|
|
|
|
|
* `use_light_tree` is changed. */
|
|
|
|
|
if (light_sampling_threshold > 0.0f && !kintegrator->use_light_tree) {
|
2022-12-12 17:51:21 +01:00
|
|
|
kintegrator->light_inv_rr_threshold = scene->film->get_exposure() / light_sampling_threshold;
|
2016-10-29 23:47:30 +02:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
kintegrator->light_inv_rr_threshold = 0.0f;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-12-13 19:14:29 +01:00
|
|
|
/* Build pre-tabulated Sobol samples if needed. */
|
2024-12-29 17:32:00 +01:00
|
|
|
const int sequence_size = clamp(
|
2025-01-15 07:41:16 +01:00
|
|
|
next_power_of_two(clamped_aa_samples - 1), MIN_TAB_SOBOL_SAMPLES, MAX_TAB_SOBOL_SAMPLES);
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
const int table_size = sequence_size * NUM_TAB_SOBOL_PATTERNS * NUM_TAB_SOBOL_DIMENSIONS;
|
2022-12-13 19:14:29 +01:00
|
|
|
if (kintegrator->sampling_pattern == SAMPLING_PATTERN_TABULATED_SOBOL &&
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
dscene->sample_pattern_lut.size() != table_size)
|
2022-12-13 19:14:29 +01:00
|
|
|
{
|
|
|
|
|
kintegrator->tabulated_sobol_sequence_size = sequence_size;
|
2022-11-21 18:16:27 +01:00
|
|
|
|
|
|
|
|
if (dscene->sample_pattern_lut.size() != 0) {
|
|
|
|
|
dscene->sample_pattern_lut.free();
|
|
|
|
|
}
|
Cycles: Implement blue-noise dithered sampling
This patch implements blue-noise dithered sampling as described by Nathan Vegdahl (https://psychopath.io/post/2022_07_24_owen_scrambling_based_dithered_blue_noise_sampling), which in turn is based on "Screen-Space Blue-Noise Diffusion of Monte Carlo Sampling Error via Hierarchical Ordering of Pixels"(https://repository.kaust.edu.sa/items/1269ae24-2596-400b-a839-e54486033a93).
The basic idea is simple: Instead of generating independent sequences for each pixel by scrambling them, we use a single sequence for the entire image, with each pixel getting one chunk of the samples. The ordering across pixels is determined by hierarchical scrambling of the pixel's position along a space-filling curve, which ends up being pretty much the same operation as already used for the underlying sequence.
This results in a more high-frequency noise distribution, which appears smoother despite not being less noisy overall.
The main limitation at the moment is that the improvement is only clear if the full sample amount is used per pixel, so interactive preview rendering and adaptive sampling will not receive the benefit. One exception to this is that when using the new "Automatic" setting, the first sample in interactive rendering will also be blue-noise-distributed.
The sampling mode option is now exposed in the UI, with the three options being Blue Noise (the new mode), Classic (the previous Tabulated Sobol method) and the new default, Automatic (blue noise, with the additional property of ensuring the first sample is also blue-noise-distributed in interactive rendering). When debug mode is enabled, additional options appear, such as Sobol-Burley.
Note that the scrambling distance option is not compatible with the blue-noise pattern.
Pull Request: https://projects.blender.org/blender/blender/pulls/118479
2024-06-05 02:29:47 +02:00
|
|
|
float4 *directions = (float4 *)dscene->sample_pattern_lut.alloc(table_size);
|
2022-08-26 13:14:57 +02:00
|
|
|
TaskPool pool;
|
2022-12-13 19:14:29 +01:00
|
|
|
for (int j = 0; j < NUM_TAB_SOBOL_PATTERNS; ++j) {
|
|
|
|
|
float4 *sequence = directions + j * sequence_size;
|
2024-12-26 17:53:55 +01:00
|
|
|
pool.push([sequence, sequence_size, j] {
|
|
|
|
|
tabulated_sobol_generate_4D(sequence, sequence_size, j);
|
|
|
|
|
});
|
2020-03-02 15:12:44 +01:00
|
|
|
}
|
2022-08-26 13:14:57 +02:00
|
|
|
pool.wait_work();
|
|
|
|
|
|
|
|
|
|
dscene->sample_pattern_lut.copy_to_device();
|
2020-03-02 15:12:44 +01:00
|
|
|
}
|
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
|
|
|
kintegrator->has_shadow_catcher = scene->has_shadow_catcher();
|
|
|
|
|
|
2021-01-29 17:17:18 +01:00
|
|
|
dscene->sample_pattern_lut.clear_modified();
|
2020-11-04 11:17:38 +01:00
|
|
|
clear_modified();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2024-12-26 17:53:59 +01:00
|
|
|
void Integrator::device_free(Device * /*unused*/, DeviceScene *dscene, bool force_free)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
dscene->sample_pattern_lut.free_if_need_realloc(force_free);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2025-01-01 18:15:54 +01:00
|
|
|
void Integrator::tag_update(Scene *scene, const uint32_t flag)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
if (flag & UPDATE_ALL) {
|
|
|
|
|
tag_modified();
|
|
|
|
|
}
|
|
|
|
|
|
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 (flag & AO_PASS_MODIFIED) {
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
/* tag only the ao_bounces socket as modified so we avoid updating sample_pattern_lut
|
|
|
|
|
* unnecessarily */
|
|
|
|
|
tag_ao_bounces_modified();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (motion_blur_is_modified()) {
|
|
|
|
|
scene->object_manager->tag_update(scene, ObjectManager::MOTION_BLUR_MODIFIED);
|
|
|
|
|
scene->camera->tag_modified();
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-26 15:30:12 +02:00
|
|
|
uint Integrator::get_kernel_features() const
|
2021-10-21 17:42:15 +02:00
|
|
|
{
|
|
|
|
|
uint kernel_features = 0;
|
|
|
|
|
|
|
|
|
|
if (ao_additive_factor != 0.0f) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_AO_ADDITIVE;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-11 10:51:45 +02:00
|
|
|
if (get_use_light_tree()) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_LIGHT_TREE;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 17:42:15 +02:00
|
|
|
return kernel_features;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
AdaptiveSampling Integrator::get_adaptive_sampling() const
|
|
|
|
|
{
|
|
|
|
|
AdaptiveSampling adaptive_sampling;
|
|
|
|
|
|
|
|
|
|
adaptive_sampling.use = use_adaptive_sampling;
|
|
|
|
|
|
|
|
|
|
if (!adaptive_sampling.use) {
|
|
|
|
|
return adaptive_sampling;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 07:41:16 +01:00
|
|
|
const int clamped_aa_samples = min(aa_samples, MAX_SAMPLES);
|
|
|
|
|
|
|
|
|
|
if (clamped_aa_samples > 0 && adaptive_threshold == 0.0f) {
|
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
|
|
|
adaptive_sampling.threshold = max(0.001f, 1.0f / (float)aa_samples);
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Cycles adaptive sampling: automatic threshold = " << adaptive_sampling.threshold;
|
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
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
adaptive_sampling.threshold = adaptive_threshold;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 07:41:16 +01:00
|
|
|
if (use_sample_subset && clamped_aa_samples > 0) {
|
|
|
|
|
const int subset_samples = max(
|
|
|
|
|
min(sample_subset_offset + sample_subset_length, clamped_aa_samples) -
|
|
|
|
|
sample_subset_offset,
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
adaptive_sampling.threshold *= sqrtf((float)subset_samples / (float)clamped_aa_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
|
|
|
if (adaptive_sampling.threshold > 0 && adaptive_min_samples == 0) {
|
|
|
|
|
/* Threshold 0.1 -> 32, 0.01 -> 64, 0.001 -> 128.
|
|
|
|
|
* This is highly scene dependent, we make a guess that seemed to work well
|
|
|
|
|
* in various test scenes. */
|
|
|
|
|
const int min_samples = (int)ceilf(16.0f / powf(adaptive_sampling.threshold, 0.3f));
|
|
|
|
|
adaptive_sampling.min_samples = max(4, min_samples);
|
2022-06-16 19:39:13 +02:00
|
|
|
VLOG_INFO << "Cycles adaptive sampling: automatic min samples = "
|
|
|
|
|
<< adaptive_sampling.min_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
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
adaptive_sampling.min_samples = max(4, adaptive_min_samples);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Arbitrary factor that makes the threshold more similar to what is was before,
|
|
|
|
|
* and gives arguably more intuitive values. */
|
|
|
|
|
adaptive_sampling.threshold *= 5.0f;
|
|
|
|
|
|
|
|
|
|
adaptive_sampling.adaptive_step = 16;
|
|
|
|
|
|
|
|
|
|
DCHECK(is_power_of_two(adaptive_sampling.adaptive_step))
|
|
|
|
|
<< "Adaptive step must be a power of two for bitwise operations to work";
|
|
|
|
|
|
|
|
|
|
return adaptive_sampling;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DenoiseParams Integrator::get_denoise_params() const
|
|
|
|
|
{
|
|
|
|
|
DenoiseParams denoise_params;
|
|
|
|
|
|
|
|
|
|
denoise_params.use = use_denoise;
|
|
|
|
|
|
|
|
|
|
denoise_params.type = denoiser_type;
|
|
|
|
|
|
2024-02-06 17:46:21 +01:00
|
|
|
denoise_params.use_gpu = denoise_use_gpu;
|
|
|
|
|
|
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
|
|
|
denoise_params.start_sample = denoise_start_sample;
|
|
|
|
|
|
|
|
|
|
denoise_params.use_pass_albedo = use_denoise_pass_albedo;
|
|
|
|
|
denoise_params.use_pass_normal = use_denoise_pass_normal;
|
|
|
|
|
|
|
|
|
|
denoise_params.prefilter = denoiser_prefilter;
|
2024-02-06 20:46:48 +01:00
|
|
|
denoise_params.quality = denoiser_quality;
|
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
|
|
|
|
|
|
|
|
return denoise_params;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-21 17:58:34 +02:00
|
|
|
GuidingParams Integrator::get_guiding_params(const Device *device) const
|
|
|
|
|
{
|
|
|
|
|
const bool use = use_guiding && device->info.has_guiding;
|
|
|
|
|
|
|
|
|
|
GuidingParams guiding_params;
|
|
|
|
|
guiding_params.use_surface_guiding = use && use_surface_guiding &&
|
|
|
|
|
surface_guiding_probability > 0.0f;
|
|
|
|
|
guiding_params.use_volume_guiding = use && use_volume_guiding &&
|
|
|
|
|
volume_guiding_probability > 0.0f;
|
|
|
|
|
guiding_params.use = guiding_params.use_surface_guiding || guiding_params.use_volume_guiding;
|
|
|
|
|
guiding_params.type = guiding_distribution_type;
|
|
|
|
|
guiding_params.training_samples = guiding_training_samples;
|
|
|
|
|
guiding_params.deterministic = deterministic_guiding;
|
2023-05-09 15:06:34 +02:00
|
|
|
guiding_params.sampling_type = guiding_directional_sampling_type;
|
|
|
|
|
// In Blender/Cycles the user set roughness is squared to behave more linear.
|
|
|
|
|
guiding_params.roughness_threshold = guiding_roughness_threshold * guiding_roughness_threshold;
|
2022-09-21 17:58:34 +02:00
|
|
|
return guiding_params;
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|