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:
authorCampbell Barton <ideasman42@gmail.com>2012-08-14 19:38:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-14 19:38:10 +0400
commit58b5fb7bab9397955514ed5726ab0da9ab2a29bc (patch)
treeb33055ef2362c436d17ab45cea80d40a5dca6e52 /source/blender/editors
parent9591142294fdcaded15663002e1f7bac568d7ed6 (diff)
fix [#32299] 16bit float texture + 'Quick Edit' gives wrong result
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c50
1 files changed, 44 insertions, 6 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 05cc958aa43..76e4a75ea8b 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -3713,7 +3713,7 @@ static void blend_color_mix_float(float *cp, const float *cp1, const float *cp2,
cp[3] = mfac * cp1[3] + fac * cp2[3];
}
-static void blend_color_mix_accum(unsigned char *cp, const unsigned char *cp1, const unsigned char *cp2, const int fac)
+static void blend_color_mix_accum(unsigned char cp[4], const unsigned char cp1[4], const unsigned char cp2[4], const int fac)
{
/* this and other blending modes previously used >>8 instead of /255. both
* are not equivalent (>>8 is /256), and the former results in rounding
@@ -3726,6 +3726,17 @@ static void blend_color_mix_accum(unsigned char *cp, const unsigned char *cp1, c
cp[2] = (mfac * cp1[2] + fac * cp2[2]) / 255;
cp[3] = alpha > 255 ? 255 : alpha;
}
+static void blend_color_mix_accum_float(float cp[4], const float cp1[4], const unsigned char cp2[4], const float fac)
+{
+ const float mfac = 1.0f - fac;
+ const float alpha = cp1[3] + (fac * (cp2[3] / 255.0f));
+
+ cp[0] = (mfac * cp1[0] + (fac * (cp2[0] / 255.0f)));
+ cp[1] = (mfac * cp1[1] + (fac * (cp2[1] / 255.0f)));
+ cp[2] = (mfac * cp1[2] + (fac * (cp2[2] / 255.0f)));
+ cp[3] = alpha > 1.0f ? 1.0f : alpha;
+}
+
static void do_projectpaint_clone(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask)
{
@@ -3886,7 +3897,7 @@ static void *do_projectpaint_thread(void *ph_v)
/* printf("brush bounds %d %d %d %d\n", bucketMin[0], bucketMin[1], bucketMax[0], bucketMax[1]); */
- while (project_bucket_iter_next(ps, &bucket_index, &bucket_bounds, pos)) {
+ while (project_bucket_iter_next(ps, &bucket_index, &bucket_bounds, pos)) {
/* Check this bucket and its faces are initialized */
if (ps->bucketFlags[bucket_index] == PROJ_BUCKET_NULL) {
@@ -3901,11 +3912,36 @@ static void *do_projectpaint_thread(void *ph_v)
for (node = ps->bucketRect[bucket_index]; node; node = node->next) {
projPixel = (ProjPixel *)node->link;
- bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, projPixel->projCoSS[0], projPixel->projCoSS[1]);
- if (projPixel->newColor.ch[3]) {
- mask = ((float)projPixel->mask) / 65535.0f;
- blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask * projPixel->newColor.ch[3]));
+ /* copy of code below */
+ if (last_index != projPixel->image_index) {
+ last_index = projPixel->image_index;
+ last_projIma = projImages + last_index;
+ last_projIma->touch = 1;
+ is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
+ use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
+ }
+ /* end copy */
+
+ if (is_floatbuf) {
+ /* re-project buffer is assumed byte - TODO, allow float */
+ bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
+ projPixel->projCoSS[0], projPixel->projCoSS[1]);
+ if (projPixel->newColor.ch[3]) {
+ mask = ((float)projPixel->mask) / 65535.0f;
+ blend_color_mix_accum_float(projPixel->pixel.f_pt, projPixel->origColor.f,
+ projPixel->newColor.ch, (mask * (projPixel->newColor.ch[3] / 255.0f)));
+ }
+ }
+ else {
+ /* re-project buffer is assumed byte - TODO, allow float */
+ bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
+ projPixel->projCoSS[0], projPixel->projCoSS[1]);
+ if (projPixel->newColor.ch[3]) {
+ mask = ((float)projPixel->mask) / 65535.0f;
+ blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch,
+ projPixel->newColor.ch, (int)(mask * projPixel->newColor.ch[3]));
+ }
}
}
}
@@ -3959,6 +3995,7 @@ static void *do_projectpaint_thread(void *ph_v)
if (alpha > 0.0f) {
+ /* copy of code above */
if (last_index != projPixel->image_index) {
last_index = projPixel->image_index;
last_projIma = projImages + last_index;
@@ -3967,6 +4004,7 @@ static void *do_projectpaint_thread(void *ph_v)
is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0;
use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0;
}
+ /* end copy */
last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
last_partial_redraw_cell->x1 = MIN2(last_partial_redraw_cell->x1, projPixel->x_px);