[Bf-blender-cvs] [4f7280da404] master: Fix paint float color blending bugs with alpha 1.0 and vivid light.

Brecht Van Lommel noreply at git.blender.org
Wed Nov 29 18:13:37 CET 2017


Commit: 4f7280da404c5054da4061335fee1dac24d9c812
Author: Brecht Van Lommel
Date:   Wed Nov 29 02:13:37 2017 +0100
Branches: master
https://developer.blender.org/rB4f7280da404c5054da4061335fee1dac24d9c812

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

===================================================================

M	source/blender/blenlib/intern/math_color_blend_inline.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list