Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-07-20 01:37:41 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-07-21 23:43:39 +0300
commit69afdf69702c8f1d4d43f7369a94bb36a4a349f2 (patch)
tree5f66807e13a31774a4a287250c45d8fc91b518e5 /source/blender/editors/sculpt_paint/sculpt.c
parent4aa2a5481cec4edc4694ee1edbde4ed3f3986313 (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.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 02b736c00c2..e679c62fdaa 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2418,7 +2418,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss,
/* Hardness. */
float final_len = len;
- const float hardness = br->hardness;
+ const float hardness = cache->paint_brush.hardness;
float p = len / cache->radius;
if (p < hardness) {
final_len = 0.0f;
@@ -6618,6 +6618,50 @@ static void sculpt_update_brush_delta(UnifiedPaintSettings *ups, Object *ob, Bru
}
}
+static void sculpt_update_cache_paint_variants(StrokeCache *cache, const Brush *brush)
+{
+ cache->paint_brush.hardness = brush->hardness;
+ if (brush->paint_flags & BRUSH_PAINT_HARDNESS_PRESSURE) {
+ cache->paint_brush.hardness *= brush->paint_flags & BRUSH_PAINT_HARDNESS_PRESSURE_INVERT ?
+ 1.0f - cache->pressure :
+ cache->pressure;
+ }
+
+ cache->paint_brush.flow = brush->flow;
+ if (brush->paint_flags & BRUSH_PAINT_FLOW_PRESSURE) {
+ cache->paint_brush.flow *= brush->paint_flags & BRUSH_PAINT_FLOW_PRESSURE_INVERT ?
+ 1.0f - cache->pressure :
+ cache->pressure;
+ }
+
+ cache->paint_brush.wet_mix = brush->wet_mix;
+ if (brush->paint_flags & BRUSH_PAINT_WET_MIX_PRESSURE) {
+ cache->paint_brush.wet_mix *= brush->paint_flags & BRUSH_PAINT_WET_MIX_PRESSURE_INVERT ?
+ 1.0f - cache->pressure :
+ cache->pressure;
+
+ /* This makes wet mix more sensible in higher values, which allows to create brushes that have
+ * a wider pressure range were they only blend colors without applying too much of the brush
+ * color. */
+ cache->paint_brush.wet_mix = 1.0f - pow2f(1.0f - cache->paint_brush.wet_mix);
+ }
+
+ cache->paint_brush.wet_persistence = brush->wet_persistence;
+ if (brush->paint_flags & BRUSH_PAINT_WET_PERSISTENCE_PRESSURE) {
+ cache->paint_brush.wet_persistence = brush->paint_flags &
+ BRUSH_PAINT_WET_PERSISTENCE_PRESSURE_INVERT ?
+ 1.0f - cache->pressure :
+ cache->pressure;
+ }
+
+ cache->paint_brush.density = brush->density;
+ if (brush->paint_flags & BRUSH_PAINT_DENSITY_PRESSURE) {
+ cache->paint_brush.density = brush->paint_flags & BRUSH_PAINT_DENSITY_PRESSURE_INVERT ?
+ 1.0f - cache->pressure :
+ cache->pressure;
+ }
+}
+
/* Initialize the stroke cache variants from operator properties. */
static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, PointerRNA *ptr)
{
@@ -6684,6 +6728,8 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
cache->dyntopo_pixel_radius = ups->initial_pixel_radius;
}
+ sculpt_update_cache_paint_variants(cache, brush);
+
cache->radius_squared = cache->radius * cache->radius;
if (brush->flag & BRUSH_ANCHORED) {