diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2019-12-02 05:49:03 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2019-12-09 18:56:05 +0300 |
commit | 40e2f4469a76f7fab5501b877c929db181dbc6a4 (patch) | |
tree | 48abc8fff3f77e7f8aa5dd8db942a94adb5bc784 /source/blender/editors/sculpt_paint | |
parent | 312b6fd713f62e60d36b2bc724f6cf5817c39b6a (diff) |
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
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 9 |
1 files changed, 7 insertions, 2 deletions
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; |