[Bf-blender-cvs] [e1a33487556] master: Fix T101458: Changing volume density when pg is enabled causes crash

Sebastian Herholz noreply at git.blender.org
Thu Oct 6 14:40:07 CEST 2022


Commit: e1a334875567418ab7a878d7ffac77f083ad8b10
Author: Sebastian Herholz
Date:   Thu Oct 6 14:39:44 2022 +0200
Branches: master
https://developer.blender.org/rBe1a334875567418ab7a878d7ffac77f083ad8b10

Fix T101458: Changing volume density when pg is enabled causes crash

Changing volume parameters during rendering could cause a crash
when guiding was enabled. It was due to an unintialized state paramter
at the beginning of the path tracing process.

In addition guiding is disabled when dealing with almost delta volumes
(i.e., g close to 1.0 or -1.0).

===================================================================

M	intern/cycles/cmake/external_libs.cmake
M	intern/cycles/kernel/integrator/guiding.h
M	intern/cycles/kernel/integrator/path_state.h

===================================================================

diff --git a/intern/cycles/cmake/external_libs.cmake b/intern/cycles/cmake/external_libs.cmake
index 9335024f2eb..9524cda54f5 100644
--- a/intern/cycles/cmake/external_libs.cmake
+++ b/intern/cycles/cmake/external_libs.cmake
@@ -274,7 +274,7 @@ endif()
 ###########################################################################
 
 if(CYCLES_STANDALONE_REPOSITORY AND WITH_CYCLES_PATH_GUIDING)
-  if(EXISTS ${_cycles_lib_dir})
+  if(NOT openpgl_DIR AND EXISTS ${_cycles_lib_dir})
     set(openpgl_DIR ${_cycles_lib_dir}/openpgl/lib/cmake/openpgl)
   endif()
 
diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h
index 5904b69b046..634bba2a9b4 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -501,6 +501,11 @@ ccl_device_forceinline bool guiding_phase_init(KernelGlobals kg,
                                                ccl_private float &rand)
 {
 #if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
+  /* we do not need to guide almost delta phase functions */
+  if (fabsf(g) >= 0.99f) {
+    return false;
+  }
+
   if (kg->opgl_volume_sampling_distribution->Init(
           kg->opgl_guiding_field, guiding_point3f(P), rand, true)) {
     kg->opgl_volume_sampling_distribution->ApplySingleLobeHenyeyGreensteinProduct(guiding_vec3f(D),
diff --git a/intern/cycles/kernel/integrator/path_state.h b/intern/cycles/kernel/integrator/path_state.h
index dbc6fc5a883..7197f0f2f3a 100644
--- a/intern/cycles/kernel/integrator/path_state.h
+++ b/intern/cycles/kernel/integrator/path_state.h
@@ -59,6 +59,13 @@ ccl_device_inline void path_state_init_integrator(KernelGlobals kg,
 #ifdef __PATH_GUIDING__
   INTEGRATOR_STATE_WRITE(state, path, unguided_throughput) = 1.0f;
   INTEGRATOR_STATE_WRITE(state, guiding, path_segment) = nullptr;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_surface_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_surface_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, surface_guiding_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, bssrdf_sampling_prob) = 0.0f;
+  INTEGRATOR_STATE_WRITE(state, guiding, use_volume_guiding) = false;
+  INTEGRATOR_STATE_WRITE(state, guiding, sample_volume_guiding_rand) = 0.5f;
+  INTEGRATOR_STATE_WRITE(state, guiding, volume_guiding_sampling_prob) = 0.0f;
 #endif
 
 #ifdef __MNEE__



More information about the Bf-blender-cvs mailing list