[Bf-blender-cvs] [560a73610b7] master: Fix artifact in Clay Strips when producing large deformations

Pablo Dobarro noreply at git.blender.org
Wed Jun 24 17:30:21 CEST 2020


Commit: 560a73610b76a08384d7396f3e864f82ece558a2
Author: Pablo Dobarro
Date:   Mon Jun 22 01:01:42 2020 +0200
Branches: master
https://developer.blender.org/rB560a73610b76a08384d7396f3e864f82ece558a2

Fix artifact in Clay Strips when producing large deformations

The clay strips brush tip tests distances against a cube with beveled Z
aligned edges. This cube was positioned with its center in the surface
of the mesh, so when producing large deformation, some vertices that
should be deformed were positioned further than the cube's Z dimension,
so they were left behind, producing artifacts.
This displaces and deforms the local space to position the brush tip
cube (now a prism) towards the deformation direction, so more vertices
can be included, removing most of these artifacts.

Reviewed By: sergey

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

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index ffbaf1f1037..25b01a20981 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4706,6 +4706,17 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
   mul_v3_fl(temp, displace);
   add_v3_v3(area_co, temp);
 
+  /* Clay Strips uses a cube test with falloff in the XY axis (not in Z) and a plane to deform the
+   * vertices. When in Add mode, vertices that are below the plane and inside the cube are move
+   * towards the plane. In this situation, there may be cases where a vertex is outside the cube
+   * but below the plane, so won't be deformed, causing artifacts. In order to prevent these
+   * artifacts, this displaces the test cube space in relation to the plane in order to
+   * deform more vertices that may be below it. */
+  /* The 0.7 and 1.25 factors are arbitrary and don't have any relation between them, they were set
+   * by doing multiple tests using the defaul Clay Strips brush preset. */
+  float area_co_displaced[3];
+  madd_v3_v3v3fl(area_co_displaced, area_co, area_no, -radius * 0.7f);
+
   /* Init brush local space matrix. */
   cross_v3_v3v3(mat[0], area_no, ss->cache->grab_delta_symmetry);
   mat[0][3] = 0.0f;
@@ -4713,13 +4724,19 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
   mat[1][3] = 0.0f;
   copy_v3_v3(mat[2], area_no);
   mat[2][3] = 0.0f;
-  copy_v3_v3(mat[3], ss->cache->location);
+  copy_v3_v3(mat[3], area_co_displaced);
   mat[3][3] = 1.0f;
   normalize_m4(mat);
 
   /* Scale brush local space matrix. */
   scale_m4_fl(scale, ss->cache->radius);
   mul_m4_m4m4(tmat, mat, scale);
+
+  /* Deform the local space in Z to scale the test cube. As the test cube does not have falloff in
+   * Z this does not produce artifacts in the falloff cube and allows to deform extra vertices
+   * during big deformation while keeping the surface as uniform as possible. */
+  mul_v3_fl(tmat[2], 1.25f);
+
   invert_m4_m4(mat, tmat);
 
   SculptThreadedTaskData data = {



More information about the Bf-blender-cvs mailing list