[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60080] branches/soc-2013-paint/source/ blender/editors/sculpt_paint: Add first working code for sharpen tool in projective texturing.
Antony Riakiotakis
kalast at gmail.com
Thu Sep 12 21:10:24 CEST 2013
Revision: 60080
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60080
Author: psy-fi
Date: 2013-09-12 19:10:23 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Add first working code for sharpen tool in projective texturing.
To use, select the Soften tool and press Ctrl while painting.
Notes:
* Disabled masking for the soften tool, it did some weird effects, such
as brush curve having weird effects (full curve would not work, for
instance).
* Unsharp masking requires a better filter to address changes in color
in the diagonal direction. Currently it shares the filter used by the
soften brush, which is similar to a simple cross filter.
* Threshhold will be added as well, will only add shariness if edge
detection value exceeds it. Will keep other parts of the image nice and
clean.
Modified Paths:
--------------
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c 2013-09-12 16:16:08 UTC (rev 60079)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c 2013-09-12 19:10:23 UTC (rev 60080)
@@ -561,6 +561,7 @@
(brush->flag & BRUSH_DRAG_DOT) ||
(brush->flag & BRUSH_ANCHORED) ||
(brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
+ (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
(brush->flag & BRUSH_USE_GRADIENT) ||
(brush->mtex.tex && !ELEM3(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ||
brush->flag & BRUSH_ACCUMULATE) ?
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 16:16:08 UTC (rev 60079)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-09-12 19:10:23 UTC (rev 60080)
@@ -3858,15 +3858,6 @@
BLI_linklist_prepend_arena(smearPixels_f, (void *)projPixel, smearArena);
}
-/* do_projectpaint_soften for float & byte
- */
-static float inv_pow2(float f)
-{
- f = 1.0f - f;
- f = f * f;
- return 1.0f - f;
-}
-
static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float mask,
MemArena *softenArena, LinkNode **softenPixels)
{
@@ -3875,9 +3866,6 @@
float *rgba = projPixel->newColor.f;
- /* sigh, mask values tend to need to be a _lot_ stronger with blur */
- mask = inv_pow2(mask);
-
/* rather then painting, accumulate surrounding colors */
zero_v4(rgba);
@@ -3893,7 +3881,20 @@
if (LIKELY(accum_tot != 0)) {
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
- blend_color_interpolate_float(rgba, rgba, projPixel->pixel.f_pt, mask);
+
+ if (ps->mode == BRUSH_STROKE_INVERT) {
+ /* subtract blurred image from normal image gives high pass filter */
+ blend_color_sub_float(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;
+ /* add to enhance edges */
+ blend_color_add_float(rgba, projPixel->pixel.f_pt, rgba);
+ } else {
+ blend_color_interpolate_float(rgba, rgba, projPixel->pixel.f_pt, mask);
+ }
+
BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
}
}
@@ -3906,9 +3907,6 @@
float rgba[4]; /* convert to byte after */
- /* sigh, mask values tend to need to be a _lot_ stronger with blur */
- mask = inv_pow2(mask);
-
/* rather then painting, accumulate surrounding colors */
zero_v4(rgba);
@@ -3926,9 +3924,21 @@
unsigned char *rgba_ub = projPixel->newColor.ch;
mul_v4_fl(rgba, 1.0f / (float)accum_tot);
+
premul_float_to_straight_uchar(rgba_ub, rgba);
- blend_color_interpolate_byte(rgba_ub, rgba_ub, projPixel->pixel.ch_pt, mask);
+ if (ps->mode == BRUSH_STROKE_INVERT) {
+ /* subtract blurred image from normal image gives high pass filter */
+ blend_color_sub_byte(rgba_ub, projPixel->pixel.ch_pt, rgba_ub);
+ /* 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;
+ /* add to enhance edges */
+ blend_color_add_byte(rgba_ub, projPixel->pixel.ch_pt, rgba_ub);
+ } else {
+ blend_color_interpolate_byte(rgba_ub, rgba_ub, projPixel->pixel.ch_pt, mask);
+ }
BLI_linklist_prepend_arena(softenPixels, (void *)projPixel, softenArena);
}
}
More information about the Bf-blender-cvs
mailing list