diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-07-20 01:37:41 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-07-21 23:43:39 +0300 |
commit | 69afdf69702c8f1d4d43f7369a94bb36a4a349f2 (patch) | |
tree | 5f66807e13a31774a4a287250c45d8fc91b518e5 /source/blender/editors/sculpt_paint/sculpt_paint_color.c | |
parent | 4aa2a5481cec4edc4694ee1edbde4ed3f3986313 (diff) |
Sculpt: Support pen pressure modulation in Paint Brush properties
This allows to use pen pressure modulation in hardness, wet mix, wet
persistence, flow and density, as well as inverting the modulation (more
pressure, less density...). With this, it is possible to create brushes
that mix paint or apply a new color based on the pressure.
Reviewed By: sergey, campbellbarton
Differential Revision: https://developer.blender.org/D8267
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_paint_color.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_paint_color.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 608ba1b934e..f01a914fdd3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -164,7 +164,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, /* Density. */ float noise = 1.0f; - const float density = brush->density; + const float density = ss->cache->paint_brush.density; if (density < 1.0f) { const float hash_noise = BLI_hash_int_01(ss->cache->density_seed * 1000 * vd.index); if (hash_noise > density) { @@ -178,11 +178,12 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, float wet_mix_color[4]; float buffer_color[4]; - mul_v4_v4fl(paint_color, brush_color, fade * brush->flow); - mul_v4_v4fl(wet_mix_color, data->wet_mix_sampled_color, fade * brush->flow); + mul_v4_v4fl(paint_color, brush_color, fade * ss->cache->paint_brush.flow); + mul_v4_v4fl(wet_mix_color, data->wet_mix_sampled_color, fade * ss->cache->paint_brush.flow); /* Interpolate with the wet_mix color for wet paint mixing. */ - blend_color_interpolate_float(paint_color, paint_color, wet_mix_color, brush->wet_mix); + blend_color_interpolate_float( + paint_color, paint_color, wet_mix_color, ss->cache->paint_brush.wet_mix); blend_color_mix_float(color_buffer->color[vd.i], color_buffer->color[vd.i], paint_color); /* Final mix over the original color using brush alpha. */ @@ -305,7 +306,7 @@ void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode /* Wet paint color sampling. */ float wet_color[4] = {0.0f}; - if (brush->wet_mix > 0.0f) { + if (ss->cache->paint_brush.wet_mix > 0.0f) { SculptThreadedTaskData task_data = { .sd = sd, .ob = ob, @@ -332,8 +333,10 @@ void SCULPT_do_paint_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode if (ss->cache->first_time) { copy_v4_v4(ss->cache->wet_mix_prev_color, wet_color); } - blend_color_interpolate_float( - wet_color, wet_color, ss->cache->wet_mix_prev_color, brush->wet_persistence); + blend_color_interpolate_float(wet_color, + wet_color, + ss->cache->wet_mix_prev_color, + ss->cache->paint_brush.wet_persistence); copy_v4_v4(ss->cache->wet_mix_prev_color, wet_color); CLAMP4(ss->cache->wet_mix_prev_color, 0.0f, 1.0f); } |