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@gmail.com>2017-11-29 04:13:37 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2017-11-29 20:01:36 +0300
commit4f7280da404c5054da4061335fee1dac24d9c812 (patch)
treeee7ab8d81cb993b367dd61f9512e5e764cfb72d7 /source/blender/blenlib/intern/math_color_blend_inline.c
parent5b5939c6e6494583a0c99f6dccb8ca8c617d204b (diff)
Fix paint float color blending bugs with alpha 1.0 and vivid light.
For some blend modes there would be no effect with factor 1.0, even if factor 0.999 would give a very different image. Now the result should have no discontinuity. Differential Revision: https://developer.blender.org/D2925
Diffstat (limited to 'source/blender/blenlib/intern/math_color_blend_inline.c')
-rw-r--r--source/blender/blenlib/intern/math_color_blend_inline.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index dc3874f83a2..1af2a0cd6a2 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -439,10 +439,10 @@ MINLINE void blend_color_vividlight_byte(unsigned char dst[4], unsigned const ch
int temp;
if (src2[i] == 255) {
- temp = 255;
+ temp = (src1[i] == 0) ? 127 : 255;
}
else if (src2[i] == 0) {
- temp = 0;
+ temp = (src1[i] == 255) ? 127 : 0;
}
else if (src2[i] > 127) {
temp = min_ii(((src1[i]) * 255) / (2 * (255 - src2[i])), 255);
@@ -784,7 +784,7 @@ MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], cons
MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -810,7 +810,7 @@ MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const
MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -835,7 +835,7 @@ MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], cons
MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -853,7 +853,7 @@ MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const flo
MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -872,7 +872,7 @@ MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], con
MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -890,7 +890,7 @@ MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const fl
MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -908,7 +908,7 @@ MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const f
MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -933,7 +933,7 @@ MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], cons
MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -959,7 +959,7 @@ MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const
MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -985,7 +985,7 @@ MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], co
MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -993,10 +993,10 @@ MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], con
float temp;
if (src2[i] == 1.0f) {
- temp = 1.0f;
+ temp = (src1[i] == 0.0f) ? 0.5f : 1.0f;
}
else if (src2[i] == 0.0f) {
- temp = 0.0f;
+ temp = (src1[i] == 1.0f) ? 0.5f : 0.0f;
}
else if (src2[i] > 0.5f) {
temp = min_ff(((src1[i]) * 1.0f) / (2.0f * (1.0f - src2[i])), 1.0f);
@@ -1016,7 +1016,7 @@ MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], con
MINLINE void blend_color_difference_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -1034,7 +1034,7 @@ MINLINE void blend_color_difference_float(float dst[4], const float src1[4], con
MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
int i = 3;
@@ -1053,7 +1053,7 @@ MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], cons
MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
float h1, s1, v1;
float h2, s2, v2;
@@ -1081,7 +1081,7 @@ MINLINE void blend_color_color_float(float dst[4], const float src1[4], const fl
MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
float h1, s1, v1;
float h2, s2, v2;
@@ -1107,7 +1107,7 @@ MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const floa
MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
float h1, s1, v1;
float h2, s2, v2;
@@ -1134,7 +1134,7 @@ MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], con
MINLINE void blend_color_luminosity_float(float dst[4], const float src1[4], const float src2[4])
{
const float fac = src2[3];
- if (fac != 0.0f && fac < 1.0f) {
+ if (fac != 0.0f) {
const float mfac = 1.0f - fac;
float h1, s1, v1;
float h2, s2, v2;