diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-28 15:55:41 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-28 15:55:41 +0400 |
commit | fe6c45e36e4fae22bbddbf3e51c7d1fca03c3c1a (patch) | |
tree | 31233740f13c5d32fc9791234197a03bd60ad510 /source/blender/blenlib/intern/math_color.c | |
parent | 753fe9f0b970c83d253a79f4b12a13d3cc5f5fad (diff) |
Fix #34233: bad alpha blending for 3D texture painting. Same changes as the
previous fix for 2D image painting were done, and also:
* For brushes that do masking (keeping the max contribution to a pixel limited),
the alpha from textures is now part of the mask. In many cases the logic
worked out the same and where it didn't it used to cause artifacts.
* Color interpolation for smear and soften tools now happens in premultipied
space, to avoid bleeding of RGB colors from zero alpha areas.
* Fix a few cases where byte <=> float conversion was not doing the proper
straight <=> premul conversion.
* Replace some float division by constants with multiplications, is faster.
Note: float texture painting seems to have some issues updating the OpenGL
texture, but issue was already there before this commit.
Diffstat (limited to 'source/blender/blenlib/intern/math_color.c')
-rw-r--r-- | source/blender/blenlib/intern/math_color.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 3567421daad..cc892795a46 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -197,9 +197,9 @@ void hex_to_rgb(char *hexcol, float *r, float *g, float *b) if (hexcol[0] == '#') hexcol++; if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi) == 3) { - *r = ri / 255.0f; - *g = gi / 255.0f; - *b = bi / 255.0f; + *r = ri * (1.0f / 255.0f); + *g = gi * (1.0f / 255.0f); + *b = bi * (1.0f / 255.0f); CLAMP(*r, 0.0f, 1.0f); CLAMP(*g, 0.0f, 1.0f); CLAMP(*b, 0.0f, 1.0f); @@ -394,17 +394,17 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b) void rgb_uchar_to_float(float col_r[3], const unsigned char col_ub[3]) { - col_r[0] = ((float)col_ub[0]) / 255.0f; - col_r[1] = ((float)col_ub[1]) / 255.0f; - col_r[2] = ((float)col_ub[2]) / 255.0f; + col_r[0] = ((float)col_ub[0]) * (1.0f / 255.0f); + col_r[1] = ((float)col_ub[1]) * (1.0f / 255.0f); + col_r[2] = ((float)col_ub[2]) * (1.0f / 255.0f); } void rgba_uchar_to_float(float col_r[4], const unsigned char col_ub[4]) { - col_r[0] = ((float)col_ub[0]) / 255.0f; - col_r[1] = ((float)col_ub[1]) / 255.0f; - col_r[2] = ((float)col_ub[2]) / 255.0f; - col_r[3] = ((float)col_ub[3]) / 255.0f; + col_r[0] = ((float)col_ub[0]) * (1.0f / 255.0f); + col_r[1] = ((float)col_ub[1]) * (1.0f / 255.0f); + col_r[2] = ((float)col_ub[2]) * (1.0f / 255.0f); + col_r[3] = ((float)col_ub[3]) * (1.0f / 255.0f); } void rgb_float_to_uchar(unsigned char col_r[3], const float col_f[3]) |