Sculpt: Wet paint area radius

This adds a new property to the sculpt vertex color paint brush to limit
the area of the brush that is going to be used to sample the wet paint
color. This is exactly the same concept as normal radius and area radius
that exist for sculpting brushes for sampling the surface depth and
orientation.

When working near color hard edges, this allows to prevent the color
from the other side of the edge to blend into the wet paint.

With 1.0 (the previous default) wet paint radius, as soon as the brush touches
one vertex of the other color, the wet paint mix color changes, making it
impossible to maintain the border between the two colors.

Reviewed By: sergey, dbystedt, JulienKaspar

Differential Revision: https://developer.blender.org/D9587
This commit is contained in:
Pablo Dobarro 2020-11-17 22:33:09 +01:00
parent 9234a6a619
commit cc6ec71b19
Notes: blender-bot 2023-02-14 07:39:44 +01:00
Referenced by issue #83342, Display RGB channels shows alpha premultiplied color with 8-bit images
7 changed files with 27 additions and 1 deletions

View File

@ -716,6 +716,9 @@ def brush_settings(layout, context, brush, popover=False):
row.prop(brush, "invert_wet_persistence_pressure", text="")
row.prop(brush, "use_wet_persistence_pressure", text="")
row = layout.row(align=True)
row.prop(brush, "wet_paint_radius_factor")
row = layout.row(align=True)
row.prop(brush, "density")
row.prop(brush, "invert_density_pressure", text="")

View File

@ -446,6 +446,7 @@ static void brush_defaults(Brush *brush)
FROM_DEFAULT(topology_rake_factor);
FROM_DEFAULT(crease_pinch_factor);
FROM_DEFAULT(normal_radius_factor);
FROM_DEFAULT(wet_paint_radius_factor);
FROM_DEFAULT(area_radius_factor);
FROM_DEFAULT(disconnected_distance_max);
FROM_DEFAULT(sculpt_plane);

View File

@ -483,6 +483,13 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports))
}
}
}
/* Wet Paint Radius Factor */
for (Brush *br = bmain->brushes.first; br; br = br->id.next) {
if (br->ob_mode & OB_MODE_SCULPT && br->wet_paint_radius_factor == 0.0f) {
br->wet_paint_radius_factor = 1.0f;
}
}
}
static void panels_remove_x_closed_flag_recursive(Panel *panel)

View File

@ -220,6 +220,9 @@ static void do_sample_wet_paint_task_cb(void *__restrict userdata,
SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
ss, &test, data->brush->falloff_shape);
test.radius *= data->brush->wet_paint_radius_factor;
test.radius_squared = test.radius * test.radius;
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (sculpt_brush_test_sq_fn(&test, vd.co)) {

View File

@ -45,6 +45,7 @@
.topology_rake_factor = 0.0f, \
.crease_pinch_factor = 0.5f, \
.normal_radius_factor = 0.5f, \
.wet_paint_radius_factor = 0.5f, \
.area_radius_factor = 0.5f, \
.disconnected_distance_max = 0.1f, \
.sculpt_plane = SCULPT_DISP_DIR_AREA, \

View File

@ -573,7 +573,7 @@ typedef struct Brush {
char gpencil_sculpt_tool;
/** Active grease pencil weight tool. */
char gpencil_weight_tool;
char _pad1[6];
char _pad1[2];
float autosmooth_factor;
@ -585,6 +585,7 @@ typedef struct Brush {
float normal_radius_factor;
float area_radius_factor;
float wet_paint_radius_factor;
float plane_trim;
/** Affectable height of brush (layer height for layer tool, i.e.). */

View File

@ -2854,6 +2854,16 @@ static void rna_def_brush(BlenderRNA *brna)
"used to sample the area center");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "wet_paint_radius_factor", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "wet_paint_radius_factor");
RNA_def_property_range(prop, 0.0f, 2.0f);
RNA_def_property_ui_range(prop, 0.0f, 2.0f, 0.001, 3);
RNA_def_property_ui_text(prop,
"Wet Paint Radius",
"Ratio between the brush radius and the radius that is going to be "
"used to sample the color to blend in wet paint");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "stencil_pos", PROP_FLOAT, PROP_XYZ);
RNA_def_property_float_sdna(prop, NULL, "stencil_pos");
RNA_def_property_array(prop, 2);