[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60083] branches/soc-2013-paint: Sharpen tool:
Antony Riakiotakis
kalast at gmail.com
Thu Sep 12 22:33:02 CEST 2013
Revision: 60083
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60083
Author: psy-fi
Date: 2013-09-12 20:33:02 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Sharpen tool:
* Expose a toggle for sharpen/soften, in addition to ctrl-paint
* Make sharpening listen to mask strength.
* Use floats for byte image sharpening as well. Sharpen depends on
negative values to work so floats are necessary here for correct
subtraction.
Modified Paths:
--------------
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py 2013-09-12 19:51:31 UTC (rev 60082)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py 2013-09-12 20:33:02 UTC (rev 60083)
@@ -747,6 +747,8 @@
col.prop(brush, "secondary_color", text="")
col.operator("paint.brush_colors_flip", icon='FILE_REFRESH')
+ col.prop(brush, "blend", text="Blend")
+
col = layout.column()
col.template_ID(toolsettings, "palette", new="palette.new")
if toolsettings.palette:
@@ -763,12 +765,9 @@
row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='LOCKED')
else:
row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='UNLOCKED')
-
- self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
- self.prop_unified_strength(row, context, brush, "use_pressure_strength")
-
- col.prop(brush, "blend", text="Blend")
-
+ col.separator()
+ col.row().prop(brush, "direction", expand=True)
+
if brush.image_tool == 'CLONE':
col.separator()
col.prop(brush, "clone_image", text="Image")
@@ -780,8 +779,11 @@
col.prop(brush, "use_accumulate")
+ self.prop_unified_strength(row, context, brush, "strength", slider=True, text="Strength")
+ self.prop_unified_strength(row, context, brush, "use_pressure_strength")
+
class IMAGE_PT_tools_brush_texture(BrushButtonsPanel, Panel):
bl_label = "Texture"
bl_options = {'DEFAULT_CLOSED'}
Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-09-12 19:51:31 UTC (rev 60082)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2013-09-12 20:33:02 UTC (rev 60083)
@@ -754,7 +754,13 @@
col.prop(brush, "secondary_color", text="")
col.operator("paint.brush_colors_flip", icon='FILE_REFRESH')
+ col.prop(brush, "blend", text="Blend")
+
col = layout.column()
+ col.active = (brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'})
+ col.prop(brush, "use_alpha")
+
+ col = layout.column()
col.template_ID(settings, "palette", new="palette.new")
if settings.palette:
col.template_palette(settings, "palette", color=True)
@@ -772,19 +778,16 @@
else:
row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='UNLOCKED')
- self.prop_unified_strength(row, context, brush, "strength", text="Strength")
- self.prop_unified_strength(row, context, brush, "use_pressure_strength")
+ col.separator()
+ col.row().prop(brush, "direction", expand=True)
- col.prop(brush, "blend", text="Blend")
-
- col = layout.column()
- col.active = (brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'})
- col.prop(brush, "use_alpha")
-
# use_accumulate
if capabilities.has_accumulate:
col.separator()
col.prop(brush, "use_accumulate")
+
+ self.prop_unified_strength(row, context, brush, "strength", text="Strength")
+ self.prop_unified_strength(row, context, brush, "use_pressure_strength")
# Weight Paint Mode #
elif context.weight_paint_object and brush:
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-09-12 19:51:31 UTC (rev 60082)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-09-12 20:33:02 UTC (rev 60083)
@@ -3883,14 +3883,20 @@
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
if (ps->mode == BRUSH_STROKE_INVERT) {
+ float alpha;
+
/* subtract blurred image from normal image gives high pass filter */
- blend_color_sub_float(rgba, projPixel->pixel.f_pt, rgba);
+ sub_v3_v3v3(rgba, projPixel->pixel.f_pt, rgba);
+
/* now rgba_ub contains the edge result, but this should be converted to luminance to avoid
* colored speckles appearing in final image, and also to check for threshhold */
rgba[0] = rgba[1] = rgba[2] = rgb_to_grayscale(rgba);
- rgba[3] = mask;
+ alpha = projPixel->pixel.f_pt[3];
+ projPixel->pixel.f_pt[3] = rgba[3] = mask;
+
/* add to enhance edges */
blend_color_add_float(rgba, projPixel->pixel.f_pt, rgba);
+ projPixel->pixel.f_pt[3] = alpha;
} else {
blend_color_interpolate_float(rgba, rgba, projPixel->pixel.f_pt, mask);
}
@@ -3925,18 +3931,26 @@
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
- premul_float_to_straight_uchar(rgba_ub, rgba);
+ if (ps->mode == BRUSH_STROKE_INVERT) {
+ float rgba_pixel[4], alpha;
- if (ps->mode == BRUSH_STROKE_INVERT) {
+ straight_uchar_to_premul_float(rgba_pixel, projPixel->pixel.ch_pt);
+
/* subtract blurred image from normal image gives high pass filter */
- blend_color_sub_byte(rgba_ub, projPixel->pixel.ch_pt, rgba_ub);
+ sub_v3_v3v3(rgba, rgba_pixel, rgba);
/* now rgba_ub contains the edge result, but this should be converted to luminance to avoid
* colored speckles appearing in final image, and also to check for threshhold */
- rgba_ub[0] = rgba_ub[1] = rgba_ub[2] = rgb_to_grayscale_byte(rgba_ub);
- rgba_ub[3] = mask * 255;
+ rgba[0] = rgba[1] = rgba[2] = rgb_to_grayscale(rgba);
+ alpha = rgba_pixel[3];
+ rgba[3] = rgba_pixel[3] = mask;
+
/* add to enhance edges */
- blend_color_add_byte(rgba_ub, projPixel->pixel.ch_pt, rgba_ub);
+ blend_color_add_float(rgba, rgba_pixel, rgba);
+
+ rgba[3] = alpha;
+ premul_float_to_straight_uchar(rgba_ub, rgba);
} else {
+ premul_float_to_straight_uchar(rgba_ub, rgba);
blend_color_interpolate_byte(rgba_ub, rgba_ub, projPixel->pixel.ch_pt, mask);
}
BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
@@ -4488,6 +4502,10 @@
Brush *brush = ps->brush;
ps->tool = brush->imagepaint_tool;
ps->blend = brush->blend;
+ /* only check for inversion for the soften tool, elsewhere, a resident brush inversion flag can cause issues */
+ if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN)
+ ps->mode = ((ps->mode == BRUSH_STROKE_INVERT) ^ ((brush->flag & BRUSH_DIR_IN) != 0) ?
+ BRUSH_STROKE_INVERT : BRUSH_STROKE_NORMAL);
/* disable for 3d mapping also because painting on mirrored mesh can create "stripes" */
ps->do_masking = paint_use_opacity_masking(brush);
Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c 2013-09-12 19:51:31 UTC (rev 60082)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c 2013-09-12 20:33:02 UTC (rev 60083)
@@ -282,6 +282,7 @@
return ((br->flag & BRUSH_AIRBRUSH) ||
(br->flag & BRUSH_DRAG_DOT) ||
(br->flag & BRUSH_ANCHORED) ||
+ (br->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
(br->imagepaint_tool == PAINT_TOOL_SMEAR) ||
(br->mtex.tex && !ELEM3(br->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D))
) ? false : true;
@@ -425,13 +426,16 @@
brush->unprojected_radius = value;
}
-static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerRNA *ptr,
+static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr,
PropertyRNA *UNUSED(prop), int *UNUSED(free))
{
+ PaintMode mode = BKE_paintmode_get_active_from_context(C);
+
static EnumPropertyItem prop_default_items[] = {
{0, NULL, 0, NULL, NULL}
};
+ /* sculpt mode */
static EnumPropertyItem prop_flatten_contrast_items[] = {
{0, "FLATTEN", 0, "Flatten", "Add effect of brush"},
{BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"},
@@ -462,44 +466,70 @@
{0, NULL, 0, NULL, NULL}
};
+ /* texture paint mode */
+ static EnumPropertyItem prop_soften_sharpen_items[] = {
+ {0, "SOFTEN", 0, "Soften", "Blur effect of brush"},
+ {BRUSH_DIR_IN, "SHARPEN", 0, "Sharpen", "Sharpen effect of brush"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
Brush *me = (Brush *)(ptr->data);
- switch (me->sculpt_tool) {
- case SCULPT_TOOL_DRAW:
- case SCULPT_TOOL_CREASE:
- case SCULPT_TOOL_BLOB:
- case SCULPT_TOOL_LAYER:
- case SCULPT_TOOL_CLAY:
- case SCULPT_TOOL_CLAY_STRIPS:
- return prop_direction_items;
-
- case SCULPT_TOOL_MASK:
- switch ((BrushMaskTool)me->mask_tool) {
- case BRUSH_MASK_DRAW:
+ switch (mode) {
+ case PAINT_SCULPT:
+ switch (me->sculpt_tool) {
+ case SCULPT_TOOL_DRAW:
+ case SCULPT_TOOL_CREASE:
+ case SCULPT_TOOL_BLOB:
+ case SCULPT_TOOL_LAYER:
+ case SCULPT_TOOL_CLAY:
+ case SCULPT_TOOL_CLAY_STRIPS:
return prop_direction_items;
- break;
- case BRUSH_MASK_SMOOTH:
- return prop_default_items;
- break;
- }
- case SCULPT_TOOL_FLATTEN:
- return prop_flatten_contrast_items;
+ case SCULPT_TOOL_MASK:
+ switch ((BrushMaskTool)me->mask_tool) {
+ case BRUSH_MASK_DRAW:
+ return prop_direction_items;
+ break;
+ case BRUSH_MASK_SMOOTH:
+ return prop_default_items;
+ break;
+ }
- case SCULPT_TOOL_FILL:
- return prop_fill_deepen_items;
+ case SCULPT_TOOL_FLATTEN:
+ return prop_flatten_contrast_items;
- case SCULPT_TOOL_SCRAPE:
- return prop_scrape_peaks_items;
+ case SCULPT_TOOL_FILL:
+ return prop_fill_deepen_items;
- case SCULPT_TOOL_PINCH:
- return prop_pinch_magnify_items;
+ case SCULPT_TOOL_SCRAPE:
+ return prop_scrape_peaks_items;
- case SCULPT_TOOL_INFLATE:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list