Add support for PGL v0.6.0 #118328

Merged
Brecht Van Lommel merged 4 commits from bartus/blender:pgl6 into main 2024-02-19 13:32:34 +01:00
1 changed files with 33 additions and 0 deletions
Showing only changes of commit 0e5daf2b4e - Show all commits

View File

@ -1286,41 +1286,74 @@ void PathTrace::set_guiding_params(const GuidingParams &guiding_params, const bo
guiding_params_ = guiding_params;
if (guiding_params_.use) {
# if OPENPGL_VERSION_MINOR >= 6
openpgl::cpp::FieldConfig field_config;
# else
PGLFieldArguments field_args;
# endif
switch (guiding_params_.type) {
default:
/* Parallax-aware von Mises-Fisher mixture models. */
case GUIDING_TYPE_PARALLAX_AWARE_VMM: {
# if OPENPGL_VERSION_MINOR >= 6
field_config.Init(
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_PARALLAX_AWARE_VMM,
guiding_params.deterministic);
# else
bartus marked this conversation as resolved Outdated

I would remove the 3200 so that the default parameter from Open PGL is used.

  1. this is the wrong value anyway (it should be 32000 instead of 3200)
  2. being able to set is is more for a debug purpose and should only be done in special cases
  3. Explicitly setting this value generates the problem that the default parameter is overwritten. If Open PGL decides that another value is more robust and preferable this would not work in Blender/Cycles
I would remove the 3200 so that the default parameter from Open PGL is used. 1. this is the wrong value anyway (it should be 32000 instead of 3200) 2. being able to set is is more for a debug purpose and should only be done in special cases 3. Explicitly setting this value generates the problem that the default parameter is overwritten. If Open PGL decides that another value is more robust and preferable this would not work in Blender/Cycles

Fixed

Fixed
pglFieldArgumentsSetDefaults(
field_args,
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_PARALLAX_AWARE_VMM);
# endif
break;
}
/* Directional quad-trees. */
case GUIDING_TYPE_DIRECTIONAL_QUAD_TREE: {
# if OPENPGL_VERSION_MINOR >= 6
field_config.Init(
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_QUADTREE,
guiding_params.deterministic);
# else
pglFieldArgumentsSetDefaults(
field_args,
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_QUADTREE);
# endif
break;
}
/* von Mises-Fisher mixture models. */
case GUIDING_TYPE_VMM: {
# if OPENPGL_VERSION_MINOR >= 6
field_config.Init(
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_VMM,
guiding_params.deterministic);
# else
pglFieldArgumentsSetDefaults(
field_args,
PGL_SPATIAL_STRUCTURE_TYPE::PGL_SPATIAL_STRUCTURE_KDTREE,
PGL_DIRECTIONAL_DISTRIBUTION_TYPE::PGL_DIRECTIONAL_DISTRIBUTION_VMM);
# endif
break;
}
}
# if OPENPGL_VERSION_MINOR >= 6
field_config.SetSpatialStructureArgMaxDepth(16);
# else
field_args.deterministic = guiding_params.deterministic;
reinterpret_cast<PGLKDTreeArguments *>(field_args.spatialSturctureArguments)->maxDepth = 16;
# endif
openpgl::cpp::Device *guiding_device = static_cast<openpgl::cpp::Device *>(
device_->get_guiding_device());
if (guiding_device) {
guiding_sample_data_storage_ = make_unique<openpgl::cpp::SampleStorage>();
# if OPENPGL_VERSION_MINOR >= 6
guiding_field_ = make_unique<openpgl::cpp::Field>(guiding_device, field_config);
# else
guiding_field_ = make_unique<openpgl::cpp::Field>(guiding_device, field_args);
# endif
}
else {
guiding_sample_data_storage_ = nullptr;