[Bf-blender-cvs] [bc5b47d41bc] cycles_path_guiding: Cleanup: changes to path guiding params
Brecht Van Lommel
noreply at git.blender.org
Thu Aug 11 17:12:50 CEST 2022
Commit: bc5b47d41bc8b0dfc20787e6a80407ccd0038e49
Author: Brecht Van Lommel
Date: Thu Aug 11 15:31:06 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBbc5b47d41bc8b0dfc20787e6a80407ccd0038e49
Cleanup: changes to path guiding params
* Rename identifiers to be long, fix typo in label
* Remove redundant guiding params update in session
* Use unique_ptr for storage in Path Trace
* Various other tweaks.
===================================================================
M intern/cycles/blender/addon/properties.py
M intern/cycles/blender/sync.cpp
M intern/cycles/integrator/guiding.h
M intern/cycles/integrator/path_trace.cpp
M intern/cycles/integrator/path_trace.h
M intern/cycles/kernel/types.h
M intern/cycles/scene/integrator.cpp
M intern/cycles/session/session.cpp
M intern/cycles/session/session.h
===================================================================
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index f1f623e8e04..5fcc1eed7b6 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -180,8 +180,8 @@ enum_view3d_shading_render_pass = (
)
enum_guiding_distribution = (
- ('PAVMM', "Paralax-Aware VMM", "Use Parallax-aware von Mises-Fisher models as directional distribution", 0),
- ('DQT', "Directional Quad Tree", "Use Directional Quad Trees as directional distribution", 1),
+ ('PARALLAX_AWARE_VMM', "Parallax-Aware VMM", "Use Parallax-aware von Mises-Fisher models as directional distribution", 0),
+ ('DIRECTIONAL_QUAD_TREE', "Directional Quad Tree", "Use Directional Quad Trees as directional distribution", 1),
('VMM', "VMM", "Use von Mises-Fisher models as directional distribution", 2),
)
@@ -525,7 +525,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
name="Guiding Distribution Type",
description="The type of the used representation for the guiding distribution",
items=enum_guiding_distribution,
- default='PAVMM',
+ default='PARALLAX_AWARE_VMM',
)
use_surface_guiding: BoolProperty(
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index f7e3bde1820..640672425eb 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -420,7 +420,7 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
integrator->set_use_guide_direct_light(get_boolean(cscene, "use_guide_direct_light"));
integrator->set_use_mis_weights(get_boolean(cscene, "use_mis_weights"));
GuidingDistributionType guiding_distribution_type = (GuidingDistributionType)get_enum(
- cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PAVMM);
+ cscene, "guiding_distribution_type", GUIDING_NUM_TYPES, GUIDING_TYPE_PARALLAX_AWARE_VMM);
integrator->set_guiding_distribution_type(guiding_distribution_type);
DenoiseParams denoise_params = get_denoise_params(b_scene, b_view_layer, background);
diff --git a/intern/cycles/integrator/guiding.h b/intern/cycles/integrator/guiding.h
index 621f5033de9..178e05d39f1 100644
--- a/intern/cycles/integrator/guiding.h
+++ b/intern/cycles/integrator/guiding.h
@@ -1,37 +1,22 @@
-/*
- * Copyright 2011-2021 Blender Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright 2011-2022 Blender Foundation */
#pragma once
CCL_NAMESPACE_BEGIN
-class GuidingParams {
+struct GuidingParams {
+ /* The subset of path guiding parameters that can trigger a creation/rebuild
+ * of the guiding field. */
+ bool use = false;
+ GuidingDistributionType type = GUIDING_TYPE_PARALLAX_AWARE_VMM;
- public:
GuidingParams() = default;
- // the subset of path guiding parameters that can
- // trigger a creation/rebuild of the guiding field
- bool use{false};
- GuidingDistributionType type{GUIDING_TYPE_PAVMM};
-
bool modified(const GuidingParams &other) const
{
return !(use == other.use && type == other.type);
}
};
-CCL_NAMESPACE_END
\ No newline at end of file
+CCL_NAMESPACE_END
diff --git a/intern/cycles/integrator/path_trace.cpp b/intern/cycles/integrator/path_trace.cpp
index 945a57ccb82..7700766cadd 100644
--- a/intern/cycles/integrator/path_trace.cpp
+++ b/intern/cycles/integrator/path_trace.cpp
@@ -173,29 +173,24 @@ void PathTrace::render_pipeline(RenderWork render_work)
rebalance(render_work);
-#ifdef WITH_PATH_GUIDING
- /* Prepare all per-thread guiding structures before we start with the
- * next rendering iteration/progression. */
+ /* Prepare all per-thread guiding structures before we start with the next rendering
+ * iteration/progression. */
const bool use_guiding = device_scene_->data.integrator.use_guiding;
if (use_guiding) {
guiding_prepare_structures();
}
-#endif
path_trace(render_work);
if (render_cancel_.is_requested) {
return;
}
-#ifdef WITH_PATH_GUIDING
- /* Update the guiding field using the training data/samples collected
- * during the rendering iteration/progression.
- * Note: we also should check if the guiding structure should be reseted due to scene changes
- */
+ /* Update the guiding field using the training data/samples collected during the rendering
+ * iteration/progression. TODO: we also should check if the guiding structure should be reset
+ * due to scene changes. */
if (use_guiding) {
guiding_update_structures();
}
-#endif
adaptive_sample(render_work);
if (render_cancel_.is_requested) {
@@ -1237,66 +1232,72 @@ string PathTrace::full_report() const
return result;
}
-#ifdef WITH_PATH_GUIDING
-void PathTrace::set_guiding_params(ccl::Device *device, const GuidingParams &guiding)
+void PathTrace::set_guiding_params(const GuidingParams &guiding_params, const bool reset)
{
- if (!guiding_sample_data_storage_) {
- guiding_sample_data_storage_ = new openpgl::cpp::SampleStorage();
- }
- guiding_sample_data_storage_->Clear();
-
- PGLFieldArguments guidingFieldArgs;
- switch (guiding.type) {
- default:
- // Using parallax-aware von Mises-Fisher mixture models.
- case GUIDING_TYPE_PAVMM: {
- pglFieldArgumentsSetDefaults(
- guidingFieldArgs,
- PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
- PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_PARALLAX_AWARE_VMM);
- break;
- }
- // Using directional quad-trees.
- case GUIDING_TYPE_DQT: {
- pglFieldArgumentsSetDefaults(
- guidingFieldArgs,
- PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
- PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_QUADTREE);
- break;
+#ifdef WITH_PATH_GUIDING
+ if (guiding_params_.modified(guiding_params)) {
+ guiding_params_ = guiding_params;
+
+ if (guiding_params_.use) {
+ PGLFieldArguments guidingFieldArgs;
+ switch (guiding_params_.type) {
+ default:
+ /* Parallax-aware von Mises-Fisher mixture models. */
+ case GUIDING_TYPE_PARALLAX_AWARE_VMM: {
+ pglFieldArgumentsSetDefaults(
+ guidingFieldArgs,
+ PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
+ PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_PARALLAX_AWARE_VMM);
+ break;
+ }
+ /* Directional quad-trees. */
+ case GUIDING_TYPE_DIRECTIONAL_QUAD_TREE: {
+ pglFieldArgumentsSetDefaults(
+ guidingFieldArgs,
+ PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
+ PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_QUADTREE);
+ break;
+ }
+ /* von Mises-Fisher mixture models. */
+ case GUIDING_TYPE_VMM: {
+ pglFieldArgumentsSetDefaults(
+ guidingFieldArgs,
+ PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
+ PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_VMM);
+ break;
+ }
+ }
+
+ guiding_sample_data_storage_ = make_unique<openpgl::cpp::SampleStorage>();
+ guiding_field_.reset(
+ static_cast<openpgl::cpp::Field *>(device_->create_guiding_field(&guidingFieldArgs)));
}
- // Using von Mises-Fisher mixture models.
- case GUIDING_TYPE_VMM: {
- pglFieldArgumentsSetDefaults(
- guidingFieldArgs,
- PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
- PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_VMM);
- break;
+ else {
+ guiding_sample_data_storage_ = nullptr;
+ guiding_field_ = nullptr;
}
}
-
- if (guiding_field_) {
- delete guiding_field_;
- }
- guiding_field_ = static_cast<openpgl::cpp::Field *>(
- device->create_guiding_field(&guidingFieldArgs));
-}
-
-void PathTrace::reset_guiding_field()
-{
- if (guiding_field_) {
- guiding_field_->Reset();
+ else if (reset) {
+ if (guiding_field_) {
+ guiding_field_->Reset();
+ }
}
+#endif
}
void PathTrace::guiding_prepare_structures()
{
+#ifdef WITH_PATH_GUIDING
for (auto &&path_trace_work : path_trace_works_) {
- path_trace_work->guiding_init_kernel_globals(guiding_field_, guiding_sample_data_storage_);
+ path_trace_work->guiding_init_kernel_globals(guiding_field_.get(),
+ guiding_sample_data_storage_.get());
}
+#endif
}
void PathTrace::guiding_update_structures()
{
+#ifdef WITH_PATH_GUIDING
// TODO(sherholz): implement
# ifdef WITH_PATH_GUIDING_DEBUG_PRINT
VLOG_WORK << "Path Guiding: update guiding structures";
@@ -1336,8 +1337,7 @@ void PathTrace::guiding_update_structures()
guiding_sample_data_storage_->Clear();
}
}
-}
-
#endif
+}
CCL_NAMESPACE_END
diff --git a/intern/cycles/integrator/path_trace.h b/intern/cycles/integrator/path_trace.h
index a834422cfb1..82f8862636c 100644
--- a/intern/cycles/integrator/path_trace.h
+++ b/intern/cycles/integrator/path_trace.h
@@ -4,17 +4,19 @@
#pragma once
#include "integrator/denoiser.h"
+#include "integrator/guiding.h"
#include "integrator/pass_accessor.h"
#include "integrator/path_trace_work.h"
#include "integrator/work_balancer.h"
+
#include "session/buffers.h"
+
#include "util/function.h"
#include "util/thread.h"
#include "util/unique_ptr.h"
#include "util/vector.h"
#ifdef WITH_PATH_GUIDING
-# include "integrator/guiding.h"
# include <openpgl/cpp/OpenPGL.h>
#endif
@@ -94,14 +96,9 @@ class PathTrace {
* Us
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list