[Bf-blender-cvs] [8308ba89ad7] soc-2021-curves: Merge branch 'master' into soc-2021-curves

Dilith Jayakody noreply at git.blender.org
Sun Apr 3 17:34:17 CEST 2022


Commit: 8308ba89ad7176ef39ce35b3d1beb90486266bca
Author: Dilith Jayakody
Date:   Wed Mar 16 12:07:08 2022 +0530
Branches: soc-2021-curves
https://developer.blender.org/rB8308ba89ad7176ef39ce35b3d1beb90486266bca

Merge branch 'master' into soc-2021-curves

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/sync.cpp
M	intern/cycles/kernel/integrator/intersect_volume_stack.h
M	intern/cycles/kernel/integrator/shade_surface.h
M	intern/cycles/kernel/light/sample.h
M	intern/itasc/Scene.cpp
M	intern/mantaflow/intern/strings/fluid_script.h
M	release/scripts/startup/bl_ui/properties_object.py
M	release/scripts/startup/bl_ui/space_node.py
M	source/blender/blenkernel/BKE_subdiv_modifier.h
M	source/blender/blenkernel/BKE_tracking.h
M	source/blender/blenkernel/intern/bpath_test.cc
M	source/blender/blenkernel/intern/fluid.c
M	source/blender/blenkernel/intern/image.cc
M	source/blender/blenkernel/intern/subdiv_modifier.c
M	source/blender/blenkernel/intern/tracking_auto.c
M	source/blender/blenlib/intern/delaunay_2d.cc
M	source/blender/blenlib/intern/expr_pylike_eval.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/compositor/operations/COM_CompositorOperation.cc
M	source/blender/draw/intern/draw_cache_impl_subdivision.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc
M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/armature/armature_select.c
M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/curve/editcurve_pen.c
M	source/blender/editors/curve/editfont.c
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/include/ED_curve.h
M	source/blender/editors/include/ED_lattice.h
M	source/blender/editors/include/ED_mball.h
M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/include/ED_particle.h
M	source/blender/editors/include/ED_select_utils.h
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/lattice/editlattice_select.c
M	source/blender/editors/mesh/editface.c
M	source/blender/editors/mesh/editmesh_path.c
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/metaball/mball_edit.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/render/render_internal.cc
M	source/blender/editors/render/render_preview.cc
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/space_clip/tracking_ops_track.c
M	source/blender/editors/space_outliner/outliner_draw.cc
M	source/blender/editors/space_outliner/outliner_intern.hh
M	source/blender/editors/space_outliner/outliner_select.cc
M	source/blender/editors/space_outliner/outliner_utils.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.hh
M	source/blender/editors/space_view3d/view3d_select.c
M	source/blender/editors/util/select_utils.c
M	source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
M	source/blender/gpu/GPU_capabilities.h
M	source/blender/gpu/intern/gpu_capabilities.cc
M	source/blender/gpu/intern/gpu_capabilities_private.hh
M	source/blender/gpu/opengl/gl_backend.cc
M	source/blender/gpu/shaders/gpu_shader_depth_only_frag.glsl
M	source/blender/ikplugin/intern/itasc_plugin.cpp
M	source/blender/imbuf/intern/dds/Stream.cpp
M	source/blender/imbuf/intern/dds/Stream.h
M	source/blender/imbuf/intern/indexer.c
M	source/blender/imbuf/intern/iris.c
M	source/blender/imbuf/intern/radiance_hdr.c
M	source/blender/io/alembic/intern/abc_customdata.cc
M	source/blender/io/avi/intern/avi_mjpeg.c
M	source/blender/nodes/geometry/nodes/node_geo_input_spline_length.cc
M	source/blender/render/RE_pipeline.h
M	source/blender/render/intern/pipeline.c
M	source/blender/render/intern/render_result.c
M	source/blender/render/intern/render_types.h
M	source/blender/sequencer/intern/effects.c
M	source/blender/sequencer/intern/render.c

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 8896f620b9f..4f78fbfc9e7 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -348,8 +348,8 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
     scrambling_distance: FloatProperty(
         name="Scrambling Distance",
         default=1.0,
-        min=0.0, max=1.0,
-        description="Reduce randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts if set too low. Only works when not using adaptive sampling",
+        min=0.0, soft_max=1.0,
+        description="Reduce randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts if set too low",
     )
     preview_scrambling_distance: BoolProperty(
         name="Scrambling Distance viewport",
@@ -360,7 +360,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
     auto_scrambling_distance: BoolProperty(
         name="Automatic Scrambling Distance",
         default=False,
-        description="Automatically reduce the randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts. Only works when not using adaptive sampling",
+        description="Automatically reduce the randomization between pixels to improve GPU rendering performance, at the cost of possible rendering artifacts",
     )
 
     use_layer_samples: EnumProperty(
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 2b74a1b7ccf..1f50f3da7ae 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -289,11 +289,8 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel):
         layout.separator()
 
         heading = layout.column(align=True, heading="Scrambling Distance")
-        heading.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling)
         heading.prop(cscene, "auto_scrambling_distance", text="Automatic")
-        sub = heading.row()
-        sub.active = not cscene.use_preview_adaptive_sampling
-        sub.prop(cscene, "preview_scrambling_distance", text="Viewport")
+        heading.prop(cscene, "preview_scrambling_distance", text="Viewport")
         heading.prop(cscene, "scrambling_distance", text="Multiplier")
 
         layout.separator()
@@ -1031,7 +1028,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
     def poll(cls, context):
         ob = context.object
         if CyclesButtonsPanel.poll(context) and ob:
-            if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'HAIR', 'POINTCLOUD'}:
+            if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META', 'CAMERA', 'CURVES', 'POINTCLOUD'}:
                 return True
             if ob.instance_type == 'COLLECTION' and ob.instance_collection:
                 return True
@@ -1070,7 +1067,7 @@ class CYCLES_OBJECT_PT_motion_blur(CyclesButtonsPanel, Panel):
 
 
 def has_geometry_visibility(ob):
-    return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT', 'VOLUME', 'POINTCLOUD', 'HAIR'}) or
+    return ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LIGHT', 'VOLUME', 'POINTCLOUD', 'CURVES'}) or
                    (ob.instance_type == 'COLLECTION' and ob.instance_collection))
 
 
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index d4949a5ff30..8af2ee7a435 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -346,31 +346,48 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background)
       cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
   integrator->set_sampling_pattern(sampling_pattern);
 
+  int samples = 1;
   bool use_adaptive_sampling = false;
   if (preview) {
+    samples = get_int(cscene, "preview_samples");
     use_adaptive_sampling = RNA_boolean_get(&cscene, "use_preview_adaptive_sampling");
     integrator->set_use_adaptive_sampling(use_adaptive_sampling);
     integrator->set_adaptive_threshold(get_float(cscene, "preview_adaptive_threshold"));
     integrator->set_adaptive_min_samples(get_int(cscene, "preview_adaptive_min_samples"));
   }
   else {
+    samples = get_int(cscene, "samples");
     use_adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
     integrator->set_use_adaptive_sampling(use_adaptive_sampling);
     integrator->set_adaptive_threshold(get_float(cscene, "adaptive_threshold"));
     integrator->set_adaptive_min_samples(get_int(cscene, "adaptive_min_samples"));
   }
 
-  int samples = get_int(cscene, "samples");
   float scrambling_distance = get_float(cscene, "scrambling_distance");
   bool auto_scrambling_distance = get_boolean(cscene, "auto_scrambling_distance");
   if (auto_scrambling_distance) {
+    if (samples == 0) {
+      /* If samples is 0, then viewport rendering is set to render infinitely. In that case we
+       * override the samples value with 4096 so the Automatic Scrambling Distance algorithm
+       * picks a Scrambling Distance value with a good balance of performance and correlation
+       * artifacts when rendering to high sample counts. */
+      samples = 4096;
+    }
+
+    if (use_adaptive_sampling) {
+      /* If Adaptive Sampling is enabled, use "min_samples" in the Automatic Scrambling Distance
+       * algorithm to avoid artifacts common with Adaptive Sampling + Scrambling Distance. */
+      const AdaptiveSampling adaptive_sampling = integrator->get_adaptive_sampling();
+      samples = min(samples, adaptive_sampling.min_samples);
+    }
     scrambling_distance *= 4.0f / sqrtf(samples);
   }
 
-  /* only use scrambling distance in the viewport if user wants to and disable with AS */
+  /* Only use scrambling distance in the viewport if user wants to. */
   bool preview_scrambling_distance = get_boolean(cscene, "preview_scrambling_distance");
-  if ((preview && !preview_scrambling_distance) || use_adaptive_sampling)
+  if (preview && !preview_scrambling_distance) {
     scrambling_distance = 1.0f;
+  }
 
   if (scrambling_distance != 1.0f) {
     VLOG(3) << "Using scrambling distance: " << scrambling_distance;
diff --git a/intern/cycles/kernel/integrator/intersect_volume_stack.h b/intern/cycles/kernel/integrator/intersect_volume_stack.h
index 4cc933aff50..49ef01dc870 100644
--- a/intern/cycles/kernel/integrator/intersect_volume_stack.h
+++ b/intern/cycles/kernel/integrator/intersect_volume_stack.h
@@ -59,6 +59,8 @@ ccl_device void integrator_volume_stack_update_for_subsurface(KernelGlobals kg,
 
     /* Move ray forward. */
     volume_ray.P = stack_sd->P;
+    volume_ray.self.object = isect.object;
+    volume_ray.self.prim = isect.prim;
     if (volume_ray.t != FLT_MAX) {
       volume_ray.D = normalize_len(to_P - volume_ray.P, &volume_ray.t);
     }
@@ -198,6 +200,8 @@ ccl_device void integrator_volume_stack_init(KernelGlobals kg, IntegratorState s
 
     /* Move ray forward. */
     volume_ray.P = stack_sd->P;
+    volume_ray.self.object = isect.object;
+    volume_ray.self.prim = isect.prim;
     ++step;
   }
 #endif
diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h
index d2442755646..df9af6ca107 100644
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ b/intern/cycles/kernel/integrator/shade_surface.h
@@ -352,13 +352,15 @@ ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
   float ao_pdf;
   sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
+  bool skip_self = true;
+
   Ray ray ccl_optional_struct_init;
-  ray.P = shadow_ray_offset(kg, sd, ao_D);
+  ray.P = shadow_ray_offset(kg, sd, ao_D, &skip_self);
   ray.D = ao_D;
   ray.t = kernel_data.integrator.ao_bounces_distance;
   ray.time = sd->time;
-  ray.self.object = sd->object;
-  ray.self.prim = sd->prim;
+  ray.self.object = (skip_self) ? sd->object : OBJECT_NONE;
+  ray.self.prim = (skip_self) ? sd->prim : PRIM_NONE;
   ray.self.light_object = OBJECT_NONE;
   ray.self.light_prim = PRIM_NONE;
   ray.dP = differential_zero_compact();
diff --git a/intern/cycles/kernel/light/sample.h b/intern/cycles/kernel/light/sample.h
index 41882e4b3ee..5acfc92cca1 100644
--- a/intern/cycles/kernel/light/sample.h
+++ b/intern/cycles/kernel/light/sample.h
@@ -180,11 +180,9 @@ ccl_device_inline float3 shadow_ray_smooth_surface_offset(
 
 ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg,
                                            ccl_private const ShaderData *ccl_restrict sd,
-                                           float3 L)
+                                           float3 L,
+                                           ccl_private bool *r_skip_self)
 {
-  float NL = dot(sd->N, L);
-  bool transmit = (NL < 0.0f);
-  float3 Ng = (transmit ? -sd->Ng : sd->Ng);
   float3 P = sd->P;
 
   if ((sd->type & PRIMITIVE_TRIANGLE) && (sd->shader & SHADER_SMOOTH_NORMAL)) {
@@ -194,19 +192,25 @@ ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg,
      * offset_cutoff = 0.1f means that 10-20% of rays will be affected. Also
      * make a smooth transition near the threshold. */
     if (offset_cutoff > 0.0f) {
-      float NgL = dot(Ng, L);
-      float offset_amount = 0.0f;
+      float NL = dot(sd->N, L);
+      const bool transmit = (NL < 0.0f);
       if (NL < 0) {
         NL = -NL;
       }
-      if (NL < offset_cutoff) {
-        offset_amount = clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f);
-      }
-      else {
-        offset_amount = clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
-      }
+
+      const float3 Ng = (transmit ? -sd->Ng : sd->Ng);
+      const float NgL = dot(Ng, L);
+
+      const float offset_amount = (NL < offset_cutoff) ?
+                                      clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f) :
+                                      clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
+
       if (offset_amount > 0.0f) {
         P += shadow_ray_smooth_surface_offset(kg, sd, Ng) * offset_amount;
+
+        /* Only skip self inters

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list