[Bf-blender-cvs] [40e2f4469a7] master: Fix Mask Brush gradient artifacts

Pablo Dobarro noreply at git.blender.org
Mon Dec 9 16:52:43 CET 2019


Commit: 40e2f4469a76f7fab5501b877c929db181dbc6a4
Author: Pablo Dobarro
Date:   Mon Dec 2 03:49:03 2019 +0100
Branches: master
https://developer.blender.org/rB40e2f4469a76f7fab5501b877c929db181dbc6a4

Fix Mask Brush gradient artifacts

The old mask brush implementation was adding the brush value to the
previous vertex mask value and clamping the result. This leads to
visible artifacts in the mask gradient as the value approaches 0 or 1,
so it was not possible to paint a smooth mask with this brush.
Now we are also multiplying by the previous mask value before clamping,
fixing all those gradient artifacts.

Reviewed By: jbakker

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

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

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 9eb32a9f731..8be44066741 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2788,8 +2788,13 @@ static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata,
       const float fade = tex_strength(
           ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.index, tls->thread_id);
 
-      (*vd.mask) += fade * bstrength;
-      CLAMP(*vd.mask, 0, 1);
+      if (bstrength > 0.0f) {
+        (*vd.mask) += fade * bstrength * (1.0f - *vd.mask);
+      }
+      else {
+        (*vd.mask) += fade * bstrength * (*vd.mask);
+      }
+      CLAMP(*vd.mask, 0.0f, 1.0f);
 
       if (vd.mvert) {
         vd.mvert->flag |= ME_VERT_PBVH_UPDATE;



More information about the Bf-blender-cvs mailing list