[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56417] trunk/blender: More painting fixes :
Brecht Van Lommel
brechtvanlommel at pandora.be
Tue Apr 30 18:07:53 CEST 2013
Revision: 56417
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56417
Author: blendix
Date: 2013-04-30 16:07:52 +0000 (Tue, 30 Apr 2013)
Log Message:
-----------
More painting fixes:
* 2D image painting with textures that contained alpha did not work correctly,
had been broken for a while.
* 2D image panels texture (mask) panels showed wrong buttons for texture overlay.
* Texture map mode 3D now also uses masking, like Tiled and Stencil the texture
does not move along with the brush so it works fine.
* 2D image paint View mapping did not work correct, especially noticeable with
Rake rotation.
* Masking is now disabled for the smear tool, this can't really work because
the original image is constantly changing and gave artifacts.
Modified Paths:
--------------
trunk/blender/release/scripts/startup/bl_ui/space_image.py
trunk/blender/source/blender/blenkernel/BKE_brush.h
trunk/blender/source/blender/blenkernel/intern/brush.c
trunk/blender/source/blender/blenlib/BLI_math_color_blend.h
trunk/blender/source/blender/blenlib/intern/math_color_blend_inline.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
Modified: trunk/blender/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_image.py 2013-04-30 15:17:20 UTC (rev 56416)
+++ trunk/blender/release/scripts/startup/bl_ui/space_image.py 2013-04-30 16:07:52 UTC (rev 56417)
@@ -728,6 +728,7 @@
toolsettings = context.tool_settings.image_paint
brush = toolsettings.brush
+ tex_slot = brush.texture_slot
col = layout.column()
col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
@@ -740,13 +741,15 @@
col.label(text="Overlay:")
row = col.row()
- if brush.use_primary_overlay:
- row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
- else:
- row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
+ if tex_slot.map_mode != 'STENCIL':
+ if brush.use_primary_overlay:
+ row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
+ else:
+ row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
+
sub = row.row()
sub.prop(brush, "texture_overlay_alpha", text="Alpha")
- sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
+ sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
@@ -778,8 +781,8 @@
row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
sub = row.row()
- sub.prop(brush, "texture_overlay_alpha", text="Alpha")
- sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
+ sub.prop(brush, "mask_overlay_alpha", text="Alpha")
+ sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
class IMAGE_PT_tools_brush_tool(BrushButtonsPanel, Panel):
Modified: trunk/blender/source/blender/blenkernel/BKE_brush.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-04-30 15:17:20 UTC (rev 56416)
+++ trunk/blender/source/blender/blenkernel/BKE_brush.h 2013-04-30 16:07:52 UTC (rev 56417)
@@ -80,8 +80,10 @@
float rgba[4], const int thread, struct ImagePool *pool);
float BKE_brush_sample_masktex(const Scene *scene, struct Brush *br, const float point[3],
const int thread, struct ImagePool *pool);
-void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, short flt,
- short texfalloff, int size, struct ImBuf **imbuf,
+
+enum BrushImBufFill { BRUSH_IMBUF_MASK, BRUSH_IMBUF_TEX, BRUSH_IMBUF_TEX_MASK };
+void BKE_brush_imbuf_new(const struct Scene *scene, struct Brush *brush, bool use_float,
+ enum BrushImBufFill fill, int size, struct ImBuf **imbuf,
bool use_color_correction, bool use_brush_alpha,
struct ImagePool *pool, struct rctf *mapping);
Modified: trunk/blender/source/blender/blenkernel/intern/brush.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/brush.c 2013-04-30 15:17:20 UTC (rev 56416)
+++ trunk/blender/source/blender/blenkernel/intern/brush.c 2013-04-30 16:07:52 UTC (rev 56417)
@@ -765,9 +765,10 @@
texco[2] = 0.0f;
}
-/* TODO, use define for 'texfall' arg
- * NOTE: only used for 2d brushes currently! */
-void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texfall, int bufsize,
+/* NOTE: only used for 2d brushes currently! and needs to stay in sync
+ * with brush_painter_2d_do_partial */
+void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, bool use_float,
+ enum BrushImBufFill fill, int bufsize,
ImBuf **outbuf, bool use_color_correction, bool use_brush_alpha,
struct ImagePool *pool, rctf *mapping)
{
@@ -780,7 +781,7 @@
float brush_rgb[3] = {1.0f, 1.0f, 1.0f};
int thread = 0;
- imbflag = (flt) ? IB_rectfloat : IB_rect;
+ imbflag = (use_float) ? IB_rectfloat : IB_rect;
xoff = -bufsize / 2.0f + 0.5f;
yoff = -bufsize / 2.0f + 0.5f;
rowbytes = bufsize * 4;
@@ -790,7 +791,7 @@
else
ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag);
- if (flt) {
+ if (use_float) {
if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
copy_v3_v3(brush_rgb, brush->rgb);
if (use_color_correction) {
@@ -805,27 +806,21 @@
xy[0] = x + xoff;
xy[1] = y + yoff;
- if (texfall == 0) {
+ if (fill == BRUSH_IMBUF_MASK) {
copy_v3_v3(dstf, brush_rgb);
dstf[3] = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
- else if (texfall == 1) {
+ else if (fill == BRUSH_IMBUF_TEX) {
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, dstf, thread, pool);
}
- else if (texfall == 2) {
+ else { /* if (fill == BRUSH_IMBUF_TEX_MASK) */
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
mul_v3_v3v3(dstf, rgba, brush_rgb);
dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
}
- else {
- brush_imbuf_tex_co(mapping, x, y, texco);
- BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
- copy_v3_v3(dstf, brush_rgb);
- dstf[3] = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
- }
/* output premultiplied alpha image */
dstf[0] *= dstf[3];
@@ -838,10 +833,10 @@
float alpha_f; /* final float alpha to convert to char */
if (brush->imagepaint_tool == PAINT_TOOL_DRAW)
- rgb_float_to_uchar(crgb, brush->rgb);
- else
- rgb_float_to_uchar(crgb, brush_rgb);
+ copy_v3_v3(brush_rgb, brush->rgb);
+ rgb_float_to_uchar(crgb, brush->rgb);
+
for (y = 0; y < ibuf->y; y++) {
dst = (unsigned char *)ibuf->rect + y * rowbytes;
@@ -849,7 +844,7 @@
xy[0] = x + xoff;
xy[1] = y + yoff;
- if (texfall == 0) {
+ if (fill == BRUSH_IMBUF_MASK) {
alpha_f = alpha * BKE_brush_curve_strength(brush, len_v2(xy), radius);
dst[0] = crgb[0];
@@ -857,31 +852,21 @@
dst[2] = crgb[2];
dst[3] = FTOCHAR(alpha_f);
}
- else if (texfall == 1) {
+ else if (fill == BRUSH_IMBUF_TEX) {
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
rgba_float_to_uchar(dst, rgba);
}
- else if (texfall == 2) {
+ else { /* if (fill == BRUSH_IMBUF_TEX_MASK) */
brush_imbuf_tex_co(mapping, x, y, texco);
BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
- mul_v3_v3(rgba, brush->rgb);
+
+ mul_v3_v3(rgba, brush_rgb);
alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
rgb_float_to_uchar(dst, rgba);
-
dst[3] = FTOCHAR(alpha_f);
}
- else {
- brush_imbuf_tex_co(mapping, x, y, texco);
- BKE_brush_sample_tex_3D(scene, brush, texco, rgba, thread, pool);
- alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius);
-
- dst[0] = crgb[0];
- dst[1] = crgb[1];
- dst[2] = crgb[2];
- dst[3] = FTOCHAR(alpha_f);
- }
}
}
}
Modified: trunk/blender/source/blender/blenlib/BLI_math_color_blend.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_color_blend.h 2013-04-30 15:17:20 UTC (rev 56416)
+++ trunk/blender/source/blender/blenlib/BLI_math_color_blend.h 2013-04-30 16:07:52 UTC (rev 56417)
@@ -49,6 +49,7 @@
MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4]);
MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4]);
MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4]);
+MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float t);
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4]);
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4]);
@@ -58,6 +59,7 @@
MINLINE void blend_color_darken_float(float dst[4], const float src1[4], const float src2[4]);
MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4]);
MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], const float src2[4]);
+MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t);
#if BLI_MATH_DO_INLINE
#include "intern/math_color_blend_inline.c"
Modified: trunk/blender/source/blender/blenlib/intern/math_color_blend_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color_blend_inline.c 2013-04-30 15:17:20 UTC (rev 56416)
+++ trunk/blender/source/blender/blenlib/intern/math_color_blend_inline.c 2013-04-30 16:07:52 UTC (rev 56417)
@@ -242,6 +242,28 @@
}
}
+MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float ft)
+{
+ /* do color interpolation, but in premultiplied space so that RGB colors
+ * from zero alpha regions have no influence */
+ const int t = (int)(255 * ft);
+ const int mt = 255 - t;
+ int tmp = (mt * src1[3] + t * src2[3]);
+
+ if (tmp > 0) {
+ dst[0] = divide_round_i(mt * src1[0] * src1[3] + t * src2[0] * src2[3], tmp);
+ dst[1] = divide_round_i(mt * src1[1] * src1[3] + t * src2[1] * src2[3], tmp);
+ dst[2] = divide_round_i(mt * src1[2] * src1[3] + t * src2[2] * src2[3], tmp);
+ dst[3] = divide_round_i(tmp, 255);
+ }
+ else {
+ dst[0] = src1[0];
+ dst[1] = src1[1];
+ dst[2] = src1[2];
+ dst[3] = src1[3];
+ }
+}
+
/* premultiplied alpha float blending modes */
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list