[Bf-blender-cvs] [309fa3e0f7c] cycles_path_guiding: Guiding: make format

Sebastian Herholz noreply at git.blender.org
Mon Feb 6 12:40:49 CET 2023


Commit: 309fa3e0f7cb1c0fffd252b7ee949fa69ba69cc5
Author: Sebastian Herholz
Date:   Mon Feb 6 12:40:47 2023 +0100
Branches: cycles_path_guiding
https://developer.blender.org/rB309fa3e0f7cb1c0fffd252b7ee949fa69ba69cc5

Guiding: make format

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

M	intern/cycles/integrator/path_trace_work_cpu.cpp
M	intern/cycles/kernel/integrator/guiding.h
M	intern/cycles/kernel/integrator/surface_shader.h
M	intern/cycles/scene/integrator.h

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

diff --git a/intern/cycles/integrator/path_trace_work_cpu.cpp b/intern/cycles/integrator/path_trace_work_cpu.cpp
index 9e612bc60a0..6cef2c984c0 100644
--- a/intern/cycles/integrator/path_trace_work_cpu.cpp
+++ b/intern/cycles/integrator/path_trace_work_cpu.cpp
@@ -359,13 +359,12 @@ void PathTraceWorkCPU::guiding_push_sample_data_to_global_storage(
 #  if PATH_GUIDING_LEVEL >= 2
   const bool use_direct_light = kernel_data.integrator.use_guiding_direct_light;
   const bool use_mis_weights = kernel_data.integrator.use_guiding_mis_weights;
-#  if OPENPGL_VERSION_MINOR >= 5
-  kg->opgl_path_segment_storage->PrepareSamples(
-      use_mis_weights, use_direct_light, false);
-#else
+#    if OPENPGL_VERSION_MINOR >= 5
+  kg->opgl_path_segment_storage->PrepareSamples(use_mis_weights, use_direct_light, false);
+#    else
   kg->opgl_path_segment_storage->PrepareSamples(
       false, nullptr, use_mis_weights, use_direct_light, false);
-#endif
+#    endif
 #  endif
 
 #  ifdef WITH_CYCLES_DEBUG
diff --git a/intern/cycles/kernel/integrator/guiding.h b/intern/cycles/kernel/integrator/guiding.h
index c1384da0158..b93aaf2f16b 100644
--- a/intern/cycles/kernel/integrator/guiding.h
+++ b/intern/cycles/kernel/integrator/guiding.h
@@ -462,13 +462,13 @@ ccl_device_forceinline bool guiding_bsdf_init(KernelGlobals kg,
     kg->opgl_surface_sampling_distribution->ApplyCosineProduct(guiding_point3f(N));
     return true;
   }
-#else
+#  else
   if (kg->opgl_surface_sampling_distribution->Init(
           kg->opgl_guiding_field, guiding_point3f(P), rand, true)) {
     kg->opgl_surface_sampling_distribution->ApplyCosineProduct(guiding_point3f(N));
     return true;
   }
-#endif
+#  endif
 #endif
 
   return false;
@@ -502,8 +502,8 @@ ccl_device_forceinline float guiding_bsdf_pdf(KernelGlobals kg,
 }
 
 ccl_device_forceinline float guiding_surface_incomming_radiance_pdf(KernelGlobals kg,
-                                              IntegratorState state,
-                                              const float3 wo)
+                                                                    IntegratorState state,
+                                                                    const float3 wo)
 {
 #if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4 && OPENPGL_VERSION_MINOR >= 5
   return kg->opgl_surface_sampling_distribution->IncommingRadiancePDF(guiding_vec3f(wo));
@@ -533,14 +533,14 @@ ccl_device_forceinline bool guiding_phase_init(KernelGlobals kg,
                                                                                   g);
     return true;
   }
-#else
+#  else
   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),
                                                                                   g);
     return true;
   }
-#endif
+#  endif
 #endif
 
   return false;
diff --git a/intern/cycles/kernel/integrator/surface_shader.h b/intern/cycles/kernel/integrator/surface_shader.h
index b0e065bacd0..59267a52042 100644
--- a/intern/cycles/kernel/integrator/surface_shader.h
+++ b/intern/cycles/kernel/integrator/surface_shader.h
@@ -22,14 +22,16 @@
 CCL_NAMESPACE_BEGIN
 
 #define RIS_COSINE
-#  if OPENPGL_VERSION_MINOR >= 5
-#define RIS_INCOMMING_RADIANCE
+#if OPENPGL_VERSION_MINOR >= 5
+#  define RIS_INCOMMING_RADIANCE
 #endif
 /* Guiding */
 
 #ifdef __PATH_GUIDING__
 
-ccl_device float surface_shader_average_sample_weight_squared_roughness(ccl_private const ShaderData *sd){
+ccl_device float surface_shader_average_sample_weight_squared_roughness(
+    ccl_private const ShaderData *sd)
+{
   float avg_roughness = 0.0f;
   float sum_sample_weight = 0.0f;
   for (int i = 0; i < sd->num_closure; i++) {
@@ -98,7 +100,7 @@ ccl_device_inline void surface_shader_prepare_guiding(KernelGlobals kg,
   float avg_roughness = surface_shader_average_sample_weight_squared_roughness(sd);
   avg_roughness = safe_sqrtf(avg_roughness);
   /* Init guiding (diffuse BSDFs only for now). */
-  if (!fully_opaque || avg_roughness < guiding_roughness_threshold*guiding_roughness_threshold ||
+  if (!fully_opaque || avg_roughness < guiding_roughness_threshold * guiding_roughness_threshold ||
       ((guiding_directional_sampling_type == GUIDING_DIRECTIONAL_SAMPLING_TYPE_PRODUCT) &&
        (diffuse_sampling_fraction <= 0.f)) ||
       !guiding_bsdf_init(kg, state, sd->P, sd->N, rand_bsdf_guiding)) {
@@ -623,9 +625,9 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
     float3 omega_in_ris[2];
     float ris_pdfs[2] = {0.f, 0.f};
     float guide_pdfs[2] = {0.f, 0.f};
-#ifdef RIS_INCOMMING_RADIANCE
+#  ifdef RIS_INCOMMING_RADIANCE
     float incomming_radiance_pdfs[2] = {0.f, 0.f};
-#endif
+#  endif
     float bsdf_pdfs[2] = {0.f, 0.f};
     float cosines[2] = {0.f, 0.f};
     BsdfEval bsdf_evals[2];
@@ -659,9 +661,10 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
                           3.0f;
       guide_pdfs[0] = guiding_bsdf_pdf(kg, state, omega_in_ris[0]);
       guide_pdfs[0] *= (1.0f - bssrdf_sampling_prob);
-#ifdef RIS_INCOMMING_RADIANCE
-      incomming_radiance_pdfs[0] = guiding_surface_incomming_radiance_pdf(kg, state, omega_in_ris[0]);
-#endif
+#  ifdef RIS_INCOMMING_RADIANCE
+      incomming_radiance_pdfs[0] = guiding_surface_incomming_radiance_pdf(
+          kg, state, omega_in_ris[0]);
+#  endif
       bsdf_pdfs[0] = max(0.f, bsdf_pdfs[0]);
     }
 
@@ -670,9 +673,10 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
     bsdf_eval_init(&bsdf_evals[1], CLOSURE_NONE_ID, eval);
     guide_pdfs[1] = guiding_bsdf_sample(kg, state, rand_guiding_bsdf_ris[1], &omega_in_ris[1]);
     guide_pdfs[1] *= (1.0f - bssrdf_sampling_prob);
-#ifdef RIS_INCOMMING_RADIANCE
-    incomming_radiance_pdfs[1] = guiding_surface_incomming_radiance_pdf(kg, state, omega_in_ris[1]);
-#endif
+#  ifdef RIS_INCOMMING_RADIANCE
+    incomming_radiance_pdfs[1] = guiding_surface_incomming_radiance_pdf(
+        kg, state, omega_in_ris[1]);
+#  endif
     cosines[1] = max(0.01f, fabsf(dot(sd->N, omega_in_ris[1])));
     bsdf_pdfs[1] = surface_shader_bsdf_eval_pdfs(
         kg, sd, omega_in_ris[1], &bsdf_evals[1], unguided_bsdf_pdfs, 0);
@@ -685,18 +689,21 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
     float sum_ris_pdfs = 0.f;
     if (avg_bsdf_evals[0] > 0.f && bsdf_pdfs[0] > 1e-10f && guide_pdfs[0] > 0.f) {
 #  ifdef RIS_COSINE
-#  ifdef RIS_INCOMMING_RADIANCE
+#    ifdef RIS_INCOMMING_RADIANCE
       ris_pdfs[0] = (avg_bsdf_evals[0] *
-                     ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * incomming_radiance_pdfs[0]))) )/
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * incomming_radiance_pdfs[0])))) /
                     (0.5f * (bsdf_pdfs[0] + guide_pdfs[0]));
-#else
+#    else
       ris_pdfs[0] = (avg_bsdf_evals[0] / cosines[0] *
-                     ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * guide_pdfs[0]))) )/
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * guide_pdfs[0])))) /
                     (0.5f * (bsdf_pdfs[0] + guide_pdfs[0]));
-# endif
+#    endif
 #  else
       ris_pdfs[0] = (avg_bsdf_evals[0] *
-                     ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * guide_pdfs[0]))) )/
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * guide_pdfs[0])))) /
                     (0.5f * (bsdf_pdfs[0] + guide_pdfs[0]));
 #  endif
       sum_ris_pdfs += ris_pdfs[0];
@@ -709,18 +716,21 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
 
     if (avg_bsdf_evals[1] > 0.f && bsdf_pdfs[1] > 1e-10f && guide_pdfs[1] > 0.f) {
 #  ifdef RIS_COSINE
-#  ifdef RIS_INCOMMING_RADIANCE
+#    ifdef RIS_INCOMMING_RADIANCE
       ris_pdfs[1] = (avg_bsdf_evals[1] *
-                     ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * incomming_radiance_pdfs[1]))) ) /
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * incomming_radiance_pdfs[1])))) /
                     (0.5f * (bsdf_pdfs[1] + guide_pdfs[1]));
-#else
+#    else
       ris_pdfs[1] = (avg_bsdf_evals[1] / cosines[1] *
-                     ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * guide_pdfs[1]))) ) /
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * guide_pdfs[1])))) /
                     (0.5f * (bsdf_pdfs[1] + guide_pdfs[1]));
-#endif
+#    endif
 #  else
       ris_pdfs[1] = (avg_bsdf_evals[1] *
-                    ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * guide_pdfs[1]))) ) /
+                     ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                       (guiding_sampling_prob * guide_pdfs[1])))) /
                     (0.5f * (bsdf_pdfs[1] + guide_pdfs[1]));
 #  endif
       sum_ris_pdfs += ris_pdfs[1];
@@ -752,18 +762,21 @@ ccl_device int surface_shader_bsdf_guided_sample_closure_ris(KernelGlobals kg,
     assert(ris_idx < 2);
 
 #  ifdef RIS_COSINE
-#  ifdef RIS_INCOMMING_RADIANCE
+#    ifdef RIS_INCOMMING_RADIANCE
     guide_pdf = (avg_bsdf_evals[ris_idx] *
-                 ( (((1.0f-guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) + (guiding_sampling_prob * incomming_radiance_pdfs[ris_idx]))) ) *
+                 ((((1.0f - guiding_sampling_prob) * (1.0f / (pi_factor * float(M_PI)))) +
+                   (guiding_sampling_prob * incomming_radiance_pd

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list