From 75a6d3abf75f3082adf5240ae34973844c0d9a09 Mon Sep 17 00:00:00 2001 From: Sebastian Herhoz Date: Wed, 21 Sep 2022 17:58:34 +0200 Subject: Cycles: add Path Guiding on CPU through Intel OpenPGL This adds path guiding features into Cycles by integrating Intel's Open Path Guiding Library. It can be enabled in the Sampling > Path Guiding panel in the render properties. This feature helps reduce noise in scenes where finding a path to light is difficult for regular path tracing. The current implementation supports guiding directional sampling decisions on surfaces, when the material contains a least one diffuse component, and in volumes with isotropic and anisotropic Henyey-Greenstein phase functions. On surfaces, the guided sampling decision is proportional to the product of the incident radiance and the normal-oriented cosine lobe and in volumes it is proportional to the product of the incident radiance and the phase function. The incident radiance field of a scene is learned and updated during rendering after each per-frame rendering iteration/progression. At the moment, path guiding is only supported by the CPU backend. Support for GPU backends will be added in future versions of OpenPGL. Ref T92571 Differential Revision: https://developer.blender.org/D15286 --- intern/cycles/kernel/integrator/path_state.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'intern/cycles/kernel/integrator/path_state.h') diff --git a/intern/cycles/kernel/integrator/path_state.h b/intern/cycles/kernel/integrator/path_state.h index 54560905397..dbc6fc5a883 100644 --- a/intern/cycles/kernel/integrator/path_state.h +++ b/intern/cycles/kernel/integrator/path_state.h @@ -56,6 +56,11 @@ ccl_device_inline void path_state_init_integrator(KernelGlobals kg, INTEGRATOR_STATE_WRITE(state, path, continuation_probability) = 1.0f; INTEGRATOR_STATE_WRITE(state, path, throughput) = one_spectrum(); +#ifdef __PATH_GUIDING__ + INTEGRATOR_STATE_WRITE(state, path, unguided_throughput) = 1.0f; + INTEGRATOR_STATE_WRITE(state, guiding, path_segment) = nullptr; +#endif + #ifdef __MNEE__ INTEGRATOR_STATE_WRITE(state, path, mnee) = 0; #endif @@ -249,7 +254,11 @@ ccl_device_inline float path_state_continuation_probability(KernelGlobals kg, /* Probabilistic termination: use sqrt() to roughly match typical view * transform and do path termination a bit later on average. */ - return min(sqrtf(reduce_max(fabs(INTEGRATOR_STATE(state, path, throughput)))), 1.0f); + Spectrum throughput = INTEGRATOR_STATE(state, path, throughput); +#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4 + throughput *= INTEGRATOR_STATE(state, path, unguided_throughput); +#endif + return min(sqrtf(reduce_max(fabs(throughput))), 1.0f); } ccl_device_inline bool path_state_ao_bounce(KernelGlobals kg, ConstIntegratorState state) -- cgit v1.2.3 From e1a334875567418ab7a878d7ffac77f083ad8b10 Mon Sep 17 00:00:00 2001 From: Sebastian Herholz Date: Thu, 6 Oct 2022 14:39:44 +0200 Subject: 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). --- intern/cycles/kernel/integrator/path_state.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'intern/cycles/kernel/integrator/path_state.h') 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__ -- cgit v1.2.3