[Bf-blender-cvs] [60119daef56] master: Cycles: remove old Sobol pattern, simplify sampling dimensions

Brecht Van Lommel noreply at git.blender.org
Thu Sep 1 14:59:09 CEST 2022


Commit: 60119daef569f647c3004360daf657739461b750
Author: Brecht Van Lommel
Date:   Fri Aug 26 13:14:57 2022 +0200
Branches: master
https://developer.blender.org/rB60119daef569f647c3004360daf657739461b750

Cycles: remove old Sobol pattern, simplify sampling dimensions

The multi-dimensional Sobol pattern required us to carefully use as low
dimensions as possible, as quality goes down in higher dimensions. Now that we
have two sampling patterns that are at least as good, there is no need to keep
it around and the implementation can be simplified.

Differential Revision: https://developer.blender.org/D15788

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/sync.cpp
M	intern/cycles/kernel/data_arrays.h
M	intern/cycles/kernel/integrator/init_from_bake.h
M	intern/cycles/kernel/integrator/init_from_camera.h
M	intern/cycles/kernel/integrator/mnee.h
M	intern/cycles/kernel/integrator/path_state.h
M	intern/cycles/kernel/integrator/shade_surface.h
M	intern/cycles/kernel/integrator/shade_volume.h
M	intern/cycles/kernel/integrator/subsurface_disk.h
M	intern/cycles/kernel/integrator/subsurface_random_walk.h
M	intern/cycles/kernel/sample/pattern.h
M	intern/cycles/kernel/svm/ao.h
M	intern/cycles/kernel/svm/bevel.h
M	intern/cycles/kernel/types.h
M	intern/cycles/scene/CMakeLists.txt
M	intern/cycles/scene/integrator.cpp
D	intern/cycles/scene/sobol.cpp
D	intern/cycles/scene/sobol.h
D	intern/cycles/scene/sobol.tables

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index a9954016829..699c90183fe 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -81,9 +81,8 @@ enum_use_layer_samples = (
 )
 
 enum_sampling_pattern = (
-    ('SOBOL', "Sobol", "Use Sobol random sampling pattern", 0),
+    ('SOBOL', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 0),
     ('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1),
-    ('SOBOL_BURLEY', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 2),
 )
 
 enum_volume_sampling = (
@@ -382,7 +381,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
 
     sampling_pattern: EnumProperty(
         name="Sampling Pattern",
-        description="Random sampling pattern used by the integrator. When adaptive sampling is enabled, Progressive Multi-Jitter is always used instead of Sobol",
+        description="Random sampling pattern used by the integrator. When adaptive sampling is enabled, Progressive Multi-Jitter is always used instead of Sobol-Burley",
         items=enum_sampling_pattern,
         default='PROGRESSIVE_MULTI_JITTER',
     )
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index 3808cbf1459..fe16f19556e 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -343,7 +343,7 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
   integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold"));
 
   SamplingPattern sampling_pattern = (SamplingPattern)get_enum(
-      cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
+      cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_PMJ);
   integrator->set_sampling_pattern(sampling_pattern);
 
   int samples = 1;
diff --git a/intern/cycles/kernel/data_arrays.h b/intern/cycles/kernel/data_arrays.h
index 7205f728088..f2877e6c37f 100644
--- a/intern/cycles/kernel/data_arrays.h
+++ b/intern/cycles/kernel/data_arrays.h
@@ -70,7 +70,7 @@ KERNEL_DATA_ARRAY(KernelShader, shaders)
 /* lookup tables */
 KERNEL_DATA_ARRAY(float, lookup_table)
 
-/* sobol */
+/* PMJ sample pattern */
 KERNEL_DATA_ARRAY(float, sample_pattern_lut)
 
 /* image textures */
diff --git a/intern/cycles/kernel/integrator/init_from_bake.h b/intern/cycles/kernel/integrator/init_from_bake.h
index c77fc2540c1..c00d677d420 100644
--- a/intern/cycles/kernel/integrator/init_from_bake.h
+++ b/intern/cycles/kernel/integrator/init_from_bake.h
@@ -126,7 +126,7 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg,
     filter_x = filter_y = 0.5f;
   }
   else {
-    path_rng_2D(kg, rng_hash, sample, PRNG_FILTER_U, &filter_x, &filter_y);
+    path_rng_2D(kg, rng_hash, sample, PRNG_FILTER, &filter_x, &filter_y);
   }
 
   /* Initialize path state for path integration. */
diff --git a/intern/cycles/kernel/integrator/init_from_camera.h b/intern/cycles/kernel/integrator/init_from_camera.h
index e89ab3991c7..a2fbf551241 100644
--- a/intern/cycles/kernel/integrator/init_from_camera.h
+++ b/intern/cycles/kernel/integrator/init_from_camera.h
@@ -30,13 +30,13 @@ ccl_device_inline void integrate_camera_sample(KernelGlobals kg,
     filter_v = 0.5f;
   }
   else {
-    path_rng_2D(kg, rng_hash, sample, PRNG_FILTER_U, &filter_u, &filter_v);
+    path_rng_2D(kg, rng_hash, sample, PRNG_FILTER, &filter_u, &filter_v);
   }
 
   /* Depth of field sampling. */
   float lens_u = 0.0f, lens_v = 0.0f;
   if (kernel_data.cam.aperturesize > 0.0f) {
-    path_rng_2D(kg, rng_hash, sample, PRNG_LENS_U, &lens_u, &lens_v);
+    path_rng_2D(kg, rng_hash, sample, PRNG_LENS, &lens_u, &lens_v);
   }
 
   /* Motion blur time sampling. */
diff --git a/intern/cycles/kernel/integrator/mnee.h b/intern/cycles/kernel/integrator/mnee.h
index c95f1557f04..ec850bb05ea 100644
--- a/intern/cycles/kernel/integrator/mnee.h
+++ b/intern/cycles/kernel/integrator/mnee.h
@@ -1034,7 +1034,7 @@ ccl_device_forceinline int kernel_path_mnee_sample(KernelGlobals kg,
           if (microfacet_bsdf->alpha_x > 0.f && microfacet_bsdf->alpha_y > 0.f) {
             /* Sample transmissive microfacet bsdf. */
             float bsdf_u, bsdf_v;
-            path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+            path_state_rng_2D(kg, rng_state, PRNG_SURFACE_BSDF, &bsdf_u, &bsdf_v);
             h = mnee_sample_bsdf_dh(
                 bsdf->type, microfacet_bsdf->alpha_x, microfacet_bsdf->alpha_y, bsdf_u, bsdf_v);
           }
diff --git a/intern/cycles/kernel/integrator/path_state.h b/intern/cycles/kernel/integrator/path_state.h
index a41e922b593..0ef89b6f52f 100644
--- a/intern/cycles/kernel/integrator/path_state.h
+++ b/intern/cycles/kernel/integrator/path_state.h
@@ -48,7 +48,7 @@ ccl_device_inline void path_state_init_integrator(KernelGlobals kg,
   INTEGRATOR_STATE_WRITE(state, path, volume_bounce) = 0;
   INTEGRATOR_STATE_WRITE(state, path, volume_bounds_bounce) = 0;
   INTEGRATOR_STATE_WRITE(state, path, rng_hash) = rng_hash;
-  INTEGRATOR_STATE_WRITE(state, path, rng_offset) = PRNG_BASE_NUM;
+  INTEGRATOR_STATE_WRITE(state, path, rng_offset) = PRNG_BOUNCE_NUM;
   INTEGRATOR_STATE_WRITE(state, path, flag) = PATH_RAY_CAMERA | PATH_RAY_MIS_SKIP |
                                               PATH_RAY_TRANSPARENT_BACKGROUND;
   INTEGRATOR_STATE_WRITE(state, path, mis_ray_pdf) = 0.0f;
@@ -314,19 +314,6 @@ ccl_device_inline void path_state_rng_2D(KernelGlobals kg,
       kg, rng_state->rng_hash, rng_state->sample, rng_state->rng_offset + dimension, fx, fy);
 }
 
-ccl_device_inline float path_state_rng_1D_hash(KernelGlobals kg,
-                                               ccl_private const RNGState *rng_state,
-                                               uint hash)
-{
-  /* Use a hash instead of dimension, this is not great but avoids adding
-   * more dimensions to each bounce which reduces quality of dimensions we
-   * are already using. */
-  return path_rng_1D(kg,
-                     hash_wang_seeded_uint(rng_state->rng_hash, hash),
-                     rng_state->sample,
-                     rng_state->rng_offset);
-}
-
 ccl_device_inline float path_branched_rng_1D(KernelGlobals kg,
                                              ccl_private const RNGState *rng_state,
                                              int branch,
diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h
index f42e2979b3b..3225a27701c 100644
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ b/intern/cycles/kernel/integrator/shade_surface.h
@@ -156,7 +156,7 @@ ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg,
     const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
     const uint bounce = INTEGRATOR_STATE(state, path, bounce);
     float light_u, light_v;
-    path_state_rng_2D(kg, rng_state, PRNG_LIGHT_U, &light_u, &light_v);
+    path_state_rng_2D(kg, rng_state, PRNG_LIGHT, &light_u, &light_v);
 
     if (!light_distribution_sample_from_position(
             kg, light_u, light_v, sd->time, sd->P, bounce, path_flag, &ls)) {
@@ -348,7 +348,7 @@ ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce(
   }
 
   float bsdf_u, bsdf_v;
-  path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+  path_state_rng_2D(kg, rng_state, PRNG_SURFACE_BSDF, &bsdf_u, &bsdf_v);
   ccl_private const ShaderClosure *sc = shader_bsdf_bssrdf_pick(sd, &bsdf_u);
 
 #ifdef __SUBSURFACE__
@@ -457,7 +457,7 @@ ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
   }
 
   float bsdf_u, bsdf_v;
-  path_state_rng_2D(kg, rng_state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
+  path_state_rng_2D(kg, rng_state, PRNG_SURFACE_BSDF, &bsdf_u, &bsdf_v);
 
   float3 ao_N;
   const Spectrum ao_weight = shader_bsdf_ao(
diff --git a/intern/cycles/kernel/integrator/shade_volume.h b/intern/cycles/kernel/integrator/shade_volume.h
index 599454c5cb2..f4512b3bc79 100644
--- a/intern/cycles/kernel/integrator/shade_volume.h
+++ b/intern/cycles/kernel/integrator/shade_volume.h
@@ -144,11 +144,11 @@ ccl_device_forceinline void volume_step_init(KernelGlobals kg,
 
     /* Perform shading at this offset within a step, to integrate over
      * over the entire step segment. */
-    *step_shade_offset = path_state_rng_1D_hash(kg, rng_state, 0x1e31d8a4);
+    *step_shade_offset = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_SHADE_OFFSET);
 
     /* Shift starting point of all segment by this random amount to avoid
      * banding artifacts from the volume bounding shape. */
-    *steps_offset = path_state_rng_1D_hash(kg, rng_state, 0x3d22c7b3);
+    *steps_offset = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_OFFSET);
   }
 }
 
@@ -549,8 +549,8 @@ ccl_device_forceinline void volume_integrate_heterogeneous(
   vstate.tmin = ray->tmin;
   vstate.tmax = ray->tmin;
   vstate.absorption_only = true;
-  vstate.rscatter = path_state_rng_1D(kg, rng_state, PRNG_SCATTER_DISTANCE);
-  vstate.rphase = path_state_rng_1D(kg, rng_state, PRNG_PHASE_CHANNEL);
+  vstate.rscatter = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_SCATTER_DISTANCE);
+  vstate.rphase = path_state_rng_1D(kg, rng_state, PRNG_VOLUME_PHASE_CHANNEL);
 
   /* Multiple importance sampling: pick between equiangular and distance sampling strategy. */
   vstate.direct_sample_method = direct_sample_method;
@@ -695,7 +695,7 @@ ccl_device_forceinline bool integrate_volume_sample_light(
   const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
   const uint bounce = INTEGRATOR_STATE(state, path, bounce);
   float light_u, light_v;
-  path_state_rng_2D(kg, rng_state, PRNG_LIGHT_U, &light_u, &light_v);
+  path_state_rng_2D(kg, rng_state, PRNG_LIGHT, &light_u, &light_v);
 
   if (!light_distribution_sample_from_volume_segment(
           kg, light_u, light_v, sd->time, sd->P, bounce, path_flag, ls)) {
@@ -736,7 +736,7 @@ ccl_device_forceinline void integrate_volume_direct_light(
     const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
     const uint bounce = INTEGRATOR_STATE(state, path, bounce);


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list