[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60086] branches/soc-2013-paint: Add threshold to control the sharpening.

Antony Riakiotakis kalast at gmail.com
Thu Sep 12 23:04:03 CEST 2013


Revision: 60086
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60086
Author:   psy-fi
Date:     2013-09-12 21:04:02 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Add threshold to control the sharpening. If color difference is not as
big as threshold, the pixel is not sharpened.

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/makesdna/DNA_brush_types.h
    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 21:01:27 UTC (rev 60085)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py	2013-09-12 21:04:02 UTC (rev 60086)
@@ -765,8 +765,11 @@
                     row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='LOCKED')
                 else:
                     row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='UNLOCKED')
-            col.separator()
-            col.row().prop(brush, "direction", expand=True)
+
+            if brush.image_tool == 'SOFTEN':
+                col.separator()
+                col.row().prop(brush, "direction", expand=True)
+                col.row().prop(brush, "sharp_threshold")
             
             if brush.image_tool == 'CLONE':
                 col.separator()

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 21:01:27 UTC (rev 60085)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-09-12 21:04:02 UTC (rev 60086)
@@ -778,8 +778,10 @@
                 else:
                     row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='UNLOCKED')
 
-            col.separator()
-            col.row().prop(brush, "direction", expand=True)
+            if brush.image_tool == 'SOFTEN':
+                col.separator()
+                col.row().prop(brush, "direction", expand=True)
+                col.row().prop(brush, "sharp_threshold")
 
             # use_accumulate
             if capabilities.has_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 21:01:27 UTC (rev 60085)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-12 21:04:02 UTC (rev 60086)
@@ -3883,20 +3883,22 @@
 		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 */
 			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);
-			alpha = projPixel->pixel.f_pt[3];
-			projPixel->pixel.f_pt[3] = rgba[3] = mask;
+			if (fabs(rgba[0]) > ps->brush->sharp_threshold) {
+				float 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;
+				/* add to enhance edges */
+				blend_color_add_float(rgba, projPixel->pixel.f_pt, rgba);
+				projPixel->pixel.f_pt[3] = alpha;
+			}
+			else
+				return;
 		} else {
 			blend_color_interpolate_float(rgba, rgba, projPixel->pixel.f_pt, mask);
 		}
@@ -3932,7 +3934,7 @@
 		mul_v4_fl(rgba, 1.0f / (float)accum_tot);
 
 		if (ps->mode == BRUSH_STROKE_INVERT) {
-			float rgba_pixel[4], alpha;
+			float rgba_pixel[4];
 
 			straight_uchar_to_premul_float(rgba_pixel, projPixel->pixel.ch_pt);
 
@@ -3941,16 +3943,21 @@
 			/* 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);
-			alpha = rgba_pixel[3];
-			rgba[3] = rgba_pixel[3] = mask;
+			if (fabs(rgba[0]) > ps->brush->sharp_threshold) {
+				float alpha = rgba_pixel[3];
+				rgba[3] = rgba_pixel[3] = mask;
 
-			/* add to enhance edges */
-			blend_color_add_float(rgba, rgba_pixel, rgba);
+				/* add to enhance edges */
+				blend_color_add_float(rgba, rgba_pixel, rgba);
 
-			rgba[3] = alpha;
+				rgba[3] = alpha;
+				premul_float_to_straight_uchar(rgba_ub, rgba);
+			}
+			else
+				return;
+		}
+		else {
 			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);

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-09-12 21:01:27 UTC (rev 60085)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h	2013-09-12 21:04:02 UTC (rev 60086)
@@ -115,6 +115,9 @@
 
 	float unprojected_radius;
 
+	float sharp_threshold;
+	int pad;
+
 	float add_col[3];
 	float sub_col[3];
 

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 21:01:27 UTC (rev 60085)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c	2013-09-12 21:04:02 UTC (rev 60086)
@@ -1031,6 +1031,13 @@
 	RNA_def_property_ui_text(prop, "Mask Stencil Dimensions", "Dimensions of mask stencil in viewport");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+	prop = RNA_def_property(srna, "sharp_threshold", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_range(prop, 0.0, 100.0);
+	RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 3);
+	RNA_def_property_float_sdna(prop, NULL, "sharp_threshold");
+	RNA_def_property_ui_text(prop, "Sharp Threshold", "Threshold below which, no sharpening is done");
+	RNA_def_property_update(prop, 0, "rna_Brush_update");
+
 	/* flag */
 	prop = RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH);




More information about the Bf-blender-cvs mailing list