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
This commit is contained in:
Pablo Dobarro
2019-12-02 03:49:03 +01:00
parent 312b6fd713
commit 40e2f4469a

View File

@@ -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;