[Bf-blender-cvs] [a8188b13882] cycles_path_guiding: Guiding: Added documentation to the guiding helper functions used to record paths
Sebastian Herholz
noreply at git.blender.org
Fri Sep 9 13:16:49 CEST 2022
Commit: a8188b13882060b291c0b0235f8649bba5fa9831
Author: Sebastian Herholz
Date: Fri Sep 9 13:16:26 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rBa8188b13882060b291c0b0235f8649bba5fa9831
Guiding: Added documentation to the guiding helper functions used to record paths
===================================================================
M intern/cycles/kernel/integrator/guiding.h
===================================================================
diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h
index 6d9b97100ff..4db9ab6a79d 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -9,6 +9,8 @@
# include "kernel/film/write.h"
#endif
+#include <iostream>
+
CCL_NAMESPACE_BEGIN
/* Utilities. */
@@ -27,35 +29,11 @@ static pgl_point3f guiding_point3f(const float3 v)
/* Path recording for guiding. */
-ccl_device_forceinline void guiding_record_light_surface_segment(
- KernelGlobals kg, IntegratorState state, ccl_private const Intersection *ccl_restrict isect)
-{
-#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
- if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
- return;
- }
-
- const pgl_vec3f zero = guiding_vec3f(zero_float3());
- const pgl_vec3f one = guiding_vec3f(one_float3());
- const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
- const float3 ray_D = INTEGRATOR_STATE(state, ray, D);
- const float3 P = ray_P + isect->t * ray_D;
-
- state->guiding.path_segment = state->guiding.path_segment_storage->NextSegment();
- openpgl::cpp::SetPosition(state->guiding.path_segment, guiding_point3f(P));
- openpgl::cpp::SetDirectionOut(state->guiding.path_segment, guiding_vec3f(-ray_D));
- openpgl::cpp::SetNormal(state->guiding.path_segment, guiding_vec3f(-ray_D));
- openpgl::cpp::SetDirectionIn(state->guiding.path_segment, guiding_vec3f(ray_D));
- openpgl::cpp::SetPDFDirectionIn(state->guiding.path_segment, 1.0f);
- openpgl::cpp::SetVolumeScatter(state->guiding.path_segment, false);
- openpgl::cpp::SetScatteredContribution(state->guiding.path_segment, zero);
- openpgl::cpp::SetDirectContribution(state->guiding.path_segment, zero);
- openpgl::cpp::SetTransmittanceWeight(state->guiding.path_segment, one);
- openpgl::cpp::SetScatteringWeight(state->guiding.path_segment, one);
- openpgl::cpp::SetEta(state->guiding.path_segment, 1.0f);
-#endif
-}
+/* Record Surface Interactions */
+/* Records/Adds a new path segment with the current path vertex on a surface.
+ * If the path is not terminated this call is usually followed by a call of
+ * guiding_record_surface_bounce. */
ccl_device_forceinline void guiding_record_surface_segment(KernelGlobals kg,
IntegratorState state,
ccl_private const ShaderData *sd)
@@ -79,6 +57,7 @@ ccl_device_forceinline void guiding_record_surface_segment(KernelGlobals kg,
#endif
}
+/* Records the surface scattering event at the current vertex position of the segment.*/
ccl_device_forceinline void guiding_record_surface_bounce(KernelGlobals kg,
IntegratorState state,
ccl_private const ShaderData *sd,
@@ -93,7 +72,6 @@ ccl_device_forceinline void guiding_record_surface_bounce(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const float min_roughness = safe_sqrtf(fminf(roughness.x, roughness.y));
const bool is_delta = (min_roughness == 0.0f);
const float3 weight_rgb = spectrum_to_rgb(weight);
@@ -113,6 +91,29 @@ ccl_device_forceinline void guiding_record_surface_bounce(KernelGlobals kg,
#endif
}
+/* Records the emission at the current surface intersection (physical or virtual) */
+ccl_device_forceinline void guiding_record_surface_emission(KernelGlobals kg,
+ IntegratorState state,
+ const Spectrum Le,
+ const float mis_weight)
+{
+#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
+ if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
+ return;
+ }
+ const float3 Le_rgb = spectrum_to_rgb(Le);
+
+ openpgl::cpp::SetDirectContribution(state->guiding.path_segment, guiding_vec3f(Le_rgb));
+ openpgl::cpp::SetMiWeight(state->guiding.path_segment, mis_weight);
+#endif
+}
+
+/* Record BSSRDF Interactions */
+
+/* Records/Adds a new path segment where the vertex position is the point of entry
+ * of the sub surface scattering boundary.
+ * If the path is not terminated this call is usually followed by a call of
+ * guiding_record_bssrdf_weight and guiding_record_bssrdf_bounce. */
ccl_device_forceinline void guiding_record_bssrdf_segment(KernelGlobals kg,
IntegratorState state,
const float3 P,
@@ -122,7 +123,6 @@ ccl_device_forceinline void guiding_record_bssrdf_segment(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const pgl_vec3f zero = guiding_vec3f(zero_float3());
const pgl_vec3f one = guiding_vec3f(one_float3());
@@ -137,6 +137,8 @@ ccl_device_forceinline void guiding_record_bssrdf_segment(KernelGlobals kg,
#endif
}
+/* Records the transmission of the path at the point of entry while passing
+ * the surface boundary.*/
ccl_device_forceinline void guiding_record_bssrdf_weight(KernelGlobals kg,
IntegratorState state,
const Spectrum weight)
@@ -145,7 +147,6 @@ ccl_device_forceinline void guiding_record_bssrdf_weight(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const float3 weight_rgb = spectrum_to_rgb(weight);
kernel_assert(state->guiding.path_segment != nullptr);
@@ -158,6 +159,10 @@ ccl_device_forceinline void guiding_record_bssrdf_weight(KernelGlobals kg,
#endif
}
+/* Records the direction at the point of entry the path takes when sampling the SSS contribution.
+ * If not terminated this function is usually followed by a call of
+ * guiding_record_volume_transmission to record the transmittance between the point of entry and
+ * the point of exit.*/
ccl_device_forceinline void guiding_record_bssrdf_bounce(KernelGlobals kg,
IntegratorState state,
const float pdf,
@@ -168,7 +173,6 @@ ccl_device_forceinline void guiding_record_bssrdf_bounce(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const float3 normal = clamp(N, -one_float3(), one_float3());
kernel_assert(state->guiding.path_segment != nullptr);
@@ -180,6 +184,11 @@ ccl_device_forceinline void guiding_record_bssrdf_bounce(KernelGlobals kg,
#endif
}
+/* Record Volume Interactions */
+
+/* Records/Adds a new path segment with the current path vertex being inside a volume.
+ * If the path is not terminated this call is usually followed by a call of
+ * guiding_record_volume_bounce. */
ccl_device_forceinline void guiding_record_volume_segment(KernelGlobals kg,
IntegratorState state,
const float3 P,
@@ -189,7 +198,6 @@ ccl_device_forceinline void guiding_record_volume_segment(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const pgl_vec3f zero = guiding_vec3f(zero_float3());
const pgl_vec3f one = guiding_vec3f(one_float3());
@@ -205,6 +213,7 @@ ccl_device_forceinline void guiding_record_volume_segment(KernelGlobals kg,
#endif
}
+/* Records the volume scattering event at the current vertex position of the segment.*/
ccl_device_forceinline void guiding_record_volume_bounce(KernelGlobals kg,
IntegratorState state,
ccl_private const ShaderData *sd,
@@ -217,7 +226,6 @@ ccl_device_forceinline void guiding_record_volume_bounce(KernelGlobals kg,
if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
return;
}
-
const float3 weight_rgb = spectrum_to_rgb(weight);
const float3 normal = make_float3(0.0f, 0.0f, 1.0f);
@@ -235,49 +243,8 @@ ccl_device_forceinline void guiding_record_volume_bounce(KernelGlobals kg,
#endif
}
-ccl_device_forceinline void guiding_record_background(KernelGlobals kg,
- IntegratorState state,
- const Spectrum L,
- const float mis_weight)
-{
-#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
- if (!kernel_data.integrator.use_guiding || !kernel_data.integrator.train_guiding) {
- return;
- }
-
- const float3 L_rgb = spectrum_to_rgb(L);
- const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
- const float3 ray_D = INTEGRATOR_STATE(state, ray, D);
- const float3 P = ray_P + (1e6f) * ray_D;
- const float3 normal = make_float3(0.0f, 0.0f, 1.0f);
-
- openpgl::cpp::PathSegment background_segment;
- openpgl::cpp::SetPosition(&background_segment, guiding_vec3f(P));
- openpgl::cpp::SetNormal(&background_segment, guiding_vec3f(normal));
- openpgl::cpp::SetDirectionOut(&background_segment, guiding_vec3f(-ray_D));
- openpgl::cpp::SetDirectContribution(&background_segment, guiding_vec3f(L_rgb));
- openpgl::cpp::SetMiWeight(&background_segment, mis_weight);
- state->guiding.path_segment_storage->AddSegment(background_segment);
-#endif
-}
-
-ccl_device_forceinline void guiding_record_surface_emission(KernelGlobals kg,
- IntegratorState state,
- const Spectrum Le,
- const float mis_weight)
-{
-#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 1
- if (!kernel_data.integrator.use_guidi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list