Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2013-05-24 01:02:51 +0400
committerAntony Riakiotakis <kalast@gmail.com>2013-05-24 01:02:51 +0400
commit326c90d41a9ce2cd7f801ad5124ba812d8e9c24e (patch)
tree0d70b4d579e40b6121fea6c9723a5801a550e6d1 /source/blender/editors/sculpt_paint
parentcbc431ec1277c300fa43e133c188c65df9b6247a (diff)
Fix #35426, masking works wrong in projection painting. When we don't
use tiling, we need to sample the mask texture when determining the pixel masking.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index dff033b3613..9189202c3c7 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -248,7 +248,8 @@ typedef struct ProjPaintState {
short is_ortho;
bool do_masking; /* use masking during painting. Some operations such as airbrush may disable */
bool is_texbrush; /* only to avoid running */
- bool is_maskbrush;
+ bool is_maskbrush; /* mask brush is applied before masking */
+ bool is_maskbrush_tiled; /* mask brush is applied after masking */
#ifndef PROJ_DEBUG_NOSEAMBLEED
float seam_bleed_px;
#endif
@@ -3841,7 +3842,14 @@ static void *do_projectpaint_thread(void *ph_v)
* and never exceeds it, which gives nice smooth results. */
float mask_accum = projPixel->mask_accum;
- mask = mask_accum + (brush_alpha * 65535.0f - mask_accum) * mask;
+ if (ps->is_maskbrush) {
+ float texmask = BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
+ CLAMP(texmask, 0.0, 1.0);
+ mask = mask_accum + (brush_alpha * texmask * 65535.0f - mask_accum) * mask;
+ }
+ else {
+ mask = mask_accum + (brush_alpha * 65535.0f - mask_accum) * mask;
+ }
mask_short = (unsigned short)mask;
if (mask_short > projPixel->mask_accum) {
@@ -3853,8 +3861,9 @@ static void *do_projectpaint_thread(void *ph_v)
continue;
}
}
- else
+ else {
mask *= brush_alpha;
+ }
if (ps->is_texbrush) {
MTex *mtex = &brush->mtex;
@@ -3877,7 +3886,7 @@ static void *do_projectpaint_thread(void *ph_v)
mask *= texrgba[3];
}
- if (ps->is_maskbrush) {
+ if (ps->is_maskbrush_tiled) {
mask *= BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
}
@@ -4099,13 +4108,23 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int
(brush->mtex.tex && !ELEM3(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)))
? false : true;
ps->is_texbrush = (brush->mtex.tex && brush->imagepaint_tool == PAINT_TOOL_DRAW) ? true : false;
- ps->is_maskbrush = (brush->mask_mtex.tex) ? true : false;
+ ps->is_maskbrush = false;
+ ps->is_maskbrush_tiled = false;
+ if (brush->mask_mtex.tex) {
+ if (ELEM(brush->mask_mtex.brush_map_mode, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_TILED)) {
+ ps->is_maskbrush_tiled = true;
+ }
+ else {
+ ps->is_maskbrush = true;
+ }
+ }
}
else {
/* brush may be NULL*/
ps->do_masking = false;
ps->is_texbrush = false;
ps->is_maskbrush = false;
+ ps->is_maskbrush_tiled = false;
}
/* sizeof(ProjPixel), since we alloc this a _lot_ */
@@ -4290,6 +4309,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op)
/* override */
ps.is_texbrush = false;
ps.is_maskbrush = false;
+ ps.is_maskbrush_tiled = false;
ps.do_masking = false;
orig_brush_size = BKE_brush_size_get(scene, ps.brush);
BKE_brush_size_set(scene, ps.brush, 32); /* cover the whole image */