[Bf-blender-cvs] [c7d940278b1] master: Cycles: remove support for rendering hair as triangle and lines

Brecht Van Lommel noreply at git.blender.org
Mon Jun 22 13:28:15 CEST 2020


Commit: c7d940278b16bb357a848f176d070e1784ccdde2
Author: Brecht Van Lommel
Date:   Thu Jun 4 15:12:31 2020 +0200
Branches: master
https://developer.blender.org/rBc7d940278b16bb357a848f176d070e1784ccdde2

Cycles: remove support for rendering hair as triangle and lines

Triangles were very memory intensive. The only reason they were not removed yet
is that they gave more accurate results, but there will be an accurate 3D curve
primitive added for this.

Line rendering was always poor quality since the ends do not match up. To keep CPU
and GPU compatibility we just remove them entirely. They could be brought back if
an Embree compatible implementation is added, but it's not clear to me that there
is a use case for these that we'd consider important.

Ref T73778

Reviewers: #cycles

Subscribers:

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_curves.cpp
M	intern/cycles/blender/blender_geometry.cpp
M	intern/cycles/blender/blender_sync.h
M	intern/cycles/bvh/bvh_embree.cpp
M	intern/cycles/bvh/bvh_embree.h
M	intern/cycles/kernel/bvh/bvh_shadow_all.h
M	intern/cycles/kernel/bvh/bvh_traversal.h
M	intern/cycles/kernel/bvh/obvh_shadow_all.h
M	intern/cycles/kernel/bvh/obvh_traversal.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/geom/geom_motion_curve.h
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/kernel/kernels/optix/kernel_optix.cu
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 1635afab210..29ef1814294 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -78,20 +78,9 @@ enum_panorama_types = (
     ('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
 )
 
-enum_curve_primitives = (
-    ('TRIANGLES', "Triangles", "Create triangle geometry around strands"),
-    ('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"),
-    ('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"),
-)
-
-enum_triangle_curves = (
-    ('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"),
-    ('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"),
-)
-
 enum_curve_shape = (
-    ('RIBBONS', "Ribbons", "Ignore thickness of each strand"),
-    ('THICK', "Thick", "Use thickness of strand when rendering"),
+    ('RIBBONS', "Ribbons", "Ignore thickness of each hair"),
+    ('THICK', "Thick", "Use thickness of hair when rendering"),
 )
 
 enum_tile_order = (
@@ -1241,12 +1230,6 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
 
 class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
 
-    primitive: EnumProperty(
-        name="Primitive",
-        description="Type of primitive used for hair rendering",
-        items=enum_curve_primitives,
-        default='LINE_SEGMENTS',
-    )
     shape: EnumProperty(
         name="Shape",
         description="Form of hair",
@@ -1255,7 +1238,7 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
     )
     cull_backfacing: BoolProperty(
         name="Cull Back-faces",
-        description="Do not test the back-face of each strand",
+        description="Do not test the back-face of each hair",
         default=True,
     )
     use_curves: BoolProperty(
@@ -1263,12 +1246,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
         description="Activate Cycles hair rendering for particle system",
         default=True,
     )
-    resolution: IntProperty(
-        name="Resolution",
-        description="Resolution of generated mesh",
-        min=3, max=64,
-        default=3,
-    )
     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 78a44881743..b6d19b1d4a7 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -406,14 +406,11 @@ class CYCLES_RENDER_PT_hair(CyclesButtonsPanel, Panel):
 
         col = layout.column()
         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")
-        col.prop(ccscene, "primitive", text="Primitive")
-
-        if ccscene.primitive == 'TRIANGLES' and ccscene.shape == 'THICK':
-            col.prop(ccscene, "resolution", text="Resolution")
-        elif ccscene.primitive == 'CURVE_SEGMENTS':
+        if ccscene.shape == 'RIBBONS':
+            # TODO: use for embree
             col.prop(ccscene, "subdivisions", text="Curve subdivisions")
+        else:
+            col.prop(ccscene, "cull_backfacing", text="Cull back-faces")
 
 
 class CYCLES_RENDER_PT_volumes(CyclesButtonsPanel, Panel):
diff --git a/intern/cycles/blender/blender_curves.cpp b/intern/cycles/blender/blender_curves.cpp
index 847a43c5f34..43fe653fda4 100644
--- a/intern/cycles/blender/blender_curves.cpp
+++ b/intern/cycles/blender/blender_curves.cpp
@@ -18,7 +18,6 @@
 #include "render/camera.h"
 #include "render/curves.h"
 #include "render/hair.h"
-#include "render/mesh.h"
 #include "render/object.h"
 #include "render/scene.h"
 
@@ -39,27 +38,6 @@ ParticleCurveData::~ParticleCurveData()
 {
 }
 
-static void interp_weights(float t, float data[4])
-{
-  /* Cardinal curve interpolation */
-  float t2 = t * t;
-  float t3 = t2 * t;
-  float fc = 0.71f;
-
-  data[0] = -fc * t3 + 2.0f * fc * t2 - fc * t;
-  data[1] = (2.0f - fc) * t3 + (fc - 3.0f) * t2 + 1.0f;
-  data[2] = (fc - 2.0f) * t3 + (3.0f - 2.0f * fc) * t2 + fc * t;
-  data[3] = fc * t3 - fc * t2;
-}
-
-static void curveinterp_v3_v3v3v3v3(
-    float3 *p, float3 *v1, float3 *v2, float3 *v3, float3 *v4, const float w[4])
-{
-  p->x = v1->x * w[0] + v2->x * w[1] + v3->x * w[2] + v4->x * w[3];
-  p->y = v1->y * w[0] + v2->y * w[1] + v3->y * w[2] + v4->y * w[3];
-  p->z = v1->z * w[0] + v2->z * w[1] + v3->z * w[2] + v4->z * w[3];
-}
-
 static float shaperadius(float shape, float root, float tip, float time)
 {
   assert(time >= 0.0f);
@@ -77,43 +55,13 @@ static float shaperadius(float shape, float root, float tip, float time)
 
 /* curve functions */
 
-static void InterpolateKeySegments(
-    int seg, int segno, int key, int curve, float3 *keyloc, float *time, ParticleCurveData *CData)
-{
-  float3 ckey_loc1 = CData->curvekey_co[key];
-  float3 ckey_loc2 = ckey_loc1;
-  float3 ckey_loc3 = CData->curvekey_co[key + 1];
-  float3 ckey_loc4 = ckey_loc3;
-
-  if (key > CData->curve_firstkey[curve])
-    ckey_loc1 = CData->curvekey_co[key - 1];
-
-  if (key < CData->curve_firstkey[curve] + CData->curve_keynum[curve] - 2)
-    ckey_loc4 = CData->curvekey_co[key + 2];
-
-  float time1 = CData->curvekey_time[key] / CData->curve_length[curve];
-  float time2 = CData->curvekey_time[key + 1] / CData->curve_length[curve];
-
-  float dfra = (time2 - time1) / (float)segno;
-
-  if (time)
-    *time = (dfra * seg) + time1;
-
-  float t[4];
-
-  interp_weights((float)seg / (float)segno, t);
-
-  if (keyloc)
-    curveinterp_v3_v3v3v3v3(keyloc, &ckey_loc1, &ckey_loc2, &ckey_loc3, &ckey_loc4, t);
-}
-
 static bool ObtainCacheParticleData(
-    Geometry *geom, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background)
+    Hair *hair, BL::Mesh *b_mesh, BL::Object *b_ob, ParticleCurveData *CData, bool background)
 {
   int curvenum = 0;
   int keyno = 0;
 
-  if (!(geom && b_mesh && b_ob && CData))
+  if (!(hair && b_mesh && b_ob && CData))
     return false;
 
   Transform tfm = get_transform(b_ob->matrix_world());
@@ -129,7 +77,7 @@ static bool ObtainCacheParticleData(
 
       if ((b_part.render_type() == BL::ParticleSettings::render_type_PATH) &&
           (b_part.type() == BL::ParticleSettings::type_HAIR)) {
-        int shader = clamp(b_part.material() - 1, 0, geom->used_shaders.size() - 1);
+        int shader = clamp(b_part.material() - 1, 0, hair->used_shaders.size() - 1);
         int display_step = background ? b_part.render_step() : b_part.display_step();
         int totparts = b_psys.particles.length();
         int totchild = background ? b_psys.child_particles.length() :
@@ -203,14 +151,14 @@ static bool ObtainCacheParticleData(
   return true;
 }
 
-static bool ObtainCacheParticleUV(Geometry *geom,
+static bool ObtainCacheParticleUV(Hair *hair,
                                   BL::Mesh *b_mesh,
                                   BL::Object *b_ob,
                                   ParticleCurveData *CData,
                                   bool background,
                                   int uv_num)
 {
-  if (!(geom && b_mesh && b_ob && CData))
+  if (!(hair && b_mesh && b_ob && CData))
     return false;
 
   CData->curve_uv.clear();
@@ -266,14 +214,14 @@ static bool ObtainCacheParticleUV(Geometry *geom,
   return true;
 }
 
-static bool ObtainCacheParticleVcol(Geometry *geom,
+static bool ObtainCacheParticleVcol(Hair *hair,
                                     BL::Mesh *b_mesh,
                                     BL::Object *b_ob,
                                     ParticleCurveData *CData,
                                     bool background,
                                     int vcol_num)
 {
-  if (!(geom && b_mesh && b_ob && CData))
+  if (!(hair && b_mesh && b_ob && CData))
     return false;
 
   CData->curve_vcol.clear();
@@ -329,272 +277,6 @@ static bool ObtainCacheParticleVcol(Geometry *geom,
   return true;
 }
 
-static void ExportCurveTrianglePlanes(Mesh *mesh,
-                                      ParticleCurveData *CData,
-                                      float3 RotCam,
-                                      bool is_ortho)
-{
-  int vertexno = mesh->verts.size();
-  int vertexindex = vertexno;
-  int numverts = 0, numtris = 0;
-
-  /* compute and reserve size of arrays */
-  for (int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
-    for (int curve = CData->psys_firstcurve[sys];
-         curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys];
-         curve++) {
-      numverts += 2 + (CData->curve_keynum[curve] - 1) * 2;
-      numtris += (CData->curve_keynum[curve] - 1) * 2;
-    }
-  }
-
-  mesh->reserve_mesh(mesh->verts.size() + numverts, mesh->num_triangles() + numtris);
-
-  /* actually export */
-  for (int sys = 0; sys < CData->psys_firstcurve.size(); sys++) {
-    for (int curve = CData->psys_firstcurve[sys];
-         curve < CData->psys_firstcurve[sys] + CData->psys_curvenum[sys];
-         curve++) {
-      float3 xbasis;
-      float3 v1;
-      float time = 0.0f;
-      float3 ickey_loc = CData->curvekey_co[CData->curve_firstkey[curve]];
-      float radius = shaperadius(
-          CData->psys_shape[sys], CData->psys_rootradius[sys], CData->psys_tipradius[sys], 0.0f);
-      v1 = CData->curvekey_co[CData->curve_firstkey[curve] + 1] -
-           CData->curvekey_co[CData->curve_firstkey[curve]];
-      if (is_ortho)
-        xbasis = normalize(cross(RotCam, v1));
-      else
-        xbasis = normalize(cross(RotCam - ickey_loc, v1));
-      float3 ickey_loc_shfl = ickey_loc - radius * xbasis;
-      float3 ickey_loc_shfr = ickey_loc + radius * xbasis;
-      mesh->add_vertex(ickey_loc_shfl);
-      mesh->add_vertex(ickey_loc_shfr);
-      vertexindex += 2;
-
-      for (int curvekey = CData->curve_firstkey[curve] + 1;
-           curvekey < CData->curve_firstkey[curve] + CData->curve_keynum[curve];
-           curvekey++) {
-        ickey_loc = CData->curvekey_co[curvekey];
-
-        if 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list