[Bf-blender-cvs] [7a92b8820b9] master: Cycles: remove hair minimum width support.

Brecht Van Lommel noreply at git.blender.org
Wed Apr 24 14:49:04 CEST 2019


Commit: 7a92b8820b9661af39165f048d716559e513ddab
Author: Brecht Van Lommel
Date:   Sat Mar 16 22:05:37 2019 +0100
Branches: master
https://developer.blender.org/rB7a92b8820b9661af39165f048d716559e513ddab

Cycles: remove hair minimum width support.

This never really worked as it was supposed to. The main goal of this is to
turn noise from sampling tiny hairs into multiple layers of transparency that
do not need to be sampled stochastically. However the implementation of this
worked by randomly discarding hair intersections in BVH traversal, which
defeats the purpose.

If it ever comes back, it's best implemented outside the kernel as a preprocess
that changes hair radius before BVH building. This would also make it work with
Embree, where it's not supported now. But it's not so clear anymore that with
many AA samples and GPU rendering this feature is as helpful as it once was for
CPU raytracers with few AA samples.

The benefit of removing this feature is improved hair ray tracing performance,
tested on NVIDIA Titan Xp:

bmw27: +0.37%
classroom: +0.26%
fishy_cat: -7.36%
koro: -12.98%
pabellon: -0.12%

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

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_curves.cpp
M	intern/cycles/kernel/bvh/bvh.h
M	intern/cycles/kernel/bvh/bvh_nodes.h
M	intern/cycles/kernel/bvh/bvh_shadow_all.h
M	intern/cycles/kernel/bvh/bvh_traversal.h
M	intern/cycles/kernel/bvh/bvh_types.h
M	intern/cycles/kernel/bvh/obvh_nodes.h
M	intern/cycles/kernel/bvh/obvh_shadow_all.h
M	intern/cycles/kernel/bvh/obvh_traversal.h
M	intern/cycles/kernel/bvh/qbvh_nodes.h
M	intern/cycles/kernel/bvh/qbvh_shadow_all.h
M	intern/cycles/kernel/bvh/qbvh_traversal.h
M	intern/cycles/kernel/geom/geom_curve_intersect.h
M	intern/cycles/kernel/kernel_path.h
M	intern/cycles/kernel/kernel_shadow.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/kernel/osl/osl_services.cpp
M	intern/cycles/kernel/svm/svm_ao.h
M	intern/cycles/render/curves.cpp
M	intern/cycles/render/curves.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index ae07bcd38fe..d6242fc3f7c 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -1192,20 +1192,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
         min=3, max=64,
         default=3,
     )
-    minimum_width: FloatProperty(
-        name="Minimal width",
-        description="Minimal pixel width for strands (0 - deactivated)",
-        min=0.0, max=100.0,
-        default=0.0,
-        subtype='PIXEL'
-    )
-    maximum_width: FloatProperty(
-        name="Maximal width",
-        description="Maximum extension that strand radius can be increased by",
-        min=0.0, max=100.0,
-        default=0.1,
-        subtype='PIXEL'
-    )
     subdivisions: IntProperty(
         name="Subdivisions",
         description="Number of subdivisions used in Cardinal curve intersection (power of 2)",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 16ad3716d4b..bcf9a351758 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -358,8 +358,6 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
         layout.active = ccscene.use_curves
 
         col = layout.column()
-        col.prop(ccscene, "minimum_width", text="Min Pixels")
-        col.prop(ccscene, "maximum_width", text="Max Extension")
         col.prop(ccscene, "shape", text="Shape")
         if not (ccscene.primitive in {'CURVE_SEGMENTS', 'LINE_SEGMENTS'} and ccscene.shape == 'RIBBONS'):
             col.prop(ccscene, "cull_backfacing", text="Cull back-faces")
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index d0375ceb79c..636b8e42481 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -897,8 +897,6 @@ void BlenderSync::sync_curve_settings()
   CurveSystemManager prev_curve_system_manager = *curve_system_manager;
 
   curve_system_manager->use_curves = get_boolean(csscene, "use_curves");
-  curve_system_manager->minimum_width = get_float(csscene, "minimum_width");
-  curve_system_manager->maximum_width = get_float(csscene, "maximum_width");
 
   curve_system_manager->primitive = (CurvePrimitiveType)get_enum(
       csscene, "primitive", CURVE_NUM_PRIMITIVE_TYPES, CURVE_LINE_SEGMENTS);
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h
index 13e72ed299f..7503bad37b0 100644
--- a/intern/cycles/kernel/bvh/bvh.h
+++ b/intern/cycles/kernel/bvh/bvh.h
@@ -57,7 +57,7 @@ CCL_NAMESPACE_BEGIN
 
 #if defined(__HAIR__)
 #  define BVH_FUNCTION_NAME bvh_intersect_hair
-#  define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_HAIR_MINIMUM_WIDTH
+#  define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR
 #  include "kernel/bvh/bvh_traversal.h"
 #endif
 
@@ -69,7 +69,7 @@ CCL_NAMESPACE_BEGIN
 
 #if defined(__HAIR__) && defined(__OBJECT_MOTION__)
 #  define BVH_FUNCTION_NAME bvh_intersect_hair_motion
-#  define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_HAIR_MINIMUM_WIDTH | BVH_MOTION
+#  define BVH_FUNCTION_FEATURES BVH_INSTANCING | BVH_HAIR | BVH_MOTION
 #  include "kernel/bvh/bvh_traversal.h"
 #endif
 
@@ -181,10 +181,7 @@ ccl_device_inline bool scene_intersect_valid(const Ray *ray)
 ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
                                           const Ray ray,
                                           const uint visibility,
-                                          Intersection *isect,
-                                          uint *lcg_state,
-                                          float difl,
-                                          float extmax)
+                                          Intersection *isect)
 {
   PROFILING_INIT(kg, PROFILING_INTERSECT);
 
@@ -211,7 +208,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
   if (kernel_data.bvh.have_motion) {
 #  ifdef __HAIR__
     if (kernel_data.bvh.have_curves)
-      return bvh_intersect_hair_motion(kg, &ray, isect, visibility, lcg_state, difl, extmax);
+      return bvh_intersect_hair_motion(kg, &ray, isect, visibility);
 #  endif /* __HAIR__ */
 
     return bvh_intersect_motion(kg, &ray, isect, visibility);
@@ -220,7 +217,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals *kg,
 
 #ifdef __HAIR__
   if (kernel_data.bvh.have_curves)
-    return bvh_intersect_hair(kg, &ray, isect, visibility, lcg_state, difl, extmax);
+    return bvh_intersect_hair(kg, &ray, isect, visibility);
 #endif /* __HAIR__ */
 
 #ifdef __KERNEL_CPU__
diff --git a/intern/cycles/kernel/bvh/bvh_nodes.h b/intern/cycles/kernel/bvh/bvh_nodes.h
index 042630121c8..a33bc73e25b 100644
--- a/intern/cycles/kernel/bvh/bvh_nodes.h
+++ b/intern/cycles/kernel/bvh/bvh_nodes.h
@@ -75,67 +75,6 @@ ccl_device_forceinline int bvh_aligned_node_intersect(KernelGlobals *kg,
 #  endif
 }
 
-ccl_device_forceinline int bvh_aligned_node_intersect_robust(KernelGlobals *kg,
-                                                             const float3 P,
-                                                             const float3 idir,
-                                                             const float t,
-                                                             const float difl,
-                                                             const float extmax,
-                                                             const int node_addr,
-                                                             const uint visibility,
-                                                             float dist[2])
-{
-
-  /* fetch node data */
-  float4 cnodes = kernel_tex_fetch(__bvh_nodes, node_addr + 0);
-  float4 node0 = kernel_tex_fetch(__bvh_nodes, node_addr + 1);
-  float4 node1 = kernel_tex_fetch(__bvh_nodes, node_addr + 2);
-  float4 node2 = kernel_tex_fetch(__bvh_nodes, node_addr + 3);
-
-  /* intersect ray against child nodes */
-  float c0lox = (node0.x - P.x) * idir.x;
-  float c0hix = (node0.z - P.x) * idir.x;
-  float c0loy = (node1.x - P.y) * idir.y;
-  float c0hiy = (node1.z - P.y) * idir.y;
-  float c0loz = (node2.x - P.z) * idir.z;
-  float c0hiz = (node2.z - P.z) * idir.z;
-  float c0min = max4(0.0f, min(c0lox, c0hix), min(c0loy, c0hiy), min(c0loz, c0hiz));
-  float c0max = min4(t, max(c0lox, c0hix), max(c0loy, c0hiy), max(c0loz, c0hiz));
-
-  float c1lox = (node0.y - P.x) * idir.x;
-  float c1hix = (node0.w - P.x) * idir.x;
-  float c1loy = (node1.y - P.y) * idir.y;
-  float c1hiy = (node1.w - P.y) * idir.y;
-  float c1loz = (node2.y - P.z) * idir.z;
-  float c1hiz = (node2.w - P.z) * idir.z;
-  float c1min = max4(0.0f, min(c1lox, c1hix), min(c1loy, c1hiy), min(c1loz, c1hiz));
-  float c1max = min4(t, max(c1lox, c1hix), max(c1loy, c1hiy), max(c1loz, c1hiz));
-
-  if (difl != 0.0f) {
-    float hdiff = 1.0f + difl;
-    float ldiff = 1.0f - difl;
-    if (__float_as_int(cnodes.z) & PATH_RAY_CURVE) {
-      c0min = max(ldiff * c0min, c0min - extmax);
-      c0max = min(hdiff * c0max, c0max + extmax);
-    }
-    if (__float_as_int(cnodes.w) & PATH_RAY_CURVE) {
-      c1min = max(ldiff * c1min, c1min - extmax);
-      c1max = min(hdiff * c1max, c1max + extmax);
-    }
-  }
-
-  dist[0] = c0min;
-  dist[1] = c1min;
-
-#  ifdef __VISIBILITY_FLAG__
-  /* this visibility test gives a 5% performance hit, how to solve? */
-  return (((c0max >= c0min) && (__float_as_uint(cnodes.x) & visibility)) ? 1 : 0) |
-         (((c1max >= c1min) && (__float_as_uint(cnodes.y) & visibility)) ? 2 : 0);
-#  else
-  return ((c0max >= c0min) ? 1 : 0) | ((c1max >= c1min) ? 2 : 0);
-#  endif
-}
-
 ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals *kg,
                                                                const float3 P,
                                                                const float3 dir,
@@ -162,41 +101,6 @@ ccl_device_forceinline bool bvh_unaligned_node_intersect_child(KernelGlobals *kg
   return tnear <= tfar;
 }
 
-ccl_device_forceinline bool bvh_unaligned_node_intersect_child_robust(KernelGlobals *kg,
-                                                                      const float3 P,
-                                                                      const float3 dir,
-                                                                      const float t,
-                                                                      const float difl,
-                                                                      int node_addr,
-                                                                      int child,
-                                                                      float dist[2])
-{
-  Transform space = bvh_unaligned_node_fetch_space(kg, node_addr, child);
-  float3 aligned_dir = transform_direction(&space, dir);
-  float3 aligned_P = transform_point(&space, P);
-  float3 nrdir = -bvh_inverse_direction(aligned_dir);
-  float3 tLowerXYZ = aligned_P * nrdir;
-  float3 tUpperXYZ = tLowerXYZ - nrdir;
-  const float near_x = min(tLowerXYZ.x, tUpperXYZ.x);
-  const float near_y = min(tLowerXYZ.y, tUpperXYZ.y);
-  const float near_z = min(tLowerXYZ.z, tUpperXYZ.z);
-  const float far_x = max(tLowerXYZ.x, tUpperXYZ.x);
-  const float far_y = max(tLowerXYZ.y, tUpperXYZ.y);
-  const float far_z = max(tLowerXYZ.z, tUpperXYZ.z);
-  const float tnear = max4(0.0f, near_x, near_y, near_z);
-  const float tfar = min4(t, far_x, far_y, far_z);
-  *dist = tnear;
-  if (difl != 0.0f) {
-    /* TODO(sergey): Same as for QBVH, needs a proper use. */
-    const float round_down = 1.0f - difl;
-    const float round_up = 1.0f + difl;
-    return round_down * tnear <= round_up * tfar;
-  }
-  else {
-    return tnear <= tfar;
-  }
-}
-
 ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
                                                         const float3 P,
                                                         const float3 dir,
@@ -227,38 +131,6 @@ ccl_device_forceinline int bvh_unaligned_node_intersect(KernelGlobals *kg,
   return mask;
 }
 
-ccl_device_forceinline int bvh_unaligned_nod

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list