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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 10:07:42 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-04-30 10:07:42 +0400
commit63f05576b840c597f91414fd2ca6db8ca869e3e9 (patch)
treee6d0bbd3dc57e67a0799a5fc066e72c8f630abc7 /source/blender/blenlib/intern/math_color_blend_inline.c
parentb735402c19782402e4a9970280cd3a3c8457296f (diff)
More image painting fixes:
* 2D image painting support for masking to limit the max contribution of a stroke to a pixel, to get it working compatible with projection painting. Not strictly a bugfix, but the inconsistency here was annoying. * Fix python errors in Texture Mask panel in image editor, was missing overlay options. * Clamp paint mask to 0..1 in case some texture exceeds it, this could give black pixels due to integer overflow.
Diffstat (limited to 'source/blender/blenlib/intern/math_color_blend_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_color_blend_inline.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 94a474da681..121750fe919 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -372,12 +372,17 @@ MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], co
{
if (src2[3] != 0.0f && src1[3] > 0.0f) {
/* subtract alpha and remap RGB channels to match */
- const float alpha = max_ff(src1[3] - src2[3], 0.0f);
- const float map_alpha = alpha / src1[3];
+ float alpha = max_ff(src1[3] - src2[3], 0.0f);
+ float map_alpha;
- dst[0] *= map_alpha;
- dst[1] *= map_alpha;
- dst[2] *= map_alpha;
+ if (alpha <= 0.0005f)
+ alpha = 0.0f;
+
+ map_alpha = alpha / src1[3];
+
+ dst[0] = src1[0] * map_alpha;
+ dst[1] = src1[1] * map_alpha;
+ dst[2] = src1[2] * map_alpha;
dst[3] = alpha;
}
else {
@@ -393,12 +398,17 @@ MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], cons
{
if (src2[3] != 0.0f && src1[3] < 1.0f) {
/* add alpha and remap RGB channels to match */
- const float alpha = min_ff(src1[3] + src2[3], 1.0f);
- const float map_alpha = (src1[3] > 0.0f) ? alpha / src1[3] : 1.0f;
+ float alpha = min_ff(src1[3] + src2[3], 1.0f);
+ float map_alpha;
+
+ if (alpha >= 1.0f - 0.0005f)
+ alpha = 1.0f;
+
+ map_alpha = (src1[3] > 0.0f) ? alpha / src1[3] : 1.0f;
- dst[0] *= map_alpha;
- dst[1] *= map_alpha;
- dst[2] *= map_alpha;
+ dst[0] = src1[0] * map_alpha;
+ dst[1] = src1[1] * map_alpha;
+ dst[2] = src1[2] * map_alpha;
dst[3] = alpha;
}
else {